News for hackers. Stuff that matters.
Re:Try OCaml by toolslive on Friday September 07, 2018 @06:44AM (#17933248)
(+) is an operator that takes 2 ints and produces an int

(+.) is the equivalent for floats: 1.0 +. 1.0

In short: if you need any operator for floats, and you know how to write it for ints, add a dot.

The reasoning is that it's hard to define the semantics of mixed expressions and explicit conversions clarify what needs to happen.

Re:Try OCaml by dpwm on Friday September 07, 2018 @07:10AM (#17933361)
I initially hated the separate operators for floats and integers.

I've since grown to like it, because the only times I've been caught out by it is when I've made a mistake or I've forgotten I was working with floats.

Don't let the syntax put you off Ocaml, because there is some reasoning behind it. It's a multi-paradigm language that has a lot of powerful features.

Re:Try OCaml by gpderetta on Friday September 07, 2018 @11:24AM (#17934967)
Not allowing mixed expressions is completely orthogonal to using the same symbols for float or integer (or bignum or fixed or...) addition.
Re:Try OCaml by zeroname on Friday September 07, 2018 @11:48AM (#17935218)
The non-obnoxious solution for that not-so-big problem is explicit conversions, not a whole new set of ugly multi-character operators.