From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: prj@po.cwru.edu (Paul Jarc) Newsgroups: gmane.lisp.guile.devel Subject: Re: puzzling things Date: Thu, 07 Aug 2003 11:18:41 -0400 Organization: What did you have in mind? A short, blunt, human pyramid? Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <20030806221246.GA16455@lark> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT X-Trace: main.gmane.org 1060269604 26019 80.91.224.253 (7 Aug 2003 15:20:04 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2003 15:20:04 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Aug 07 17:20:16 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 19kmYp-00075P-00 for ; Thu, 07 Aug 2003 17:20:15 +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 19kmXv-0003Xx-By for guile-devel@m.gmane.org; Thu, 07 Aug 2003 11:19:19 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19kmXr-0003XX-Cc for guile-devel@gnu.org; Thu, 07 Aug 2003 11:19:15 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19kmXL-00038l-4s for guile-devel@gnu.org; Thu, 07 Aug 2003 11:19:14 -0400 Original-Received: from [129.22.104.63] (helo=harris.CNS.CWRU.Edu) by monty-python.gnu.org with esmtp (Exim 4.20) id 19kmXK-00038I-RM for guile-devel@gnu.org; Thu, 07 Aug 2003 11:18:42 -0400 Original-Received: from multivac.cwru.edu (multivac.STUDENT.CWRU.Edu [129.22.114.26]) by smtp-a.cwru.edu (iPlanet Messaging Server 5.2 Patch 1 (built Aug 19 2002)) with SMTP id <0HJ900FDI9764F@smtp-a.cwru.edu> for guile-devel@gnu.org; Thu, 07 Aug 2003 11:18:42 -0400 (EDT) Original-Received: (qmail 9896 invoked by uid 500); Thu, 07 Aug 2003 15:19:04 +0000 In-reply-to: <20030806221246.GA16455@lark> Original-To: guile-devel@gnu.org Mail-followup-to: guile-devel@gnu.org Mail-Copies-To: nobody User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) Original-Lines: 53 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:2681 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2681 Andy Wingo wrote: > (define second-arg > (procedure->syntax > (lambda (x y) (cadr x)))) > > ((lambda () (second-arg a b c d))) > > I get some kind of error like this: > > 18: 2* [cadr (#@second-arg a b c d)] > > :18:18: In procedure cadr in expression (cadr x): > :18:18: Wrong type argument in position 1: (#@second-arg a b c d) - Scheme Procedure: procedure->syntax code - C Function: scm_makacro (code) Return a macro which, when a symbol defined to this value appears as the first symbol in an expression, returns the result of applying CODE to the expression and the environment. So when your macro is called, the first argument is the whole macro expression, and the second is the local environment. guile> (define foo ... (procedure->syntax ... (lambda args ... (format #t "~S\n" args) ... #f))) guile> (foo a b c) ((foo a b c) (#)) #f guile> (define foo (procedure->syntax (lambda (expr env) (caddr expr)))) guile> (foo a b c) b guile> (define foo (procedure->macro (lambda (expr env) (caddr expr)))) guile> (foo a b c) Backtrace: In current input: 10: 0* (foo a b c) ?: 1 b : In expression b: : Unbound variable: b ABORT: (unbound-variable) guile> (define b 3) guile> (foo a b c) 3 guile> (define-macro (foo . args) (cadr args)) guile> (foo a b c) 3 paul _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel