guile-devel
[Top][All Lists]
Advanced

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

Re: while break and continue


From: Kevin Ryde
Subject: Re: while break and continue
Date: Fri, 15 Aug 2003 11:43:01 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

Matthias Koeppe <address@hidden> writes:
>
> I think you need a fresh catch tag for every invocation (not only for
> every macro expansion site) of WHILE.

I think this might do the trick.  A separate helper is an easy way to
keep the "key" binding from being exposed to the cond and body.

(define-macro (while cond . body)
  (define (while-helper proc)
    (do ((key (make-symbol "while-key")))
        ((catch key
                (lambda ()
                  (proc (lambda () (throw key #t))
                        (lambda () (throw key #f))))
                (lambda (key arg) arg)))))
  `(,while-helper (,lambda (break continue)
                    (,do ()
                        ((,not ,cond))
                      ,@body)
                    #t)))




reply via email to

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