From: Han-Wen Nienhuys <hanwenn@gmail.com>
To: David Kastrup <dak@gnu.org>
Cc: lilypond-devel <lilypond-devel@gnu.org>,
Guile Devel <guile-devel@gnu.org>
Subject: Re: definitions in macros?
Date: Mon, 23 Mar 2020 08:21:12 +0100 [thread overview]
Message-ID: <CAOw_e7aZM1rBjwpEnow+jhVD4f4Rn8VTiNrrdLV6jzKM28g4jA@mail.gmail.com> (raw)
In-Reply-To: <87v9mw9jwa.fsf@fencepost.gnu.org>
On Sun, Mar 22, 2020 at 10:09 PM David Kastrup <dak@gnu.org> wrote:
> > In the code below, it looks like only one of the two definitions in
> > the body of my-macro-new takes effect. Is this expected, and if so,
> > why?
> >
> > (defmacro-public my-macro-old (command-and-args . definition)
> > (module-define! (current-module) 'x1 "I am X1\n")
> > (module-define! (current-module) 'x2 "I am X2\n"))
> >
> > (defmacro-public my-macro-new (command-and-args . definition)
> > `(define p "i am P\n")
> > `(define q "i am Q\n"))
>
> This is very much expected. The macro body contains two side-effect
> free expressions (namely quoted lists) and returns the last one which is
..
> You probably wanted something like
> `(begin (define p ...) (define q ...))
d'oh! I am an idiot.
Thanks,
--
Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen
prev parent reply other threads:[~2020-03-23 7:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 19:07 definitions in macros? Han-Wen Nienhuys
2020-03-22 19:16 ` Matt Wette
2020-03-22 21:09 ` David Kastrup
2020-03-23 7:21 ` Han-Wen Nienhuys [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=CAOw_e7aZM1rBjwpEnow+jhVD4f4Rn8VTiNrrdLV6jzKM28g4jA@mail.gmail.com \
--to=hanwenn@gmail.com \
--cc=dak@gnu.org \
--cc=guile-devel@gnu.org \
--cc=lilypond-devel@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).