[Openmcl-devel] Why doesn't #$ eval at read time?
David Steuber
david at david-steuber.com
Sun Feb 6 12:46:28 PST 2005
Hi,
On Jan 25, 2005, at 9:25 PM, alex crain wrote:
>
> I just discovered that this doesn't work....
>
> (case event-type
> (#$NSLeftMouseDragged
> (stuff...))
> (#$NSLeftMouseUp
> (more-stuff...)))
>
> because it expands to
>
> ...
> (COND ((EQ #:G7256 'OS::|NSLeftMouseDragged|))
> ....
Did you ever find a good solution for this? I would prefer to use CASE
for this also but I have been using my own macro based on something
Kent Pitman posted to c.l.l a while back:
(defmacro case-equal (exp &body clauses)
(let ((temp (gensym)))
`(let ((,temp ,exp))
(cond ,@(mapcar #'(lambda (clause)
(destructuring-bind (keys . clause-forms)
clause
(if (eq keys 'otherwise)
`(t , at clause-forms)
(if (atom keys)
`((equal ,temp ,keys)
, at clause-forms)
`((member ,temp ',keys :test
#'equal)
, at clause-forms)))))
clauses)))))
It would be nice to have #$foo fully evaluated for use in CASE.
More information about the Openmcl-devel
mailing list