[plt-scheme] append!?

From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk at info.unicaen.fr)
Date: Sat Oct 20 13:40:49 EDT 2007

Pierpaolo Bernardi writes: 

> On 10/20/07, Majorinc, Kazimir <kazimir at chem.pmf.hr> wrote:
>> (append! x y) results in concatenation of the values of x and y.
>> But, is it guaranteed that result is stored in x? I've read something
>> like that in Help Desk, but I'm still not completely without doubt. Do I
>> need to write (set! x (append! x y))
> yes 
> | or (append! x y) is always enough? 
> no

I am sorry, but the question suggests that the asker is not well acquainted
with the intricacies of destructive procedures, and such a two word answer
is not very helpful. If Pierpaolo Bernardi didn't want to waste his time,
he could go further. 

USUALLY, pragmatically, the answer is yes, since if a variable, say:
(define x '(1 2))
is processed by (append! x '(3))
then x becomes, physically, (1 2 3). The last (null) cdr pointer of
*the value* of x has been replaced by the new list. 

BUT if x=(), then no choice, a constant cannot be modified, otherwise we
would have a situation similar to some old Fortran systems, where the user,
exploiting the call-by-reference, *could* change a (stored) constant, say
make 2 behave as zero... 

Jerzy Karczmarczuk 

Posted on the users mailing list.