From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Viktor Pavlenko Newsgroups: gmane.lisp.guile.user Subject: help with define-syntax Date: Sat, 10 Jan 2004 12:54:38 -0500 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <16384.15454.842037.476033@shmyh.ua> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1073757617 18864 80.91.224.253 (10 Jan 2004 18:00:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 10 Jan 2004 18:00:17 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jan 10 19:00:13 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 1AfNPB-0000gp-00 for ; Sat, 10 Jan 2004 19:00:13 +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 1AfOJs-0005ph-S4 for guile-user@m.gmane.org; Sat, 10 Jan 2004 13:58:48 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AfOI2-0005IZ-3w for guile-user@gnu.org; Sat, 10 Jan 2004 13:56:54 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AfOHN-00056Z-3x for guile-user@gnu.org; Sat, 10 Jan 2004 13:56:44 -0500 Original-Received: from [24.156.164.241] (helo=shmyh.ua) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AfOHL-00055c-9P for guile-user@gnu.org; Sat, 10 Jan 2004 13:56:11 -0500 Original-Received: by shmyh.ua (Postfix, from userid 502) id DF069E628; Sat, 10 Jan 2004 12:54:38 -0500 (EST) Original-To: guile-user@gnu.org X-Mailer: VM 7.17 under Emacs 21.2.1 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:2570 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2570 Hello, (warning: this is a newbie question, please be patient:) I'm experimenting with syntax rules and can't figure out how to achieve something that seems reasonable. I want to define a syntax to combine each of supplied procedures with `and' (well my ultimate goal is more ambitious but first things first) while adding some extra argument to them, and it works fine if done like this: --------------------------------------------------------------8< (use-syntax (ice-9 syncase)) (define (f1 a b c) (lambda (ls) (format #t "in proc made by f1: ~A/~A~%" (list a b c) ls) #t)) (define (f2 a b) (lambda (ls) (format #t "in proc made by f2: ~A/~A~%" (list a b) ls) #t)) (define (f3 a) (lambda (ls) (format #t "in proc made by f3: ~A/~A~%" (list a) ls) #t)) (define-syntax *flt* (syntax-rules() ((_ (a) (and (f1 a1 ...) (f2 a2 ...) ...)) (lambda (ls) (display "in xxx") (newline) (and ((f1 a a1 ...) ls) ((f2 a a2 ...) ls) ...))))) (define pr (*flt* ("arg-a") (and (f3) (f1 "arg-f1-1" "arg-f1-2") (f3) (f2 "arg-f2-1")))) (pr '(1 2 3)) (pr '(11 22 33)) --------------------------------------------------------------8< Now, I want to avoid calling f1, f2, ... each time the resulting procedure is called but rather make a closure with `let', something like --------------------------------------------------------------8< (define-syntax *flt* (syntax-rules() ((_ (a) (and (f1 a1 ...) (f2 a2 ...) ...)) (let ((f1-pr (f1 a a1 ...)) (f2-pr (f2 a a2 ...)) ...) (lambda (ls) (display "in xxx") (newline) (and (f1-pr ls) (f2-pr ls) ...)))))) --------------------------------------------------------------8< but it won't work: I get an "extra ellipsis" error in the last `and' statement, and if I comment it out, `let' will complain about "duplicate bound variable". A hint how to do it properly would be much appreciated. TIA -- Viktor _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user