[plt-scheme] append!?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sat Oct 20 17:43:18 EDT 2007

These are comments about the specification of Scheme itself, I suppose?

Matthias was, I believe, speaking of PLT Scheme, which is definitely
always going to mutate (non-empty) lists that appear as the first
argument to append!.


On 10/20/07, hufflen at lifc.univ-fcomte.fr <hufflen at lifc.univ-fcomte.fr> wrote:
> >
> > (append! L1 L2) mutates the first cdr field in L1 that contains NULL
> > so that it points to L2.
> > It then returns L1. If L1 is NULL, it returns L2.
> >
> > You may wish to think of the overall effect of appending L2 at the
> > end of L1, but note that
> > append! is an imperative procedure and affects all pointers to L1
>    Personally, I think that the best approach of (append! L1 L2) is:
>    -it results in the concatenation of L1 and L2,
>    -L1 and/or L2 may be physically changed, but "may" should read as "may
> or may not". In fact:
> (define (append! L1 L2)
>   (append L1 L2))
> is a correct implementation: append! is allowed to be destructive but does
> not have to. So, catching the result of (append! x y) in x is:(set! x
> (append! x y))
> J.-M.
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.