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

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

Re: Compiling a recursive macro


From: Douglas Lewan
Subject: Re: Compiling a recursive macro
Date: Thu, 11 Jun 2020 17:23:27 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 6/11/20 4:57 PM, Stefan Monnier wrote:
That suggests to me that you can't compile any recursive macro.
Depends what you mean by "recursive macro".
What this prevents is to use a macro inside the definition of a macro.

Most cases of "recursive macros" instead just returns code which
itself uses that macro.  In that case, there's no real recursion: the
macro just returns a list which happens to include a symbol which has
the same name as the macro.  And then the macro-expander will end up
calling that macro back when it gets to macro-expanding that chunk
of code.
This works just fine (and may inf-loop, of course).

It did work when not compiled. However, when compiling I got a max-depth-exceeded error. (Forgive the paraphrasing, I'm now running a new instance of emacs.

And, if anyone cares, I did find a work-around for the macro in question. It had the following structure:

(defmacro mmm ()
    (cond ((at-root-p)
           do  tree-wide stuff)
          (t
           (with-current-buffer root (mmm)))

Since there is never more than one level of recursion, I defined another macro to do the tree-wide stuff first and then call that from mmm.


--
,Doug
d.lewan2000@gmail.com
(908) 720 7908

If this is what winning looks like, I'd hate to see what losing is.



reply via email to

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