Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: continuatio...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 2716 of 2972
Post > Topic >>

Re: continuations in SML

by Michele Simionato <michele.simionato@[EMAIL PROTECTED] > Jan 6, 2008 at 04:32 AM

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 ;)
 




 7 Posts in Topic:
continuations in SML
Michele Simionato <mic  2008-01-05 22:15:11 
Re: continuations in SML
Vesa Karvonen <vesa.ka  2008-01-06 12:00:29 
Re: continuations in SML
Michele Simionato <mic  2008-01-06 04:32:28 
Re: continuations in SML
Benedikt Rosenau <rose  2008-01-11 17:45:58 
Re: continuations in SML
Abdulaziz Ghuloum <agh  2008-01-12 03:14:19 
Re: continuations in SML
Abdulaziz Ghuloum <agh  2008-01-12 03:48:47 
Re: continuations in SML
Benedikt Rosenau <rose  2008-01-13 22:58:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Aug 30 8:18:02 CDT 2008.