Re: macro question



"Karol Skocik" <Karol.Skocik@xxxxxxxxx> writes:
> I just can't use ,(when make-undo `(undo-funcs '())) because it leaves
> nil in the list when the condition is not true.

,@(when make-undo `((undo-funcs '())))

> How do you usually solve situations like this?
> Or did I miss something in basic macro writing rules?

This has nothing to do with macros, all with building lists. You don't
need to use backquote/comma to build lists (but it's convenient at
times). You could write:

(let ((make-undo (oddp (random 2))))
(print (list 'let (append (list (list 'x 1))
(when make-undo
(list (list 'undo-funcs '())))))))

or:

(let ((make-undo (oddp (random 2))))
(print `(let ((x 1)
,@(when make-undo
`((undo-funcs '())))))))


--
__Pascal Bourguignon__ http://www.informatimago.com/

Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
.


Quantcast