unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: guile-devel@gnu.org
Subject: Re: definitions in macros?
Date: Sun, 22 Mar 2020 12:16:46 -0700	[thread overview]
Message-ID: <7b0c63b6-bd75-2f3d-602e-0c8a5a631048@gmail.com> (raw)
In-Reply-To: <CAOw_e7bVfgmrMf-ZtjF4zJqESLS1Y6CbHNztxcvfiEYwX5PzwQ@mail.gmail.com>

On 3/22/20 12:07 PM, Han-Wen Nienhuys wrote:
> Hi there,
>
> in my quest to get lilypond working with GUILE 2+, I've hit another
> stumbling block.
>
> In order to make compilation with GUILE 2+ working, we have to move
> away from runtime symbol definition (ie. module-define! calls).
>
> 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"))
>
>
> (my-macro-old 1 2)
> (my-macro-new 1 2)
> (display x1)
> (display x2)
> (display q)
> (display p)
>
>
> thanks,
>

Try the following.  Not sure about defmacro but define-syntax must 
return a single form.

(defmacro-public my-macro-new (command-and-args . definition)
     `(begin
       (define p "i am P\n")
       (define q "i am Q\n")))

  






  reply	other threads:[~2020-03-22 19:16 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 [this message]
2020-03-22 21:09 ` David Kastrup
2020-03-23  7:21   ` Han-Wen Nienhuys

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=7b0c63b6-bd75-2f3d-602e-0c8a5a631048@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-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).