At Mon, 02 Aug 2010 20:42:34 +0900 (JST), Keiko Nakata wrote:
> This code prints "hi" twice,
> 
> (define d (box #f))
> 
> (+ (begin (let/cc k (begin (set-box! d k) 3))) (begin (print "hi") 9)) 
> 
> ((unbox d) 0)
> 
> whereas this prints "hi" once
> 
> (define d (box #f))
> 
> (begin (begin (let/cc k (begin (set-box! d k) 3))) (print "hi")) 
> 
> ((unbox d) 0)
> 
> Why?

Each form at the top level is wrapped in a prompt, and the content of a
top-level `begin' is spliced into the top level.

The latter program is the same as

 (define d (box #f))

 (let/cc k (begin (set-box! d k) 3))
 (print "hi")

 ((unbox d) 0)

where there's an implicit prompt around the `let/cc' form.

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to