[Openmcl-devel] User contributions
ron at awun.net
Sun Jun 14 00:58:13 UTC 2009
On Jun 13, 2009, at 4:43 PM, Brian Mastenbrook wrote:
> 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
>> because, as Gary points out in http://trac.clozure.com/ccl/ticket/
>> 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
>> 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 ',
> (define-guardian +guardian+))
That fails if you reload an uncompiled version of the file.
Ironically, using DEFVAR instead of DEFCONSTANT or DEFINE-SYMBOL-MACRO
comes closest to doing the Right Thing -- but then you can't rely on
the system to prohibit assignment and rebinding.
More information about the Openmcl-devel