[m-rev.] for review: generalize the specialization of compare/3 predicates
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Feb 5 03:29:52 AEDT 2002
On 05-Feb-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > @@ -1069,52 +1063,32 @@
> > Ctor, Res, H1, H2,
> > Context, Clauses)
> > ;
> > - unify_proc__generate_du_general_compare_clauses(Type,
> > + unify_proc__generate_du_linear_compare_clauses(Type,
> > Ctors, Res, H1, H2, Context, Clauses)
> >
> > ;
> > - { Ctors = [Ctor1, Ctor2] },
> > + { Ctors = [_, _ | _] },
>
> Can't you remove the special case handling of the single
> constructor case as well?
Yes, but that case is already handled by code above this diff.
> > { globals__lookup_int_option(Globals, compare_specialization,
> > CompareSpec) },
> > - ( { CompareSpec >= 2 } ->
> > - unify_proc__generate_du_two_compare_clauses(
> > - Ctor1, Ctor2, Res, H1, H2,
> > - Context, Clauses)
> > - ;
> > - unify_proc__generate_du_general_compare_clauses(Type,
> > + { list__length(Ctors, NumCtors) },
> > + ( { CompareSpec >= NumCtors } ->
> > + unify_proc__generate_du_quad_compare_clauses(
> > Ctors, Res, H1, H2, Context, Clauses)
>
> The comparison would be slightly easier to read with the constant
> (CompareSpec) on the right.
OK, I will flip them around.
> I'd also suggest not abbreviating "quadratic".
The predicates names are already very long.
> > +unify_proc__generate_du_quad_compare_clauses_2(_LeftCtor,
> > + [], _Cmp, _R, _X, _Y, _Context, Cases, Cases) --> [].
> > +unify_proc__generate_du_quad_compare_clauses_2(LeftCtor,
> > + [RightCtor | RightCtors], Cmp0, R, X, Y, Context,
> > + Cases0, Cases) -->
> > + ( { LeftCtor = RightCtor } ->
> > + unify_proc__generate_compare_case(LeftCtor, R, X, Y, Context,
> > + Case),
> > + { Cmp1 = "<" }
> > + ;
> > + unify_proc__generate_asymmetric_compare_case(LeftCtor,
> > + RightCtor, Cmp0, R, X, Y, Context, Case),
> > + { Cmp1 = Cmp0 }
> > + ),
> > + unify_proc__generate_du_quad_compare_clauses_2(LeftCtor, RightCtors,
> > + Cmp1, R, X, Y, Context, [Case | Cases0], Cases).
>
> It might be slightly better to reverse the list of cases so
> they are in sorted order.
The order will disappear anyway at switch detection time.
Are you concerned about how the code appears before then?
Zoltan.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list