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

Re: LISP has both pure and reference data types

(For those on CL-Object-Oriented-Programming and not on
Common-Lisp@SU-AI, there's been a discussion of the value of having
"read-only" CONS cells.)

One of the issues in the CommonLoops design was whether it would be
possible to (:include cons) in a new defstruct. Expressing it in
CommonLoops terms, the issue is: what is the metaclass of ($ cons)?
Possibilities are 

(a) "built-in", i.e., you can discriminate on "cons" but can't :include
it (this is what we've defined currently)

(b) "structure" (I don't think that's acceptable for any cdr-coded
implementation unless structure knows explicitly about cdr-coding),
i.e., equivalent to requiring it look like you did something like
(defstruct (cons (:conc-name nil)) car cdr)

(c) "apparent-structure" (it looks like structure to any sub-class with
slots car and cdr, but doesn't necessarly have those slots), and 

(d) "abstract", with some other class which is the "real" class-of
built-in conses, e.g. (class-of (cons)) = ($ real-cons)

  - - - - - - - - - - - - - - -
CommonLoops currently picks (a), so as not to mess up current
implementations that think they know-all about cons cells, and because
of performance issues with consp and listp. With most of the other
choices, making another class of read-only CONSes is quite possible, and
seems like a reasonable application of the class hierarchy. Case (d)
would require only that any subclass of "cons" be able to deal with car
and cdr somehow.