unary "-" operator

Patryk Zadarnowski patrykz at cse.unsw.edu.au
Thu Feb 2 18:14:31 EST 2006


On 03/02/2006, at 10:03 AM, Ian Lynagh wrote:

> On Fri, Feb 03, 2006 at 09:54:59AM +1100, Patryk Zadarnowski wrote:
>> Yes, it *would* mean that (-x) and (- 1) are sections while (-1)
>> isn't, and
>> yes, that would be slightly confusing (and a good compiler might  
>> want to
>> issue a warning whenever it sees a construct of the form (- 
>> identifier).
>
> I'd much prefer it gave a warning for (-1) as, with -1 being a single
> lexeme, parentheses would never be needed.

Before we start another debate on warnings (which I would REALLY
prefer to keep out of my already-swamped mailbox!) this really isn't
an issue for the language design, but rather compiler implementation
(and therefore out of scope of this mailing list.) The right thing would
probably be warn about any instance of code that breaks between
H98 and H' for now, and once the change becomes mainstream,
change the compilers to generate whatever warnings turn out to
be more useful.

Either way, my point is that detecting these is a trivial lexical  
matter,
while detecting (.) inconsistencies isn't. And I would NOT like to see
(.) as the composition operator go - I use it in pretty much every piece
of Haskell code I have ever written!

>> In both cases, accidentally omitting a space will result in a
>> compiler or type error
>> anyway, since (-x) has a different type than (- x), so such accidents
>
> Do you mean (-1) and (- 1) here?

Both.

	Pat.



More information about the Haskell-prime mailing list