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

Re: call/cc

When I was first trying to grok continuations as a Scheme novitiate, I
found the sequence below very enlightening.  Try to understand what's
going on here; I'll post a detailed description in a day or two.

> (define (identity-fn x) x)
> (define (current-continuation) (call/cc identity-fn))
> (define foo (current-continuation))
> foo
> (foo 10)
> foo

Bob Glickstein                | Internet: bobg@andrew.cmu.edu
Information Technology Center | Bitnet:   bobg%andrew@cmuccvma.bitnet
Carnegie Mellon University    | UUCP:     ...!harvard!andrew.cmu.edu!bobg
Pittsburgh, PA  15213-3890    |
(412) 268-6743                | Sinners can repent, but stupid is forever