From: Tobias Brandt <tob.brandt@googlemail.com>
To: guile-user@gnu.org
Subject: Mixing syntax-rule and indentifier-syntax
Date: Tue, 17 Jan 2012 00:11:49 +0100 [thread overview]
Message-ID: <CAOOWqiq40E7xnxs=KJepv2Yjx5-WPOp61yXijkQo7pg7Jyv2dg@mail.gmail.com> (raw)
Hi,
is it possible to define a macro that does one thing when
it's in operator position and another when it's not?
I want to define a macro `with-vectors` that transforms this:
(with-vectors (v)
(v 0)
(set! (v 0) 'foo)
(some-procedure v))
into this:
(begin
(vector-ref v 0)
(vector-set! v 0 'foo)
(some-procedure v))
So far I have this:
(define-syntax with-vectors
(syntax-rules ()
((_ (id ...) exp ...)
(let-syntax ((id* (syntax-rules ()
((_ idx) (vector-ref id idx)))) ...)
exp ...))))
But that obviously only works for the first case: (v 0).
Regards,
Tobias
next reply other threads:[~2012-01-16 23:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-16 23:11 Tobias Brandt [this message]
2012-01-17 9:22 ` Mixing syntax-rule and indentifier-syntax Andy Wingo
2012-01-17 21:53 ` Ian Price
2012-01-17 23:26 ` Tobias Brandt
2012-01-18 16:23 ` Andy Wingo
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='CAOOWqiq40E7xnxs=KJepv2Yjx5-WPOp61yXijkQo7pg7Jyv2dg@mail.gmail.com' \
--to=tob.brandt@googlemail.com \
--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).