[Top][All Lists]

[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: Tue, 29 Jul 2003 10:23:12 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

Marius Vollmer <address@hidden> writes:
> Do you want to put it into boot-9.scm?

Yes, I think it'd be good.  Actually what I'd like to put in is
something like

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

All the backquoting being designed to protect against local bindings
at expansion time.  I know what you said about compiler friendliness,
but I think for the moment protection against local defines would be

(I imagine a compiler might want to try to cooperate with application
macros like this using only basic list or procedure stuff, through
some sort of eval in a restricted environment or whatever.  But no
doubt plenty of people smarter than me have thought about such things

reply via email to

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