[m-rev.] for post-commit review: inst_var_sub_result
Peter Wang
novalazy at gmail.com
Fri Jul 5 14:06:44 AEST 2024
On Fri, 05 Jul 2024 13:49:45 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For review by anyone.
>
> Zoltan.
> Avoid overuse of higher order code.
>
> compiler/inst_match.m:
> Change how handle_inst_var_sub operates. Instead of taking as arguments
> two predicates to call as continuations, simply return a structure
> that tells its callers which of those two predicates to call, and
> with what arguments. The new arrangement has the advantage of
>
> - separating handle_inst_var_sub's task from its callers' tasks,
> - making the flow of control more visible and more easily understandable,
> - allowing direct tail recursion in a situation where the old code did
> tail recursion indirectly, through a higher-order call.
>
> The new arrangement does incur the cost of constructing a small cell
> on the heap, but this cost should be similar to, or even smaller than
> the cost of old arrangement's construction of closures.
That looks good.
Peter
More information about the reviews
mailing list