[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Well, nobody has expressed a strong opinion about the issue I raised, so
let me make a proposal for what should appear in the manual.

1. DEFCONSTANT does not create a "symbol macro".  Conceptually, it
evaluates the init form at load time and sets the global special value
of the variable to that value.  It also causes this symbol to be
CONSTANTP.  The semantics of DEFCONSTANT differs from DEFVAR only in
that you must supply an init and you are declaring to the compiler that
the value of the variable will never be changed.  The compiler can do
whatever it wants to with that information, but it must preserve the
variable-reference semantics.  If the user violates this declaration, it
it "is an error" and might cause bad things to happen, but it might not
be signalled.

2. Numbers are particularly slippery items in Common Lisp.  If you set X
to a number, it is not necessarily the case that (EQ X X), though you
can count on (EQL X X).  This needs to be noted in the data type
chapter, and also should be referred to under EQ and maybe under

3. I would like to include byte-specifiers in this slippery class as
well.  Some implementations may choose to make these into numbers.  In
any event, these are things that you especially want to do replacement

4. Given the above rules, if X is a constant defined by DEFCONSTANT, the
compiler knows that it is safe to substitute the initial value V
(quoted) for references to X if V is a number of any kind, a byte
specifier, a symbol, or any kind of immediate object whose creation
involves no consing.  A more complex compiler might be able to
substitute for other kinds of V if it can prove that the value is
consumed locally in a way that does not depend on EQ-ness, and that it
cannot escape the local environment to be EQ-tested elsewhere.

5. For now if you want the effect of symbol-macros, you have to do
something like

(defmacro x () '(a b c d e))
(print (x))

instead of

(defconstant x '(a b c d e))
(print x)

We may want to consider putting true symbol-macros into the next
edition, but let's not worry about this now.  They are convenient, but
non-essential and somewhat confusing.

-- Scott