chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] set!


From: Andy C
Subject: [Chicken-users] set!
Date: Thu, 27 Feb 2014 22:28:06 -0700

Hi,

I am trying to wrap my head around following, from SICP book:

#;1> (define a (cons 1 2))
#;2> (define b (cons a a))
#;3> a
(1 . 2)
#;4> b
((1 . 2) 1 . 2)
#;5> (set-car! (car b) 3)
#;6> a
(3 . 2)

... changing underlying value affects everything. However in seemingly similar exercise:

#;1> (define x 1)
#;2> (define a (cons x x))
#;3> (define b (cons a a))
#;4> a
(1 . 1)
#;5> b
((1 . 1) 1 . 1)
#;6> (set! x 3)
#;7> a
(1 . 1)
#;8> b
((1 . 1) 1 . 1)

nothing really happens. It poses the question, at what point Scheme uses references instead of evaluating the result. Any ideas?

Thx,
Andy

reply via email to

[Prev in Thread] Current Thread [Next in Thread]