Subject: Re: Is there a better way?
From: (Rob Warnock)
Date: Sat, 22 Sep 2007 07:14:55 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Raffael Cavallaro  <raffaelcavallaro@pas-d'espam-s'> wrote:
| Kent M Pitman <> said:
| > Does this help?
| Maybe I'm confused as well, but for me the issue arises because I
| would expect that (constantp x) would tell me if x is a constant
| *object*, which is to say, I would expect that constantp would tell
| me if an object is immutable. Instead, constantp tells me if a
| *form* is a constant form, which is not always helpful.

That's correct [in both senses]. E.g., in an implementation like CMUCL
which chooses[1] to evaluate the value of a (DEFCONSTANT <var> <form>)
at LOAD time, a (CONSTANTP <var>) can return T at compile time and yet
the *value* of <var> is *NOT* available at compile time!!

To say that at times this can be frustrating is an understatement...  ;-}


[1] Legally, according to CLHS "Macro DEFCONSTANT":

        If a defconstant form appears as a top level form, the
        compiler must recognize that name names a constant variable.

    That implies that a (CONSTANTP <var>) later in the code *must*
    return T, but:

	An implementation may choose to evaluate the value-form
	at compile time, load time, or both.

    So attempting to *reference* the value of <var> at compile time
    is allowed to fail... even if <form> is a simple literal!

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607