On Wed 13 Apr 2011 19:31, Wolfgang J Moeller <w...@heenes.com> writes:

> Last resort: Once we do allow for argument(s) to (break),
>
>    (while #t ... (break x) ... (break y) ...)

If I understand you right, this is more like a coroutine, which could
use an orthogonal form:

(define-syntax with-yield
  (lambda (x)
    (syntax-case x ()
      ((_ yield exp exp* ...) (identifier? #'yield)
       #'(let ((tag (make-prompt-tag)))
           (define (handler k . args)
             (define (resume . args)
               (call-with-prompt tag
                 (lambda () (apply k args))
                 handler))
             (apply values resume args))

           (call-with-prompt
            tag
            (lambda ()
              (let-syntax ((yield (syntax-rules ()
                                    ((_ arg (... ...))
                                     (abort-to-prompt tag arg (... ...))))))
                exp exp* ...))
           handler))))))

Then you can

  (with-yield yield
    (while #t ... (yield) ...))

Regards,

Andy
-- 
http://wingolog.org/

Reply via email to