From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: define-syntax
Date: Wed, 16 Jun 2010 00:06:10 +0200 [thread overview]
Message-ID: <m3bpbchrxp.fsf@pobox.com> (raw)
In-Reply-To: <87bpbcm381.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 15 Jun 2010 22:48:46 +0200")
Hi,
On Tue 15 Jun 2010 22:48, ludo@gnu.org (Ludovic Courtès) writes:
> From R6RS Section 10:
>
> define-syntax form The expander expands and evaluates the
> right-hand-side expression and binds the keyword to the resulting
> transformer.
>
> Thus I think the following should work:
>
An interesting issue, and an interesting example. The problem boils down
to eval-when.
$ cat > foo.scm
(define-syntax +
(let ((plus +)) ;; `+' should resolve to whatever `+' is bound to
;; before this definition
(lambda (stx)
(syntax-case stx ()
((_ args ...)
(apply plus (map syntax->datum #'(args ...))))))))
^D
$ guile -l foo.scm -c '(begin (display (+ 1 2 3)) (newline))'
6
Indeed + does resolve to whatever + was bound to before the definition;
it's just that when you define the + macro it usually defines at
compile-time too! By compiling ahead of time and exiting we leave + in
its pristine state. See also the discussion of
eval-syntax-expanders-when in psyntax.scm or in
http://www.scheme.com/csug8/system.html#./system:s78.
Cheers,
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2010-06-15 22:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 20:48 define-syntax Ludovic Courtès
2010-06-15 22:06 ` Andy Wingo [this message]
2010-06-15 22:38 ` define-syntax Ludovic Courtès
2010-06-16 7:35 ` define-syntax Marco Maggi
2010-06-18 8:39 ` define-syntax Andy Wingo
2010-06-18 14:41 ` define-syntax Marco Maggi
-- strict thread matches above, loose matches on Subject: below --
2008-12-09 16:51 define-syntax Pach Roman (DGS-EC/ESG3)
2008-12-09 20:20 ` define-syntax Neil Jerram
2008-12-09 20:52 ` AW: define-syntax Pach Roman (DGS-EC/ESG3)
2008-12-09 21:17 ` define-syntax Neil Jerram
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=m3bpbchrxp.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=ludo@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).