On Aug 30, 2012, at 5:48 PM, Harry Spier wrote: > When I run this in the definitions window of DrRacket > #lang racket > (+ 100 > (call-with-composable-continuation > (λ (k) (+ 1000 (k 1))))) > > it prints > 101 > 1201 > in the interactions window. > Why doesn't it just print 1201 ?
As John says, the meaning of this program isn't "on its sleeve" as semanticists used to say in the 1980s. If you use the Macro Stepper to expand the above program (- racket, -library), you get (module anonymous-module racket (#%module-begin (#%app call-with-values (lambda () (#%app + (quote 100) (#%app call-with-composable-continuation (lambda (k) (#%app + (quote 1000) (#%app k (quote 1))))))) print-values))) The key is to note that an expression is wrapped in a (call-with-values . print-values), plus an outer #%module-begin. Hence the meaning of cwcc is (at least) (lambda (x) (call-with-values (lambda () (+ 100 x)) print-values)) ;; --- In contrast, the same expression in the repl gets expanded via #%top, which does not wrap the print-values around it -- after all the "printer" is a part of the REPL. ;; --- Perhaps this is somewhat ironic, because the idea is really that each expression in the def window should be wrapped in a "prompt" -- but it means only "control delimiter". Something to consider is that we take the meaning of the word "prompt" literally and have the two areas behave identically. -- Matthias
smime.p7s
Description: S/MIME cryptographic signature
____________________ Racket Users list: http://lists.racket-lang.org/users