Tim, if you paste your code in the definitions in DrRacket (with the #lang
racket line), and run it (as a module, thus), you obtain this in the
interactions window:
3
10
6
The `3` is because of the `(add1 (call/cc ... 2)))` expression, which is
reduced to `(add1 2)` with the side effect of recordi
The duplication is because you're evaluating the expression at top
level, so the repl is part of the continuation. The continuation isn't
(lambda (c) (c e2); it's actually something like (lambda (c)
(evaluate-in-repl (c e2)). So when you run (ret 9), you're actually
re-running the repl you had when
I've read a lot about call/cc, and each time wind up just moving on. So
this is an early New Year's resolution: getting a better understanding of
it.
According to Wikipedia's page on continuations, the continuation of the
statement:
((call/cc f) e2)
is:
(lambda (c) (c e2))
#lang racket
(define
3 matches
Mail list logo