unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Josef Wolf <jw@raven.inka.de>
To: guile-user@gnu.org
Subject: Re: Need help to understand a macro
Date: Mon, 22 Mar 2010 22:06:07 +0100	[thread overview]
Message-ID: <20100322210606.GG31143@raven.wolf.lan> (raw)
In-Reply-To: <4BA4D819.6020508@ludens.elte.hu>

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...




      reply	other threads:[~2010-03-22 21:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19  8:57 Need help to understand a macro Josef Wolf
2010-03-19 12:54 ` Ken Raeburn
2010-03-22 19:25   ` Josef Wolf
2010-03-22 20:16     ` Andy Wingo
2010-03-22 20:54       ` Josef Wolf
2010-03-19 14:28 ` Andy Wingo
2010-03-19 16:15   ` Andreas Rottmann
2010-03-22 19:55     ` Josef Wolf
2010-03-22 21:50       ` Andreas Rottmann
2010-03-22 19:50   ` Josef Wolf
2010-03-22 20:36     ` Andy Wingo
2010-03-22 21:01       ` Josef Wolf
2010-03-23  0:50         ` Neil Jerram
2010-03-20 14:13 ` szgyg
2010-03-22 21:06   ` Josef Wolf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100322210606.GG31143@raven.wolf.lan \
    --to=jw@raven.inka.de \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).