[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SYNTAX ONLY - Precedence of prefix minus
Original-Via: uk.ac.ukc; Fri, 15 Mar 91 16:40:42 GMT
From: Kent Karlsson <kent@se.chalmers.cs>
Date: Fri, 15 Mar 91 17:30:33 +0100
To: haskell@cs.glasgow.ac.uk
Subject: Re: SYNTAX ONLY - Precedence of prefix minus
Original-Sender: kent%se.chalmers.cs@mcsun.eu.net
Sender: haskell-request@cs.glasgow.ac.uk
Lex Augusteijn writes:
> it was suggested that -2^2 should be equivalent to 0-2^2, which
> would be parsed as (0-2)^2.
No, parsed as 0-(2^2), '-' has lower precedence than '^'.
> interpretation' of -x whould alsways be 0-x.
>
> May I conclude from this, that the mathematical interpreation of
> 2*-3 is 2*0-3, which will be parsed as (2*0)-3?
> Hopefully not.
According to my proposal 2 * -3 is a syntax error, you must write 2*(-3).
But 2 >= -3 is ok, and parsed as 2 >= (-3), or if you like 2 >= 0-3, i.e. 2 >= (0-3).
And *- is one infix operator really, initially undefined, but you may define it
if you like: a *- b = a * (-b) (I'm ignoring the disallowance of the
character '-' in arbitrary operators, this disallowance is a lexical problem
source... Why should *- be read as * -, while *+ is not split up?)
This was my last(?) word on this subject :-)
/kent k