From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Josef Wolf Newsgroups: gmane.lisp.guile.user Subject: Re: Need help to understand a macro Date: Mon, 22 Mar 2010 22:06:07 +0100 Message-ID: <20100322210606.GG31143@raven.wolf.lan> References: <20100319085701.GA31143@raven.wolf.lan> <4BA4D819.6020508@ludens.elte.hu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1269292227 26835 80.91.229.12 (22 Mar 2010 21:10:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Mar 2010 21:10:27 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Mar 22 22:10:22 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NtotC-0006pK-63 for guile-user@m.gmane.org; Mon, 22 Mar 2010 22:10:22 +0100 Original-Received: from localhost ([127.0.0.1]:38503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtotB-00084p-Kc for guile-user@m.gmane.org; Mon, 22 Mar 2010 17:10:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ntot8-00084T-22 for guile-user@gnu.org; Mon, 22 Mar 2010 17:10:18 -0400 Original-Received: from [140.186.70.92] (port=53783 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ntot6-00083u-Ev for guile-user@gnu.org; Mon, 22 Mar 2010 17:10:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ntot4-0002ak-Ih for guile-user@gnu.org; Mon, 22 Mar 2010 17:10:16 -0400 Original-Received: from quechua.inka.de ([193.197.184.2]:43153 helo=mail.inka.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ntot4-0002aT-Co for guile-user@gnu.org; Mon, 22 Mar 2010 17:10:14 -0400 Original-Received: from raven.inka.de (uucp@[127.0.0.1]) by mail.inka.de with uucp (rmailwrap 0.5) id 1Ntot2-0002F7-Pf; Mon, 22 Mar 2010 22:10:12 +0100 Original-Received: by raven.inka.de (Postfix, from userid 1000) id 6BB39760B3; Mon, 22 Mar 2010 22:06:07 +0100 (CET) Mail-Followup-To: Josef Wolf , guile-user@gnu.org Content-Disposition: inline In-Reply-To: <4BA4D819.6020508@ludens.elte.hu> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7712 Archived-At: On Sat, Mar 20, 2010 at 03:13:45PM +0100, szgyg wrote: > Josef Wolf wrote: > >I am trying to understand the defstruct macro from the "teach yourself > >scheme in fixnum days" tutorial, which can be found in chapter 9 at > >http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-11.html#node_chap_9 > > > >My first question is of a more generic type. For a better understanding > >how macros work, I'd like to have a way to show what expansion a macro > >would generate when it would be used. E.g., I'd like to do something > >like > > > > (show-expansion (defstruct tree height girth age leaf-shape leaf-color)) > > > >and get what the expansion of this macro would produce: > > > > (begin > > (define make-tree > > (lambda fvfv > > [ ... and so on ... ] > > Use the trick from the inexplicable JRM's Syntax-rules Primer for > the Merely Eccentric[1], wrap the output with quote: > > ... > (let ((ff (map (lambda (f) (if (pair? f) (car f) f)) > ff))) > `'(begin > ; ^ > (define ,(string->symbol > (string-append "make-" s-s)) > ... Ah, sounds reasonable. Thanks! > [1] > http://www.xs4all.nl/~hipster/lib/scheme/gauche/define-syntax-primer.txt I will save this link for later, since this stuff is still too advanced for me. In the meantime, I'll be looking for something that's more entry-level...