From: Mark H Weaver <mhw@netris.org>
To: Matt Wette <mwette@alumni.caltech.edu>
Cc: guile-user@gnu.org
Subject: Re: a Q on syntax-rules vs syntax-case
Date: Sun, 08 Feb 2015 20:48:30 -0500 [thread overview]
Message-ID: <87386fua6p.fsf@netris.org> (raw)
In-Reply-To: <E785699C-CF62-4780-A29F-E8EC97B7CFD4@alumni.caltech.edu> (Matt Wette's message of "Thu, 05 Feb 2015 11:44:13 -0800")
Hi Matt,
Matt Wette <mwette@alumni.caltech.edu> writes:
> I want to use macros inside a let which is part of an expansion of a
> top-level macro in order to have local bindings visible to macros.
Okay, that's fine.
> Is there a difference in implementation (e.g., when inside macros get
> expanded) between using syntax-rules versus syntax-case at the top
> level.
No. 'syntax-rules' is actually just a normal macro that expands into an
equivalent 'syntax-case' form. Guile's implementation is made more
complex by the presence of features such as docstrings, procedure
metadata, custom ellipses, and R7RS 'syntax-error' support, but if you
strip away those extra features, it looks like this:
(define-syntax syntax-rules
(lambda (form)
(syntax-case form ()
((_ (k ...) ((keyword . pattern) template) ...)
#'(lambda (x)
(syntax-case x (k ...)
((dummy . pattern) #'template)
...))))))
> Is this coding considered OK?
Yes, absolutely. It's fully supported.
Happy hacking!
Mark
next prev parent reply other threads:[~2015-02-09 1:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 19:44 a Q on syntax-rules vs syntax-case Matt Wette
2015-02-09 1:48 ` Mark H Weaver [this message]
2015-02-09 2:36 ` Matt Wette
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=87386fua6p.fsf@netris.org \
--to=mhw@netris.org \
--cc=guile-user@gnu.org \
--cc=mwette@alumni.caltech.edu \
/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).