guile-user
[Top][All Lists]
Advanced

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

Re: continuation?


From: rm
Subject: Re: continuation?
Date: Sun, 25 May 2003 20:29:47 +0200
User-agent: Mutt/1.5.3i

On Sun, May 25, 2003 at 04:58:50AM -0700, Bill Schottstaedt wrote:
> Why doesn't Scheme have "continuation?"?  Here's a
> toy example:
> 
> (catch 'got-c-g
>  (lambda ()
>    (do ((i 0 (1+ i)))
>        ((= i 100))
>      (if (c-g?) ; returns #t if C-g was typed
>        (call-with-current-continuation
>         (lambda (return)
>           (throw 'got-c-g return))))
>      (display (format #f "back again: ~A" i))
>      (sleep 1)))
>  (lambda args
>    (display (format #f "caught C-g: ~A" args))
>    (if (continuation? (cadr args))
>        ((cadr args) #f))))
> 
> 
> It's not hard to implement in Guile; something like:
> 
> SCM_BOOL (SCM_NIMP (obj) && (SCM_CONTINUATIONP (obj)))

Even more easy: 

 SCM_BOOL (SCM_CONTINUATIONP (obj))


The macro SCM_CONTINUATIONP gets rewritten to SCM_TYP16_PREDICATE 
(scm_tc16_continuation, x) and that macro allready does the SCM_NIMP-testing (i 
think
this _is_ actually described in the docu somewhere).
But i agree, 'continuation?' should be available on the Scheme level.

  Ralf Mattes




reply via email to

[Prev in Thread] Current Thread [Next in Thread]