[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is it possible for a macro to expand to nothing?
From: |
Alan Mackenzie |
Subject: |
Re: Is it possible for a macro to expand to nothing? |
Date: |
Mon, 23 Nov 2009 20:09:34 +0000 (UTC) |
User-agent: |
tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386)) |
Hi, Drew!
Drew Adams <drew.adams@oracle.com> wrote:
>> I think I want to be able to do this:
>> (defun foo ()
>> (setq bar 1)
>> (ifdef baz (setq bar 2)))
>> , and if baz is nil at compile time, this function should be
>> identical to
>> (defun foo ()
>> (setq bar 1))
> (defmacro titi (fn)
> `(defun ,fn ()
> (setq bar 1)
> ,@(ifdef baz '((setq bar 2))))))
> Assuming that ifdef returns nil if baz is nil, that should give you
> (defun foo () (setq bar 1)). If baz is not nil, it should give you
> this:
> (defun foo ()
> (setq bar 1)
> (setq bar 2))
> Or something like that.
Wow, you're a genius, Drew! It's a little bit ugly having to write a
defmacro around a defun, but only a very very little.
The way you've described actually looks fairly obviousi now, but these
things always do after somebody bright has just shown you them.
Thanks again!
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Is it possible for a macro to expand to nothing?, (continued)
- Re: Is it possible for a macro to expand to nothing?, Pascal J. Bourguignon, 2009/11/24
- Message not available
- Re: Is it possible for a macro to expand to nothing?, Pascal J. Bourguignon, 2009/11/23
- RE: Is it possible for a macro to expand to nothing?, Drew Adams, 2009/11/23
- Message not available
- Re: Is it possible for a macro to expand to nothing?, Pascal J. Bourguignon, 2009/11/23
- RE: Is it possible for a macro to expand to nothing?, Drew Adams, 2009/11/23
- Message not available
- Re: Is it possible for a macro to expand to nothing?, Pascal J. Bourguignon, 2009/11/23
- Message not available
- Re: Is it possible for a macro to expand to nothing?,
Alan Mackenzie <=
Re: Is it possible for a macro to expand to nothing?, Jeff Clough, 2009/11/23