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

Simon Taylor stayl at cs.mu.OZ.AU
Tue Feb 5 17:19:58 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:
> > Why can't it be optimized away by
> > unify_proc__generate_du_quad_compare_clauses?
> 
> There needs to be something that tests whether the number of alternatives
> is zero (which is an error), one (generate just one clause), or more (generate
> several clauses in a disjunction).

 unify_proc__generate_du_quad_compare_clauses(Ctors, R, X, Y, Context,
		Clauses) -->
	unify_proc__generate_du_quad_compare_clauses_1(Ctors, Ctors, R, X, Y,
		Context, [], Cases),
	{ goal_info_init(GoalInfo0) },
	{ goal_info_set_context(GoalInfo0, Context, GoalInfo) },
-	{ map__init(Empty) },
-	{ Goal = disj(Cases, Empty) - GoalInfo },
+	{ disj_list_to_goal(Cases, GoalInfo, Goal) },
        unify_proc__quantify_clauses_body(HeadVars, Goal, Context, Clauses).
 
> The code in my diff reflects this directly. Lumping the "one" and "more"
> cases together, only to distinguish lthem later by an optimization that
> removes the redundant disjunction from the "one" case, seems too roundabout
> for my taste.

The "one" and "more" cases aren't significantly different. Having
duplicated code to handle the single constructor case suggests to
future readers of the code that they are.

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