[plt-scheme] backwards append!

From: Anton van Straaten (anton at appsolutions.com)
Date: Sun Mar 16 18:21:48 EST 2003

With the caveat that this is really picky and semantically questionable:

MzScheme's append! iterates backwards through its arguments (at least in
v202).  This leads to a result I wouldn't have expected in the following

(define l '(1 2))
(append l l '(3)) => (1 2 1 2 3)
(append! l l '(3)) => #0=(1 2 3 . #0#)

The meaning of that last result can only be understood if you realize that
append! is working backwards through its arguments.  Of course, if it worked
forwards through the arguments, this case would hang.  However, backwards
handling of the arguments is no defense against hanging - e.g. (append! l l
l) will hang either way.

Providing a real program in which this would matter, I leave as an exercise
for the reader.  It could matter in a lazy implementation of append!, which
might be expected to generate the list (1 2 1 2 ... 3).


Posted on the users mailing list.