[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
New special form suggestion: LET-CONSTANT
Date: Mon, 3 Aug 87 12:05:52 PDT
From: edsel!kent-state!eb@labrea.stanford.edu (Eric Benson)
There's actually no need for a declaration or special form. LET will
do fine all by itself. If the expression to which the variable is
bound is constant and there are no SETQs to the variable, all
references to the variable may be legitimately replaced by the
constant expression. This is a very common optimization in Lisp
compilers. However, as far as I know it is not done by the Symbolics
compiler.
I thought of that, and rejected it. I want to tell the compiler,
interpreter, and other programmers reading the code that a particular
name is a symbolic constant. If I accidentally assign to it, I want the
system to produce an error message. In Lisp this isn't a problem as
much as in my previous language, PL/I, because Lisp doesn't have call by
reference; however, I still prefer to code what I mean.
Someone else (DCP?) mentioned using MACROLET for this. I also
considered this, and almost did it. It just seemed more esthetically
unpleasing than the DEFCONSTANTs. Now, if Symbolics had SYMBOL-MACROLET
to go with their DEFINE-SYMBOL-MACRO, I could use that (my code was a
Zmail extension, so I had no reason not to use Symbolics-only features)
(actually, I don't really care for symbol macros, because they allow a
function call to masquerade as a variable reference, which is really
confusing to the reader).
barmar