[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How constant are defconstants?
- To: Jim Meehan <Meehan@YALE.ARPA>
- Subject: How constant are defconstants?
- From: "Scott E. Fahlman" <Fahlman@CMU-CS-C.ARPA>
- Date: Thu, 04 Oct 1984 00:18:00 -0000
- Cc: Common-Lisp@SU-AI.ARPA
- In-reply-to: Msg of 3 Oct 1984 17:57-EDT from Jim Meehan <Meehan at YALE.ARPA>
- Sender: FAHLMAN@CMU-CS-C.ARPA
The following is my own view on this issue. If anyone out there in
net-land disagrees, speak up.
The concept of enforced read-only data structures is not included in
Common Lisp, because implementations on some machines and on some
operating systems just couldn't hack that without an unacceptable
penalty in performance.
It "is an error" to mess with something declared to be a constant, which
means that the compiler can play various tricks, but doesn't have to. An
implemenations could build such a structure in some sort of read-only
space and signal an error if you try to alter it, but again it doesn't
have to. The same is true with :READ-ONLY slot options in Defstruct --
all this really guarantees is that no SETF form is created for this
So if you want to create a read-only structure that guarantees to signal
an error if you touch it, there may be a way to do this in some
implemenations, but there's no way to do this in portable Common Lisp.
You might just as well create your structure with DEFVAR.