Lisp HUG Maillist Archive

Re: defconstant and #.

Gregory Tod <hug@gtod.net> wrote:

>I suspect this is acceptable behaviour per the spec but have been unable 
>to find a truly satisfactory reference on the InterWeb.  Comment 
>appreciated.

I think the following is the relavent section <http://www.lisp.org/HyperSpec/Body/mac_defconstant.html#defconstant>:

<blockquote>
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.
</blockquote>

Because an implementation may choose to evaluate the value-form at load time, one is not guaranteed to be able to use that value at compile time.  Other posts have mentioned being able to control this behavior using EVAL-WHEN.


Updated at: 2020-12-10 08:43 UTC