From: Marco Maggi <marco.maggi-ipsu@poste.it>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: define-syntax
Date: Wed, 16 Jun 2010 09:35:25 +0200 [thread overview]
Message-ID: <87631jqvk2.fsf@rapitore.luna> (raw)
In-Reply-To: marco@localhost Jun 2010 22:48:46 +0200")
"Ludovic Courtès" wrote:
> (define-syntax +
> (let ((plus +))
I am assuming you are starting the program with:
(import (rnrs))
or you are importing at level 1 a library which exports "+";
if this is the case, and you want R6RS compatibility, IMHO
this should fail because you are redefining the binding for
"+"; many R6RS implementations agree with this (with the
exception of Ypsilon which has hygiene problems and must not
be taken as model).
Notice that bindings from "(rnrs)" are imported at both
levels 0 and 1[1]:
For the libraries defined in the library report, the
export level is 0 for nearly all bindings. The
exceptions are syntax-rules, identifier-syntax, ..., and
_ from the (rnrs base (6)) library, which are exported
with level 1, set! from the (rnrs base (6)) library,
which is exported with levels 0 and 1, and all bindings
from the composite (rnrs (6)) library (see library
chapter on “Composite library”), which are exported with
levels 0 and 1.
As a side note: the existence of the binding for the
keyword can be recorded by SYNTAX in the right-hand side of
a DEFINE-SYNTAX, so that the binding itself is can be used
to refer to the context of the definition:
(import (rnrs))
(define ciao 123)
(define-syntax this
(lambda (stx)
(syntax-case stx ()
((_)
(datum->syntax #'this 'ciao)))))
(write (this))
(newline)
and also:
(import (rnrs))
(define ciao 123)
(define-syntax this
(let ((ctx #'this))
(lambda (stx)
(syntax-case stx ()
((_)
(datum->syntax ctx 'ciao))))))
(write (this))
(newline)
for this kind of things, I suggest taking the behaviour of
Larceny as model: if it works with it, it will probably work
with all the other R6RS implementations.
HTH
[1] <http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-10.html#node_sec_7.2>
--
Marco Maggi
next prev parent reply other threads:[~2010-06-16 7:35 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 ` define-syntax Andy Wingo
2010-06-15 22:38 ` define-syntax Ludovic Courtès
2010-06-16 7:35 ` Marco Maggi [this message]
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=87631jqvk2.fsf@rapitore.luna \
--to=marco.maggi-ipsu@poste.it \
--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).