bugMIT/GNU Scheme - Bugs: bug #14792, append! does not modify an empty...

 
 

bug #14792: append! does not modify an empty list

Submitted by:  None
Submitted on:  Fri 14 Oct 2005 08:31:15 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect behavior
Status: InvalidPrivacy: Public
Assigned to: NoneOriginator Name: 
Originator Email: -unavailable-Open/Closed: Closed
Keywords: 

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 23 Oct 2005 09:07:51 PM UTC, comment #2:

This isn't a bug. It's a misunderstanding of the definition of append!. In any case it's impossible to do what you want since the empty list can't be modified.

Chris Hanson <cph>
Project Administrator
Sun 23 Oct 2005 04:28:38 PM UTC, comment #1:

This is not incorrect behaviour. There is no reasonable way for
APPEND! to 'modify an empty list'; there is only one empty list, and it
cannot be modified. As you see from the documentation, APPEND!
returns a list that is all of the arguments concatenated, and it
points out that it destroys the arguments. In fact, what this means is
that you can no longer reliably use any of the values you passed to
APPEND!: you should use only what it returns. If you want to set L to
be the concatenation of L's current value and some other list, use
(SET! L (APPEND L other-list)) or (SET! L (APPEND! L other-list)) --
the only difference between APPEND and APPEND! is that APPEND! is
allowed to reuse the storage of its input lists because you are saying
when you use it that you no longer need the values of the input lists.
APPEND! could have been defined as (DEFINE APPEND! APPEND) with no
semantic difference, just the pragmatic difference that it would cons.

SRFI 1 <http://srfi.schemers.org/srfi-1/srfi-1.html> has a good
explanation of routines like APPEND!, which are called /linear-update/,
and which are different from operations that reliably modify their
inputs.

Taylor R. Campbell <riastradh>
Project Member
Fri 14 Oct 2005 08:31:15 PM UTC, original submission:

(append! list ...) should destructively append to 'list' all the other arguments, if any.

for non-empty list it works:
(define l '(1))
(append! l '(2))
l

> (1 2)


for empty list it does not:
(define l '())
(append! l '(1))
l

> ()

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sun 23 Oct 2005 09:07:51 PM UTCcphStatusNone=>Invalid
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1