[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: continuations in Scheme
- From: Alex Queiroz <asandroq@...>
- Date: Tue, 22 Feb 2011 12:27:59 -0300
Hallo,
On Tue, Feb 22, 2011 at 11:53 AM, David Given <dg@cowlark.com> wrote:
> I'm not a Scheme programmer, but I recognise his description from C. In
> very approximate pseudocode:
>
I guess this is the translation:
(define (cont-example)
(let ((k #f)
(i 1)
(j (cons 1 '())))
(call/cc (lambda (label)
(set! k label)))
(display i)
(display " ")
(display j)
(newline)
(set! i 2)
(set-car! j 2)
(if k (let ((jmp k))
(set! k #f)
(jmp 42)))))
And this is the output:
1 (1)
2 (2)
Nothing is "rolled back" at all. BTW, this code is not representative
of Scheme, as it is very imperative. But it was based on the example
you gave me.
--
-alex
http://www.artisancoder.com/