[m-dev.] Precedence of (,), (<=) and (=>) (...again)

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Sep 22 18:55:31 AEST 2004


To me your suggestion does seem more intuitive.

However couldn't this cause existing code to break?  I mean the  
compiler we can fix ourselves, but what about other projects?  My main  
worry is that it causes things to silently do the wrong thing.  For  
example if I have a test:

if (a(X) => b(X), c(X)) then ...

then the behaviour will change without any warnings or errors.

Ian.

On 22 Sep 2004, at 18:33, Ralph Becket wrote:

> I've just been bitten for the nth time by the fact that (=>) binds more
> strongly than conjunction.  A goal like this will lead to (fairly
> unhelpful) compiler errors complaining about binding variables in a
> negated context:
>
> 	all [X] (
> 		p(X)
> 	=>
> 		q(X),
> 		r(X)
> 	)
>
> The problem arises because this is parsed as
>
> 	all [X] (
> 		( p(X) => q(X) ),
> 		r(X)
> 	)
>
> I recall asking that we change the priority of (=>) and (<=) to 1010
> (i.e. *above* (,) which has priority 1000) years ago and nobody was
> interested.
>
> Another point in this proposal's favour is that multiple type class
> constraints would no longer have to appear in parentheses.  That is, at
> present we have to write
>
> 	:- pred p(T) <= (foo(T), bar(T)).
>
> whereas with the changed precedence this would become
>
> 	:- pred p(T) <= foo(T), bar(T).
>
> Any takers?
> -- Ralph
> ----------------------------------------------------------------------- 
> ---
> mercury-developers mailing list
> Post messages to:       mercury-developers at cs.mu.oz.au
> Administrative Queries: owner-mercury-developers at cs.mu.oz.au
> Subscriptions:          mercury-developers-request at cs.mu.oz.au
> ----------------------------------------------------------------------- 
> ---
>

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list