[Openmcl-devel] User contributions

Brian Mastenbrook brian at mastenbrook.net
Sat Jun 13 16:43:35 PDT 2009


On Jun 13, 2009, at 5:51 PM, Ron Garret wrote:

> And just in case anyone actually tried this, it won't work.  The
> reason is that I'm doing (essentially) this:
>
> (defconstant +guardian+ (gensym))
>
> as part of my iterators code.  But it turns out this is a broken idiom
> because, as Gary points out in http://trac.clozure.com/ccl/ticket/539:
>
> The spec says:
>
> "If a defconstant form appears as a top level form, the compiler must
> recognize that name names a constant variable. An implementation may
> choose to evaluate the value-form at compile time, load time, or both.
> Therefore, users must ensure that the initial-value can be evaluated
> at compile time (regardless of whether or not references to name
> appear in the file) and that it always evaluates to the same value."
>
>
> I am open to suggestions on how to fix this because this leave me at a
> bit of a loss.

Use a symbol-macro instead:

(macrolet ((define-guardian (name) `(define-symbol-macro ,name ', 
(gensym))))
    (define-guardian +guardian+))
--
Brian Mastenbrook
brian at mastenbrook.net
http://brian.mastenbrook.net/




More information about the Openmcl-devel mailing list