[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue DEFCONSTANT-VALUE (V2)
- To: David N Gray <Gray@dsg.csc.ti.com>
- Subject: Re: Issue DEFCONSTANT-VALUE (V2)
- From: sandra%defun@cs.utah.edu (Sandra J Loosemore)
- Date: Thu, 6 Oct 88 16:19:26 MDT
- Cc: CL-Compiler@sail.stanford.edu
- In-reply-to: David N Gray <Gray@DSG.csc.ti.com>, Thu, 6 Oct 88 16:24:53 CDT
I still have a couple of nits to pick with this proposal.
The value form may
be evaluated at compile-time in the null lexical environment [...]
It is
an error for the value expression to have a different value at load time
than it had at compile-time [...]
I'm still not clear on whether you want the run-time evaluation of the
value form to happen in a null lexical environment as well. If not, I
think the proposal should include some strong warnings about it, since
that would be a likely source of getting different values at load time
than at compile time.
Lucid also conforms to this proposal.
My understanding of JonL's comments on this were that Lucid only does
compile-time evaluation of the value form when the DEFCONSTANT appears
at top-level.
Cost to implementors:
The simple approach of just having DEFCONSTANT expand to (EVAL-WHEN
(EVAL COMPILE LOAD) ...) would be trivial to implement. A little more
work in the compiler would be needed if the value were to be remembered
temporarily during COMPILE-FILE, but this would be less effort than it
would take to implement the optimizations permitted by the previous
proposal.
I think this is a red herring. If you're going to go through the work
of implementing a way to temporarily remember values of constants
seen by the compiler, is one call to CONSTANTP going to make any
difference?
Here is one way of implementing DEFCONSTANT that is consistent with
your proposal:
(defmacro defconstant (name initial-value &optional documentation-string)
`(progn
(eval-when (compile)
(make-symbol-constant-in-compiler ',name)
(remember-constant-in-compiler ',name ,initial-value))
(make-symbol-constant ',name)
(setq ,name ,initial-value)
(setf (documentation ',name 'variable) ',documentation-strng)
',name))
And here is one way of implementing DEFCONSTANT that is consistent with
my original proposal:
(defmacro defconstant (name initial-value &optional documentation-string)
`(progn
(eval-when (compile)
(make-symbol-constant-in-compiler ',name)
,(if (constantp initial-value)
`(remember-constant-in-compiler ',name ,initial-value)))
(make-symbol-constant ',name)
(setq ,name ,initial-value)
(setf (documentation ',name 'variable) ',documentation-strng)
',name))
Not much difference between the two, hmmm? Seeing as though it only took
me about 5 minutes to compose both alternatives, I think we can pretty
much say that *anything* we decide to do with DEFCONSTANT is going to
be trivial to implement.
-Sandra
-------