From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang J Moeller Newsgroups: gmane.lisp.guile.bugs Subject: Re: shift and reset, plus "while" Date: Thu, 28 Apr 2011 16:44:26 +0200 (CEST) Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: dough.gmane.org 1304001946 8041 80.91.229.12 (28 Apr 2011 14:45:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Apr 2011 14:45:46 +0000 (UTC) Cc: bug-guile@gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Apr 28 16:45:42 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QFSTN-0007Hy-DZ for guile-bugs@m.gmane.org; Thu, 28 Apr 2011 16:45:41 +0200 Original-Received: from localhost ([::1]:57516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFSTM-0000Es-OA for guile-bugs@m.gmane.org; Thu, 28 Apr 2011 10:45:40 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFSTF-0000Ec-9g for bug-guile@gnu.org; Thu, 28 Apr 2011 10:45:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFSTD-0001A3-W7 for bug-guile@gnu.org; Thu, 28 Apr 2011 10:45:33 -0400 Original-Received: from emailer.gwdg.de ([134.76.10.24]:58447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFSTD-00019l-GX for bug-guile@gnu.org; Thu, 28 Apr 2011 10:45:31 -0400 Original-Received: from gwdw03.gwdg.de ([134.76.5.10]) by mailer.gwdg.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1QFSST-0000dC-Vz; Thu, 28 Apr 2011 16:44:46 +0200 In-Reply-To: X-Virus-Scanned: (clean) by exiscan+sophie X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 134.76.10.24 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5537 Archived-At: Hi Andy, >[...] > On Mon 04 Apr 2011 15:05, Wolfgang J Moeller writes: > > > (a) to always have a well-defined result > > (b) to allow for (break arg ...) > > I have implemented this in stable-2.0. It did not make it into 2.0.1 > however. Incidentally it should be compatible with the old 1.6 `while'. Great. Thanks! No more reason to consider my "last resort": > On Wed, 13 Apr 2011, Andy Wingo wrote: > >[...] > > >From Guile 1.6: > >[...] > > It did indeed happen to return #t on a normal termination, and have > > (break ARG). It has lots of other bugs though. I would prefer (break) > > to return zero values, and (while #f 1) as well, but that is > > incompatible with 2.0. Bummer. > > OK, that explains why I have an old & lengthy program that does use > (break arg), and why I had to keep my macro compatible. > > Last resort: Once we do allow for argument(s) to (break), > > (while #t ... (break x) ... (break y) ...) > > allows for full functionality, plus returning all well-defined results, > without necessarily requiring well-defined (or even different) results > from (break) and (while #f). > > Only that this construct might better be called "loop/return" ... Sorry, this was meant as a loop that would _only_ be terminated [conditionally] by (BREAK arg . optargs) forms [at various places]. I had proposed this, so - for compatibility - both of the other forms (while #f ... ) and (break) w/o arguments within (while ...) could return whatever values you'd like (including #). Maybe you just did implement point (a) above this way ... === >[...] > (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) ...)) While not asked for, great macro anyway ;-) I eventually got to try it out and check if it's "call/cc-compatible" [remember my (solved) problem to have general reset/shift-based co-routines?]. === Next going to play with 2.0.1 ! Best regards, Wolfgang J. Moeller, Tel. +49 551 47361, wjmheenes.com 37085 Goettingen, Germany | Disclaimer: No claim intended! http://www.wjmoeller.de/ -+-------- http://www.heenes.com/