-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime crash with "Numeric" #2583
Comments
The plan is to support operator overloading to implement 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 |
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: