all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: defmacro* usage
Date: Wed, 02 Nov 2011 09:04:07 -0400	[thread overview]
Message-ID: <jwvd3dahe5u.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ipn2rcer.fsf@gmail.com> (Thierry Volpiatto's message of "Wed,  02 Nov 2011 12:28:44 +0100")

> I have an error with following recipe:

> #+BEGIN_SRC lisp
> (defmacro* test1 (&key (lang 'french))
>   `(case ,lang
>      (french (message "Bonjour"))
>      (english (message "Hello"))))
[...]
> As you can see, the quoted default argument 'french cause an error with
> the defmacro* and work fine with the defun*.

The error is not from defmacro* but from the code you generated using defmacro*.

> Is it a bug or i misunderstand something?

A misunderstanding.  Think harder about what your macro does.  E.g. try
(macroexpand '(test1 :lang 'toto)) and (macroexpand '(test1)).
During macroexpansion, your `lang' is not supposed to hold a "language
value" but "a Lisp expression that will evaluate to a language value".


        Stefan



  parent reply	other threads:[~2011-11-02 13:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 11:28 defmacro* usage Thierry Volpiatto
2011-11-02 13:02 ` Andreas Schwab
2011-11-02 13:04 ` Stefan Monnier [this message]
2011-11-02 13:15   ` Thierry Volpiatto

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd3dahe5u.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=thierry.volpiatto@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.