[m-rev.] for review: generalize the specialization of compare/3 predicates

Simon Taylor stayl at cs.mu.OZ.AU
Tue Feb 5 03:55:32 AEDT 2002


On 05-Feb-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 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.

The point I was trying to make was that you should be able to remove the
code above this diff fragment that handles the single constructor case,
and change the test in the diff fragment to `Ctors = [_ | _]'.

> > > +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?

It's not a big deal, but it makes HLDS dumps easier to read
if the order in the clauses_info matches the order in the
proc_info.

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