[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: definitions in macros?
From: |
Han-Wen Nienhuys |
Subject: |
Re: definitions in macros? |
Date: |
Mon, 23 Mar 2020 08:21:12 +0100 |
On Sun, Mar 22, 2020 at 10:09 PM David Kastrup <address@hidden> 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 - address@hidden - http://www.xs4all.nl/~hanwen