-
Notifications
You must be signed in to change notification settings - Fork 16
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
DivideByZero exception has conflicting attributes #434
Comments
I'm on vacation, and can't yet give this full attention, but Raku's DBZ, successes, failures, DBZ exceptions, .... |
[please can you point to the source and I would be happy to try and grok the intent if I can] for a long time IEEE P754 has given us valid values for the results of DBZ following raiph's pointer to the docs on ZBRs, I see that this is OK: say <1/0>.Num; # OUTPUT: «Inf»
say <-1/0>.Num; # OUTPUT: «-Inf»
say <0/0>.Num; # OUTPUT: «NaN»
say Inf.Rat.nude; # OUTPUT: «(1 0)» yet this is an error: say <1/0>;
# Attempt to divide by zero when coercing Rational to Str in ... my guess on the error attributes is:
|
You can find all the instances (though you'll have to look at the source because many of these are part of a multi-line invocation) with
There is nothing in the current usage of rakudo or roast that requires There is no tie in to the CPU/FPU operations here. |
|
@coke thanks for clarifying my guess - looks like the info I guessed at is split between the Based on this, I see no issue in keeping the fields as they are since both the On the FPU, apologies if I did not explain myself carefully, but the situation I wanted to clarify (at least to my own satisfaction) is that where this is a thing:
And this (although you can't make a string from it):
Then, from a raku coder POV a valid mental model is that this is a divide by zero "non-failure" aka a ZBR that is made by creating a Inf (ie. by coercing a ZBR to an IEEE P754 Inf in the FPU since Num s are doubles) and then coercing it back to a Rat which as a construct of Ints lives in the CPU. And I can make the identical thing via an FPU overflow like this:
My point is that when you have done a bunch of P754 coding then it is most natural to think of Inf (aka the result of a DBZ op) as a creature of the FPU. This is the design of raku Num and the cool thing is the "interop" between Num and Rat - but also a source of potential complexity around DBZ behaviours. So, obviously this would work too:
.oO Realises that raku still supports DBZ exceptions in the FPU. Probably have to monkey with the compiler directives to put FPU in the "don't raise exception" mode atm. Would be nice to have that control on the same footing as eg It took me a while to realise that this Failure is from an FPU exception so maybe the |
While roast only seems to check the type of the exception, current rakudo has 3 attributes:
Checking where the exception is thrown by rakudo, it seems to either be a numerator/using pair, the single attribute details, or nothing. We should be consistent in usage and probably select
numerator
andusing
, removedetails
, and ensure that wherever we throw the exception, we include the information.Because there is no testing of these attributes in roast, we could do this as an implementation detail in existing rakudo, but I would recommend implementing it as a 6.e feature and then testing the attributes in roast for 6.e
The text was updated successfully, but these errors were encountered: