Lisp HUG Maillist Archive

RE: Bit array should be local - acting global


> -----Ursprüngliche Nachricht-----
> Von: owner-lisp-hug@lispworks.com
> [mailto:owner-lisp-hug@lispworks.com] Im Auftrag von Mitch Berkson
> Gesendet: Montag, 10. September 2007 18:40
> An: lisp-hug@lispworks.com
> Betreff: Bit array should be local - acting global
> 
> 
> 
> After it is compiled and the first time the function below is
> called, it correctly prints #*00000000 as the value of the 
> local b-array.  When it is run again, it incorrectly returns 
> #*00010000.  There seems to be a problem with a bit array 
> inside a let not being local.
>  
> (defun bit-array-test ()
>   (let ((b-array #8*0))
>     (format t "b-array = ~A~%" b-array)
>     (setf (sbit b-array 3) 1)))
>  
>  
> Mitch
> 

Hi Mitch,

even if not compiled it behaves this way. I think it is the same as 

(defun list-test ()
  (let ((list '(1 2 3)))
    (format t "list = ~A~%" list)
    (setf (car list) 9)))

which produces a similar behaviour. I don't remember the exact terms of the explanation, but basically you invisibly modify your
source with programs like this.

Andreas


Updated at: 2020-12-10 08:45 UTC