Re: macro question
- From: "josephoswaldgg@xxxxxxxxxxx" <josephoswald@xxxxxxxxx>
- Date: 30 Sep 2005 10:05:37 -0700
Karol Skocik wrote:
> Hello,
> I need help with macro style. I sometimes need a macro which outputs
> some code, but depending on some variable, I need to add something to
> the output or nothing, to be more specific :
>
> I want in a macro to have in let section something like :
>
> `(let ((added-nodes (make-hash-table)))
> ....
>
> or, sometimes I need this :
> `(let ((added-nodes (make-hash-table))
> (undo-funcs '()))
Others have given you some specific answers. I have a general
suggestion.
Don't be afraid to create helper-functions in your macro functions.
I.e., if you have a tricky bit of list construction, put it in a
function like
(defmacro ...
(lables ((make-let-arg () (append ... (if make-undo ... ))))
`(let ,(make-let-arg) ...))
;; not debugged, but you hopefully get the idea.
where you can work on a separate definition of make-let-arg at the Lisp
prompt until you have all the bells and whistles working.
When working this way, be careful to have everything you need defined
at macro expansion time. Beware that your REPL experiments might not
work when loaded into a fresh Lisp image.
.
- References:
- macro question
- From: Karol Skocik
- macro question
- Prev by Date: Re: Beginner - Function Critique
- Next by Date: Re: macro question
- Previous by thread: Re: macro question
- Next by thread: Re: macro question
- Index(es):