On 02.12.2015 19:59, Stanislav Artemkin wrote:
Hi all,

I've just stumbled upon yet another question about unary negation parsing (http://stackoverflow.com/questions/34044873/passing-negative-integer-to-a-function-in-ocaml):

let f x = x + 1 in
f -1

is not valid in OCaml.

I'm just wondering why this issue is still not addressed in the parser? For example, F# parses "f -1" as unary negation, but "f - 1" and "f-1" as binary operator. It looks a bit tricky (as whitespace is taken into account), but feels so natural when writing code.

Is there any reason we can't have the same in OCaml?

PS. I understand that it may break existing code, but it should be solvable by a compiler option similar to -safe-string etc.

I think this is a non-issue, and it is easily explained to every beginner. And you say yourself: ... tricky .. whitespace ... may break existing code ...

/Str.