[Openmcl-devel] Why doesn't #$ eval at read time?

alex crain alexcrain at mail.widgetworks.com
Sun Feb 6 21:45:51 UTC 2005


The solution is to just do #.#$foo whenever you need #$foo to be 
evaluated immediately (like in a CASE form)

My question is more about the nature of the #$foo macro, which 
evaluates to OS::|foo| which in turn evaluates
to an external constant.

If OS::|foo| is always a constant, why not have #$foo evaluate at read 
time?

I confess that I haven't dug through the code and that there may be 
some kind of circular dependency somewhere
that requires the delayed evaluation, I'm brining it up on the off 
chance that no one ever really thought about it.

:alex

On Feb 6, 2005, at 3:46 PM, David Steuber wrote:

> 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