david135 / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

set-car! called by value instead of by reference #139

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Evaluating the following lines:
(define a '(0))
(define (set-car-wrapper! list x)
    (set-car! list x))
(set-car-wrapper! a 3)

What is the expected output? What do you see instead?
a should be (3) yet evaluating the above results in an error.

What version of the product are you using? On what operating system?
Ypsilon 0.9.6-update3 running under Ubuntu 9.04.

Please provide any additional information below.

Original issue reported on code.google.com by Daniel.L...@gmail.com on 25 Apr 2010 at 11:22

GoogleCodeExporter commented 9 years ago
It seems intended, not a bug.
The literal expression '(0) is for creating an immutable pair, so
set-car-wrapper! raises 'error in set-car!: attempt to modify literal constant 
(0)'.

Instead, the following works well:
> (define a (list 0))
> (define (set-car-wrapper! list x)
    (set-car! list x))
> (set-car-wrapper! a 3)
> a
(3)
> 

Original comment by tabe.fix...@gmail.com on 24 Jun 2010 at 5:10

GoogleCodeExporter commented 9 years ago
Also, MIT/GNU Scheme runs it just fine.

Original comment by Daniel.L...@gmail.com on 24 Jun 2010 at 1:14