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

Re: Issue DEFCONSTANT-VALUE



> I would like to see some mention in this proposal of what users are
> supposed to do if the constant value truly cannot be computed at
> compile time and you do want nasty things to happen if the user
> rebinds or SETQs the variable.  (For example, perhaps the constant
> holds some value that is specific to the particular machine the Lisp
> is running on, such as the amount of physical memory.)

Well, let's see.   You've got something like

  (DEFCONSTANT MEMORY-SIZE (DETERMINE-MEMORY-SIZE))

and you want the value computed at load time, which means that references
to MEMORY-SIZE later in the same file will need to be compiled like a
special variable access.  So you compile the file and load the object, at
which time MEMORY-SIZE is given a value.  Now, when someone compiles
another file which uses MEMORY-SIZE, they will be prevented from altering
it as you wish.  However, since the value is presumably a number, there is
nothing to prevent the value from being wired in to their compiled code,
which means that their object file won't work right if loaded on another
machine with a different amount of memory.  So it doesn't appear that this
example will work meaningfully with any of the current proposals for
DEFCONSTANT.

What you probably want is a new construct midway between DEFCONSTANT and
DEFPARAMETER which has the feature of preventing run-time alteration, but
never permits the compiler to wire in the value.  It happens that the
Explorer has such a capability that is used internally for system
quantities where run-time alteration could crash the system, but we don't
want the value wired into object files in order to avoid incompatibilities
between software releases.  I haven't heard any one before desiring to
have that capability available to users, but I wouldn't object to the
idea.  Now, if we can just think of a word similar to "constant" but less
so ... anyone have a thesaurus handy?