On Jan 6, 1:00 pm, Vesa Karvonen <vesa.karvo...@[EMAIL PROTECTED]
> wrote:
> > (display (+ 1 (store/cc! cont 0))) ;=> displays 1
> > (cont 1) ;=> displays 2
>
> The above two lines form a loop, although, if you run the above from
> Bigloo's REPL, the continuation captured on the display expression seems
> to be limited to that expression.
You are right that this is a loop, even if typically the top-level
environment of R5RS Scheme is forgiving, I had forgotten about that.
On a whim, I wanted to check what happens with R6RS Scheme, where
there
is no top-level. I expected to see a loop and indeed this is what
happens
$ cat cont.ss
(im****t (rnrs))
(define-syntax store/cc!
(syntax-rules ()
((_ name body ...)
(call-with-current-continuation
(lambda (k) (set! name k) body ...)))))
(define cont #f)
(display (+ 1 (store/cc! cont 0)))
(cont 1)
$ scheme-script cont.ss
1222222222222222222222222222222222222222222222222222 ....
I run this with Ikarus Scheme, there aren't that many R6RS
compatibile implementations out there yet. So it looks like
SML has been doing the right thing for all these years ;)


|