why setf don't work?

Started by psilwen, August 01, 2017, 08:03:04 AM

Previous topic - Next topic

psilwen


newLISP v.10.7.1 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h

> (struct 'RECT "long" "long" "long" "long")
RECT
> (unpack RECT (pack RECT 1 2 3 4))
(1 2 3 4)
> ((unpack RECT (pack RECT 1 2 3 4)) 0)
1
> (setf ((unpack RECT (pack RECT 1 2 3 4)) 0) 5)

ERR: symbol is protected : RECT
> (setq r (unpack RECT (pack RECT 1 2 3 4)))
(1 2 3 4)
> (setf (r 0) 5)
5
> r
(5 2 3 4)


why setf do in-place modifying don't work?

but

> (setf ('(1 2 3 4) 0) 5)
5
> (setf ((list 1 2 3 4) 0) 5)
5
(reverse \"newlisp\")

Lutz

#1
Thanks for this discovery, the protection status of RECT should'nt be an issue in that expression as only the evaluation result of it is changed in place. Fixed now:


newLISP v.10.7.3 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h

>  (struct 'RECT "long" "long" "long" "long")
RECT
> (setf ((unpack RECT (pack RECT 1 2 3 4)) 0) 5)
5
>


http://newlisp.nfshost.com/downloads/development/inprogress/">http://newlisp.nfshost.com/downloads/de ... nprogress/">http://newlisp.nfshost.com/downloads/development/inprogress/