[m-rev.] for review: document require_tail_recursion pragmas

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Jun 21 18:58:50 AEST 2026



On Wed, 10 Jun 2026 21:23:20 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> 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).

With the current compiler, we do not get a warning for this code,
unless the pragma is modified to add the "in_all_grades" option.
I expect that the warning you got was from an installed compiler
that did not include the diff I committed that added trailing to
the list of grade components that make a grade a non-tail-rec grade.

> 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.).

In that case, you won't get a warning even if add the in_all_grades option,
precisely because, as you say, the trail op is not in the HLDS, but is
added later.

This is such a niche difference that I don't think it would serve any useful
purpose to refer to it in the manual; I think any reference would be
much more likely to confuse than enlighten.

I am committing the attached updated diff, in which I addressed all your
previously raised points. There is no interdiff, because some parts of the diff
make sense only in view of context that the interdiff would omit.

I will address any issues raise post-commit. When we agree, I intend to add a note
announcing these pragmas to NEWS.md.

Zoltan.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.rtrd2
Type: application/octet-stream
Size: 19369 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20260621/7898e8b1/attachment-0001.obj>


More information about the reviews mailing list