bugKawa - Bugs: bug #15579, append-map may destroy arguments.

 
 

bug #15579: append-map may destroy arguments.

Submitted by:  None
Submitted on:  Mon 30 Jan 2006 08:06:59 PM UTC  
 
Category: Scheme librarySeverity: 3 - Normal
Item Group: Unexpected resultStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 16 Mar 2006 05:56:43 AM UTC, comment #4:

I checked in to CVS the fix for this.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 09 Mar 2006 11:22:47 PM UTC, comment #3:

Try replacing append-map and append-map! in srfi1.scm with these:

(define (append-map f lis1 . lists)
(if (pair? lists)
(apply append (apply map f lis1 lists))
(apply append (map f lis1))))

(define (append-map! f lis1 . lists)
(if (pair? lists)
(apply append! (apply map f lis1 lists))
(apply append! (map f lis1))))

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 09 Mar 2006 06:14:43 AM UTC, comment #2:

But the problem is not a set-car! on a constant. The
problem is append-map assuming that the value
returned by the function will not be used again. Consider:

(append-map (lambda (x) (hash-table-ref/default ht x '())) ls)

I don't want the values on my hash table to be modified
by append-map, and all those values are created with
cons, not quote.

Anonymous
Sat 11 Feb 2006 01:56:16 AM UTC, comment #1:

Well, it's not really a Kawa bug - the test program is not a well-defined program. It's just like:
(define p '(3 4))
(set-car! p 5)

Ideally, Kawa should throw an exception when you attempt to set-car! on a "constant" pair. That will probably happen in the not too distant future.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Mon 30 Jan 2006 08:06:59 PM UTC, original submission:

I found a bug while using KAWA-1.8.

If you run the below program, you can see that the program does not return at 2nd append-map call. I think the reason of this is that the constants in foo are destroyed by append! in append-map.

(require 'list-lib)

(define (foo x)
(cond ((= x 0) '(a))
((= x 1) '(b))
(else '())))

; It is ok.
(append-map foo '(0 1 2))

; But it does not return.
(append-map foo '(0 1 2))

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 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 16 Mar 2006 05:56:43 AM UTCbothnerStatusConfirmed=>Fixed
  Open/ClosedOpen=>Closed
Thu 09 Mar 2006 11:22:47 PM UTCbothnerStatusNone=>Confirmed
  Assigned toNone=>bothner

Back to the top


Powered by Savane 3.1-cleanup1