[m-users.] Tail recursion optimisation

Volker Wysk post at volker-wysk.de
Mon May 18 15:56:22 AEST 2026


Am Montag, dem 18.05.2026 um 15:32 +1000 schrieb Julien Fischer:
> On Mon, 18 May 2026 at 00:15, Volker Wysk <post at volker-wysk.de> wrote:
> > 
> > 
> > I have two mutually recursive predicates, which really need the tail
> > recursion optimisation. Does this recursion also happen when there are
> > two
> > or more predicates involved? They both are clearly tail recursive,
> > calling
> > each other.
> 
> Yes, if the predicates in question are mutually tail recursive and are
> all defined
> in the same module.  (If they are defined in different modules, then
> it will depend
> on what cross module inlining takes place.)

Okay, thank you. It's the same module. My program (which I can't compile
yet) wouldn't work without the tail recursion optimisation. The stack would
grow unbounded.

Cheers,
Volker


More information about the users mailing list