Build problem? constant literal lists?



Maxima 5.12.0

While we are at it, has anybody checked whether the
use of constant lists is safe in Maxima?



The problem:

(defvar *foo* '(bar baz))

We are not allowed to destructively change the list structure
in ANSI Common Lisp. You can set the variable to a new
list, but you are not allowed to change the list otherwise.
The lists are constant in ANSI CL and can even be shared.

(defvar *foo1* '(bar baz))

Now the compiler can set *foo* and *foo1* to the same
list (sharing the list).

This is not only for DEFVAR, but all kinds of places
where constant literal items (lists, strings, arrays, ...)
can be used.

As a consequent all lists that will be modified
in a program need to be CONSed.

So instead

(defvar *foo* '(1 2 3))

; destructive use is not allowed!
(setf (second *foo*) 4)


We need


(defvar *foo* (list 1 2 3))

; destructive use is allowed!
(setf (second *foo*) 4)


If we not use this consing of lists, we will see
lots of interesting effects. :-(

-- 
http://lispm.dyndns.org