[m-rev.] for review: fix mantis bug #559, step 1

Julien Fischer jfischer at opturion.com
Wed May 4 13:45:39 AEST 2022


On Wed, 4 May 2022, Zoltan Somogyi wrote:

> This does not fix Mantis #559; it is just the first step
> towards the fix.
>
> For review and before-and-after benchmarking by Julien,
> since it is his bug, and he has server-class machines that have
> way less benchmark jitter than my laptop.

I have just set makebatch running for this.

> Restructure parse_goal to make tail recursion possible.
> 
> compiler/parse_goal.m:
>     The parse_goal predicate is basically an if-then-else. If the input term
>     has the form of a non-call goal, then parse it as such, using
>     the parse_non_call_goal predicate; otherwise, parse it as a call.
>
>     For historical reasons, we gave always parsed non-call goals in the

s/gave/have/


>     condition of the if-then-else. However, this requires parse_non_call_goal
>     to be semidet, and requires its call to be followed by the then-part
>     of the if-then-else. Both of those requirements prevent mutual tail
>     recursion between parse_goal and parse_non_call_goal in MLDS grades,
>     and the latter requirement prevents in the LLDS grades.

prevents *it*

>
>     Avoid both of these obstacles by splitting parse_non_call_goal in half.
>     The first half just recognises whether the input term represents
>     a non-call goal, and if so, which kind, while the second half
>     (which inherits the parse_non_call_goal name) actually parses it.
>     Since the new parse_non_call_goal predicate is (a) det and (b)
>     called in tail position in the else arm of the if-then-else,
>     this removes both of the above obstacles preventing mutual tail recursion.
>
>     This is not enough for the use case motivating this change, a very deep
>     disjunction Mantis bug #559, because the code of parse_goal_semicolon

*from* Mantis bug #559

The rest looks fine.

Julien.


More information about the reviews mailing list