3 ms·
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 o
by theseoafs 12y ago
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).
- ufo 12y agoIn 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)
- jondubois 12y agoTry to add an int and a float32 using 'Try go' on http://glolang.org 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.