Re:Everyday hassles in Go
by theseoafs on Tuesday December 30, 2014 @01:36PM
(#8815918)
Have you never used a statically-typed language? Most statically typed languages can handle adding an integer and a float together. The only one I can think of that isn't capable of that is OCaml, though this is probably a strength of OCaml rather than a weakness (int-to-float casting can be a common source of bugs if it happens unexpectedly).
[ Parent
| on HN ]
Try to add an int and a float32 using 'Try go' on http://glolang.org - I get this error:
prog.go:13: invalid operation: x + y (mismatched types int and float32) [process exited with non-zero status]
I'd have to cast one of the variables to get it to work. Casting is unnatural - Maybe it's not so bad in this case, but in many cases it isn't desirable.
In Ocaml's case its less about casting being a source of bugs and more about casting not playing well with Hindley-Milner type inference, which is Ocaml's "killer feature". (and Ocaml doesn't have type classes to solve this problem like Haskell does)