You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this simple case it could be detected by the compiler but in the general case it should be handled somehow. If it crashes or throws a runtime exception it means the Numeric type is useless and dangerous.
The text was updated successfully, but these errors were encountered:
The plan is to support operator overloading to implement Int + Float and others, in order to get the desired behavior at an acceptable performance level.
Until then, I recommend not using explicitly the Numeric static type if you don't need it, the Numeric limitations should not affect the direct use of Float and Int. You probably already noticed, in the given example simply removing the two :Numeric types will result in the expected static error to be displayed. But if you do need to use Numeric, use it with the Numeric-safe (but slower) methods add, sub, etc.
On Wed, Nov 22, 2017 at 02:36:09PM +0000, Alexis Laferrière wrote:
The plan is to support operator overloading to implement `Int + Float` and others, in order to get the desired behavior at an acceptable performance level.
just curious - is it similar like in Ruby where ```2+3``` is syntactic sugar for ```2.+(3)``` (integer.methodcall+(arg))? In that case I would think it could be easily "redefined" by the programmer as needed? I was also thinking on complex numbers and whatever else might become useful at some point.
Until then, I recommend not using explicitly the Numeric static type if you don't need it, the Numeric limitations should not affect the direct use of Float and Int. You probably already noticed, in the given example simply removing the two `:Numeric` types will result in the expected static error to be displayed. But if you do need to use Numeric, use it with the Numeric-safe (but slower) methods `add`, `sub`, etc.
thanks for the hint, never knew about the numeric-safe variants.
In this simple case it could be detected by the compiler but in the general case it should be handled somehow. If it crashes or throws a runtime exception it means the Numeric type is useless and dangerous.
The text was updated successfully, but these errors were encountered: