[m-rev.] for review: document require_tail_recursion pragmas
Zoltan Somogyi
zoltan.somogyi at runbox.com
Wed Jun 24 02:57:23 AEST 2026
On Wed, 10 Jun 2026 21:23:20 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> > And I will need to modify mark_tail_calls.m to actually generate the warnings
> > for seemingly-but-not-really tail recursive calls that the manual says it should
> > generate. At the moment, for invisible code added by a code generator, it does not.
> >
> > > although I'd need to think
> > > about the interaction between the two in more detail.
> >
> > When you have a conclusion, yea or nay, please tell me.
>
> Trailing inhibits tail recursion in certain (fortunately rare) circumstances.
> Specifically, when we add trail ops. to a model_det or model_semi
> disjunction, we add some trail ops. after each disjunct goal in order to
> handle the commit.
>
> The attached test case is a contrived example of this. In non-trailing
> MLDS grades it is tail-recursive, but in trailing MLDS grades it is not
> tail recursive (and we get a warning because of the pragma).
Thanks for that.
> I'm not sure what the situation with the LLDS backend is. (It adds
> trail ops. directly in the code generator, as opposed to using
> add_trail_ops.).
It must generate the same trail ops in the same circumstances as
the MLDS backend, or LLDS trailing grades would not work.
I came up with a design that identifies non-tail-recursive calls
in the presence of trailing for both backends. Its implementation
is attached, for your review.
Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.tr
Type: application/octet-stream
Size: 2506 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20260624/043efd9e/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.tr
Type: application/octet-stream
Size: 46800 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20260624/043efd9e/attachment-0003.obj>
More information about the reviews
mailing list