The code blow generates compiler error "Error: ambiguous call; both test.test(f: float64) and test.test(f: float32) match for: (float)"
variable f is a 64 bit float in current nimrod implementation, so it would be obvious which test function to call in this case. Is the float type handled as an own type? Why is that, and why is it not just an alias for float64??
proc test(f:float64)=
echo "float64"
proc test(f:float32)=
echo "float32"
var f=1.234
test(1.234)
I think that float being aliased to 64 bits floats is just an implementation detail you should not depend on. float is just a different type as the following modification shows:
proc test(f:float64)=
echo "float64"
proc test(f:float32)=
echo "float32"
proc test(f:float)=
echo "float"
test(1.234)
test(1.234'f32)
test(1.234'f64)
You can use the borrow pragma to allow coercion for these procs.I think that float being aliased to 64 bits floats is just an implementation detail you should not depend on. float is just a different type
Yes, indeed. And float should become 32bits for ARM I think.
You can use the borrow pragma to allow coercion for these procs.
That's news to me.
Ok, so say I want to extend the math module with the faster Float32 versions of the common math functions. How do I do this without the compiler complaining about:
sin(3.1415)
Is the only way do create three overloads for every function, one for Float, one for Float32 and one for Float64?