Language standards for LispOS
Wed, 21 May 97 22:59:02 +0200
firstname.lastname@example.org (Henry G. Baker) wrote:
> I'd like to find out who uses &rest mutation, other than the beast who
> defines list as
> (defun list (&rest l) l)
In fact, the beast would be wrong, as &REST is allowed to share structure
with the last argument of APPLY, and LIST must still return a freshly
allocated list when called from APPLY. Of course, one could nevertheless
define some PRIVATE-LIST this way, if one didn't worry about sharing.
> Really, someone who depends upon the mutable properties of &rest lists
> should be taken out & shot, right?
I'm too peaceful for that, but something like tracing the execution of
an optimizing Common Lisp compiler (applied to itself) on paper would be
an appropriate punishment.
To protect the innocent user of such horrible software, one might simply
provide a compiler switch (via a declaration/proclamation) which tells
the compiler to generate mutable &REST lists, without any extraordinary
effort at optimizing it away, but use immutable &REST lists by default.
(DECLAIM (LISPOS:MUTABLE-&REST :SANE-DEFAULT))
(DECLAIM (LISPOS:MUTABLE-&REST :PEDANTIC))
That's an old trick to satisfy language lawyers: Define the "standard"
implementation to be invoked by starting your optimized version and then
switching off the optimization ;-)
-- Marc Wachowitz <email@example.com>