lua-users home
lua-l archive

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


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/