unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Wolfgang J Moeller <wjm@heenes.com>
Cc: bug-guile@gnu.org, guile-devel <guile-devel@gnu.org>
Subject: Re: [shift and reset, plus] "while"
Date: Thu, 28 Apr 2011 14:15:20 +0200	[thread overview]
Message-ID: <m34o5i373b.fsf@unquote.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.00.1104131810330.3553@gwdw03.gwdg.de> (Wolfgang J. Moeller's message of "Wed, 13 Apr 2011 19:31:32 +0200 (CEST)")

On Wed 13 Apr 2011 19:31, Wolfgang J Moeller <wjm@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	other threads:[~2011-04-28 12:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LNX.2.00.1104041402090.26447@gwdw03.gwdg.de>
2011-04-13  9:47 ` shift and reset, plus "while" Andy Wingo
2011-04-13 14:56   ` [shift and reset, plus] "while" Wolfgang J Moeller
2011-04-13 15:41     ` Andy Wingo
2011-04-13 17:31       ` Wolfgang J Moeller
2011-04-28 12:15         ` Andy Wingo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m34o5i373b.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=bug-guile@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=wjm@heenes.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).