bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#58513: describe-function should say that defconst variables are cons


From: Drew Adams
Subject: bug#58513: describe-function should say that defconst variables are constant
Date: Sun, 16 Oct 2022 21:11:01 +0000

>   > And then, in a later Emacs version, we could start enforcing the
>   > constness in running code.
> 
> defconst has had a subtle meaning: "It is ok to expect, in certain
> limited ways, that the value will not be altered."  Nothing more.
> 
> This change may seem to be fixing a bug, but some old programs used to
> take advantage of the actual old meaning.  This change might break
> them.
> 
> I think that would be asking for trouble, and we have better things to
> do than deal with that trouble.

+1.
_____


FWIW, Common Lisp has `defconstant':

"Constant symbols defined by defconstant also become reserved
 and may not be further assigned to or bound (although they
 may be redefined, if necessary, by using defconstant again)."

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node58.html#SECTION00912000000000000000

"...assert that the value of the variable name is fixed and
 does license the compiler to build assumptions about the
 value into programs being compiled. (However, if the compiler
 chooses to replace references to the name of the constant by
 the value of the constant in code to be compiled, perhaps in
 order to allow further optimization, the compiler must take
 care that such ``copies'' appear to be eql to the object that
 is the actual value of the constant. For example, the compiler
 may freely make copies of numbers but must exercise care when
 the value is a list.)"

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node67.html#SECTION00932000000000000000


reply via email to

[Prev in Thread] Current Thread [Next in Thread]