help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Is it possible for a macro to expand to nothing?


From: Drew Adams
Subject: RE: Is it possible for a macro to expand to nothing?
Date: Mon, 23 Nov 2009 09:29:45 -0800

> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]