(New diff) Re: [m-rev.] Handle polymorphic inequality goals
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Oct 30 23:42:35 AEDT 2002
On 29-Oct-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
>
> Make the Prolog term comparison operators (@<, @=<, @>, @>=)
> builtin since they're often useful and calling compare/3
> can look a little awkward.
>
> Simplification now applies the following transformations on the
> new builtin operators:
>
> X @< Y ---> some [R] (compare(R, X, Y), R = (<))
> X @=< Y ---> some [R] (compare(R, X, Y), R \= (>))
> X @> Y ---> some [R] (compare(R, X, Y), R = (>))
> X @>= Y ---> some [R] (compare(R, X, Y), R \= (<))
(Ideally it would have been best to post these two -- the library change
and the optimization -- as two separate patches.)
A test case would be a good idea.
> compiler/goal_util.m:
> Added a new parameter, ModeNo, to goal_util__generate_simple_call.
> ModeNo is either
> - `only_mode' in which case the predicate in question is expected to
> have exactly one mode or
> - `mode_no(N)' in which case mode number N (counting from 0) is
> used.
> The inequality transformation uses this to handle calls to compare/3
> with unique arguments (even though the builtin inequality modes don't
> yet handle ui arguments...)
Hmm...
> Index: NEWS
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/NEWS,v
> retrieving revision 1.274
> diff -u -r1.274 NEWS
> --- NEWS 22 Oct 2002 13:10:33 -0000 1.274
> +++ NEWS 28 Oct 2002 05:07:28 -0000
> @@ -12,6 +12,7 @@
> * Support for defining predicates or functions
> using different clauses for different modes.
> * Support for Haskell-like "@" expressions.
> +* Prolog-style term comparison operators, @<, @=<, @>, @>=, are now builtin.
That should go in the "library" changes section, IMHO.
> Index: compiler/simplify.m
...
> + "replacment of inequality with call to compare/3"),
> + []),
s/replacment/replacement/
Otherwise that looks fine.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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