Wanted: warning option for usages of unary minus

Simon Marlow simonmarhaskell at gmail.com
Mon May 21 05:33:56 EDT 2007


John Meacham wrote:
> On Mon, May 14, 2007 at 10:19:07AM +0100, Simon Marlow wrote:
>> Really?  I'm beginning to have second thoughts about the proposed change to 
>> negation for Haskell'.  The main reason, and this isn't pointed out as well 
>> as it should be on the wiki, is that "x-1" will cease to be an infix 
>> application of (-), it will parse as x applied to the literal (-1).  And 
>> this is different from "x - 1" (syntax in which whitespace matters should 
>> be avoided like the plague, IMO).  I think this would be worse than the 
>> current situation.
> 
> White space already matters when it comes to numbers quite a bit
> 
> 0 x 123 vs 0x123
> 1.5 vs 1 . 5
> 3e4 vs 3 e 4
> 
> etc.

Yes, I happen to think that whitespcae should only be significant where it 
separates two lexemes of the same category.  I'm prepared to make an exception 
for numbers, because the syntax of numbers is already so familiar to almost 
everyone.

I think that we could easily remove the '3e4' lexical syntax though, since 
'3*10^^4' works just as well (I often write the latter anyway) (and guess what, 
I just had to look up the difference between ^ and ^^, only to discover I picked 
the wrong one).  The '3e4' syntax is a common source of compiler bugs, becuase 
it is rarely used and hence rarely tested.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list