[plt-scheme] set! in lazy.ss

From: jos koot (jos.koot at telefonica.net)
Date: Sun Jan 28 10:14:14 EST 2007

Hi,
Welcome to DrScheme, version 369.6-svn27jan2007 [3m].
Language: Lazy Scheme.

In
(define (kons x y) (set! cons-counter (add1 cons-counter)) (cons x y))
set! work as expected.

However, at toplevel or (module toplevel)
(set! cons-counter 0) --> promise and hence:
cons-counter --> old value, not 0

Easy to repair:
(! (set! cons-counter 0)) --> void
cons-counter --> 0

However, this leaves me with a question. Is there a reason why the set! form 
requires forcing at toplevel but does not within the body of a procedure? I 
don't understand this and any comment would be very welcome.
Jos Koot

(((((lambda(x)((((((((x x)x)x)x)x)x)x)x))
    (lambda(x)(lambda(y)(x(x y)))))
   (lambda(x)(x)x))
  (lambda()(printf "Greetings, Jos~n")))) 



Posted on the users mailing list.