
Måndag 8. februar 2010 17.59.59 skreiv Ross Paterson:
But I agree they should all be legal, i.e. that unary minus should bind more tightly than any infix operator (as in C).
I second this, at least in general. However, one issue is function application. Should unary minus bind tighter than it or not and are there special cases (spaces)? Consider: 1) foo-1 2) foo -1 3) foo - 1 If unary minus binds tighter than application then we get `foo (-1)` in all cases. The other way around we get `(foo) - (1)` in all cases. To me the most natural parsing would be 1) (foo) - (1) 2) foo (-1) 3) (foo) - (1) Then there's also the issue of literals: 4) 1-1 5) 1 -1 6) 1 - 1 To me, all of these should parse as `(1) - (1)`. I'm a fan of treating literals and variables the same though (referential transparancy even in parsing), and that makes this problematic. Personally I'd like to just get rid of unary minus altogether and use some other symbol, like _, to represent negation, but doing that would probably break most programs out there. -- Sjur Gjøstein Karevoll