Page 1 of 1

why setf don't work?

PostPosted: Tue Aug 01, 2017 3:03 pm
by psilwen
Code: Select all
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
Code: Select all
> (setf ('(1 2 3 4) 0) 5)
5
> (setf ((list 1 2 3 4) 0) 5)
5

Re: why setf don't work?

PostPosted: Tue Aug 01, 2017 7:22 pm
by Lutz
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:

Code: Select all
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/de ... nprogress/