On Thu, Nov 23, 2006 at 07:16:17AM -0800, michael rice wrote:
> I stumbled upon that same problem when I first began
> looking at OCaml and discovered the same solution. But
> still, it seems weird that -5 is not an int without
> wrapping it in parens.
It's basically because there is an ambiguity between the expression:
i-5 # assuming i is an integer
and the function application:
f-5 # assuming f is a function
since at parse time we don't know the types (parsing happens long
before types are worked out). In other languages function application
has parentheses around the parameters so there is no such ambiguity.
There is also a unary negation symbol ~- (tilde minus) which you might
find useful:
# sign_int ~-5;;
- : sign = Negative
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!
.