From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthias Koeppe Newsgroups: gmane.lisp.guile.devel Subject: Re: while break and continue Date: Wed, 13 Aug 2003 11:27:13 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <87isrtmhfw.fsf@zip.com.au> <87he79ic44.fsf@zagadka.ping.de> <878yshe1ux.fsf@zip.com.au> <87n0gf0zbc.fsf@zagadka.ping.de> <87fzm3m2n9.fsf@zip.com.au> <87smosrpp0.fsf@zagadka.ping.de> <8765lmkwpb.fsf@zip.com.au> <87znid1b4l.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1060767023 6409 80.91.224.253 (13 Aug 2003 09:30:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Aug 2003 09:30:23 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Aug 13 11:30:22 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mrxW-0007ps-00 for ; Wed, 13 Aug 2003 11:30:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mrwi-0005Xs-9S for guile-devel@m.gmane.org; Wed, 13 Aug 2003 05:29:32 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mrwY-0005TR-76 for guile-devel@gnu.org; Wed, 13 Aug 2003 05:29:22 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mruZ-0004PD-5F for guile-devel@gnu.org; Wed, 13 Aug 2003 05:27:51 -0400 Original-Received: from [141.44.75.40] (helo=merkur.math.uni-magdeburg.de) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mruY-0004Lt-Ll for guile-devel@gnu.org; Wed, 13 Aug 2003 05:27:18 -0400 Original-Received: from beta ([141.44.75.78] helo=beta.math.uni-magdeburg.de) by merkur.math.uni-magdeburg.de with esmtp (Exim 4.10) id 19mruU-0001Pd-00 for guile-devel@gnu.org; Wed, 13 Aug 2003 11:27:14 +0200 Original-Received: (from mkoeppe@localhost) by beta.math.uni-magdeburg.de (8.11.7+Sun/8.11.7) id h7D9RDU18752; Wed, 13 Aug 2003 11:27:13 +0200 (MEST) X-Authentication-Warning: beta.math.uni-magdeburg.de: mkoeppe set sender to mkoeppe@mail.math.uni-magdeburg.de using -f Original-To: guile-devel@gnu.org In-Reply-To: <87znid1b4l.fsf@zip.com.au> (Kevin Ryde's message of "Thu, 14 Aug 2003 07:49:30 +1000") Original-Lines: 37 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.3.50 (sparc-sun-solaris2.8) X-Warning: no 'abuse'-account in domain mail.math.uni-magdeburg.de (cf. RFC2142/4.) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2694 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2694 Kevin Ryde writes: +(define-macro (while cond . body) + (let ((key (make-symbol "while-key"))) + `(,do ((break ,(lambda () (throw key #t))) + (continue ,(lambda () (throw key #f)))) + ((,catch (,quote ,key) + (,lambda () + (,do () + ((,not ,cond)) + ,@body) + #t) + ,(lambda (key arg) arg)))))) I think you need a fresh catch tag for every invocation (not only for every macro expansion site) of WHILE. Consider this recursive example: (define (rec branch breaker) (while #t (case branch ((1) (display ".") (breaker)) ; should break the (dynamically) outer loop ; but only breaks the inner loop ((2) (rec 1 break))))) (rec 2 (lambda () #t)) This should display one "." and return because the dynamically outer loop (branch = 2) is broken. But with your implementation, both loops share the same catch tag, so only the inner loop (branch = 1) is broken, hence the outer loop continues indefinitely. -- Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel