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
prints NaN which was a little surprising to me -- I wouldn't have expected a conversion to a double in such a case. What we've done in softdevteam/yksom#57 is to throw an error in such cases. Admittedly, on reflection, both the NaN and "thrown an error" behaviour are defensible, though I suspect the latter catches more genuine programmer errors. Maybe something to think about for the SOM spec!
The text was updated successfully, but these errors were encountered:
Smalltalks classically try to move between numerical representations for such things.
I am not sure I like that. One problem is that it violates the typing dimension, and makes it value dependent. This leads to surprising results.
---> 4 sqrt
it = 2
---> 4 sqrt class
it = Integer
---> 4.0 sqrt class
it = Double
---> 1 sqrt class
it = Integer
---> 3 sqrt class
it = Double
---> 10 sqrt class
it = Double
---> -1 sqrt class
it = Double
The above behavior (note the 4, 1, and 3 case), is consistent with Pharo. Except for -1 raising an exception.
So, the conversion to a Double and NaN isn't surprising to me and seem consistent with the other behaviors.
Though, I agree that an error as in yksom or Pharo is likely the better result.
I did see the PR earlier, but didn't have an opinion on it before.
Is yksom consistent with sqrt results for 4, 1, and 3?
This program:
prints
NaN
which was a little surprising to me -- I wouldn't have expected a conversion to a double in such a case. What we've done in softdevteam/yksom#57 is to throw an error in such cases. Admittedly, on reflection, both theNaN
and "thrown an error" behaviour are defensible, though I suspect the latter catches more genuine programmer errors. Maybe something to think about for the SOM spec!The text was updated successfully, but these errors were encountered: