3 ms·
I wish Julia would be more strict wrt type coercion of integer to float values. I've once spent a day debugging the issue caused by the following line of code,
by ninesigns 8y ago
I wish Julia would be more strict wrt type coercion of integer to float values.
I've once spent a day debugging the issue caused by the following line of code, where t1, t2 are floats and v is an array:
d = (t2 - t1) * length(v)
It should've been LinearAlgebra.norm():Float instead of length():Int. Had julia been stricter the code would have failed to run, saving me much time.
- tkoolen 8y agoI actually can't think of a single language that doesn't allow you to multiply an integer and a floating point value, yielding a floating point result.
- ryl00 8y agoAda?
- the_duke 8y agoRust. In Rust, all type coercion must be explicit, you can't even add different integer types: 5i64 + 5i32 // WONT compile 5i64 + 5i32 as i64 // will work
- gmfawcett 8y agoOCaml has distinct multiplication operators for ints and floats. Haskell's multiplication operator requires its arguments to be of the same numeric type, and returns a product of the same type. That's two, off the top of my head...
- jjtheblunt 8y agoGo ?
- threatofrain 8y agoJavaScript? 23n + 5 causes a TypeError.