From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.lisp.guile.user Subject: Re: C++ declaration style programming? Date: Wed, 21 Jan 2004 00:03:18 -0500 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <400E0816.6080902@indiana.edu> References: <16397.43262.881852.180514@localhost.localdomain> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1074661719 6784 80.91.224.253 (21 Jan 2004 05:08:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2004 05:08:39 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 21 06:08:33 2004 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 1AjAbR-0004xY-00 for ; Wed, 21 Jan 2004 06:08:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AjAXs-0003SE-FC for guile-user@m.gmane.org; Wed, 21 Jan 2004 00:04:52 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AjAX9-0003Q0-68 for guile-user@gnu.org; Wed, 21 Jan 2004 00:04:07 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AjAWa-0003DQ-6d for guile-user@gnu.org; Wed, 21 Jan 2004 00:04:03 -0500 Original-Received: from [129.79.1.73] (helo=plounts.uits.indiana.edu) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AjAWZ-0003Cj-Q8 for guile-user@gnu.org; Wed, 21 Jan 2004 00:03:31 -0500 Original-Received: from fontz.uits.indiana.edu (fontz.uits.indiana.edu [129.79.1.76]) by plounts.uits.indiana.edu (8.12.10/8.12.10/IUPO) with ESMTP id i0L53STY021973 for ; Wed, 21 Jan 2004 00:03:28 -0500 (EST) Original-Received: from indiana.edu (dial-124-19.dial.indiana.edu [156.56.124.19]) by fontz.uits.indiana.edu (8.12.10/8.12.10/IUPO) with ESMTP id i0L53Rsi010553 for ; Wed, 21 Jan 2004 00:03:28 -0500 (EST) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830 X-Accept-Language: en-us, en Original-To: guile-user X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:2671 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2671 Han-Wen Nienhuys wrote: > (begin-let* > (def var1 (something)) > (set! var1 (+ var1 2)) > (def var2 (something var1)) > (set! var2 (+ var2 var1)) > (def var3 (something var1 var2)) > ... ) > > > This can presumably be done by writing a macro begin-let* that expands > the statement list in a suitably nested let* > > However, I was wondering whether there exists a standard library > syntax mechanism that lets me write code in this fashion. > Untested... (define-syntax begin-let* (syntax-rules () ((_ args ...) (begin-let*-helper () () (args ...))))) (define-syntax begin-let*-helper (syntax-rules (def) ((_ (var ...) (statement ...) ()) (let ((var #f) ...) statement ...)) ((_ vars (statement ...) ((def x y) . rest)) (begin-let*-helper (x . vars) (statement ... (set! x y)) rest)) ((_ vars (statement ...) (non-decl . rest)) (begin-let*-helper vars (statement ... (set! x y)) rest)))) You could be slightly more clever about reversing the statements _after_ accumulating them, rather than appending (and building the same list over and over and over...). But I'll leave that as an easy exercise. Odd to call it "declaration style", though. Lynn _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user