Hi Lutz,
The problem below looks familiar to me but i cant find/recall the explenation in the manual,
perhpas you can clear me up.. I would intepret it as a bug , as its not explained as a feature in the manual.
The question is , why doesn't the use of -1 or 'last apply to setq/setf for strings?
As the impression is made inside the manual that setq/setf can be used for string manipulation.
Problem is, with common sense, im unable to append 2 strings without deleting the last char. of the first.
> (setq A "Hello/")
"Hello/"
> (setq (A -1) "world")
"world"
> A
"Helloworld"
> (setq (A -1) "!")
"!"
> A
"Helloworl!"
> (setq (last A) "!")
"!"
> A
"Helloworl!"
>
It behaves exactly like it should, analogous to lists:
> (set 'A '(w o r l d))
(w o r l d)
> (setf (A -1) '!)
!
> A
(w o r l !)
>
the -1 refers to the last element, which gets replaced. To append to a string or list destructively use either 'push':
> (set 'A "world")
"world"
> (push "!" A -1)
"world!"
or 'extend':
> (set 'A "world")
"world"
> (extend A "!")
"world!"
> A
"world!"
ps: setf and setq work/are the same in newLISP, but I prefer use setf when used destructive