-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
[RFC 58] Add partial arithmetic for integer types #2865
Conversation
as it mapped +? to partial add, not to add_partial so in this respect, a class could not have both methods, but the integer typed need to have.
I added a Division test to make sure division by zero is zero and that
I think this should be handled as a separate issue. |
I'd suggest to stick to the scope of the original RFC for the purposes of this PR, and leave out both of these extensions. These be handled in a separate RFC.
Agreed. In a separate issue, we can make sure this result is deterministic across platforms, and if someone wants the faster, nondeterministic behaviour, they can use |
Thanks @jemc yeah, i will stick the failing division test into the new issue and remove it here. This RFCs feature is working fine it seems. |
this one should be included in another PR fixing the underlying issue with detecting overflow on division for I128 on platforms without native 128 bit int support
I removed the division test and will stick this PR to the RFC scope and at some point create a new RFC to extend the partial arithmetic both in terms of functions and in terms of scope (to include floating point). |
(x/~y, x %~ y) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few style issues in this file - everywhere where you have two blank lines, it should be one blank line. See https://github.com/ponylang/ponyc/blob/master/STYLE_GUIDE.md#blank-lines
One minor drawback that this implementation contains is that previously, when implementing custom operator functions, say |
Was the "how we teach this" from the RFC merged? I don't see anything re: "The tutorial should introduce the different ways of doing arithmetic in greater detail, checked (addc etc.), unchecked (add etc.). unsafe ( add_unsafe etc.) and partial (add_partial). So that users know what options they have and what the drawbacks might be (e.g. performance against correctness)." We need to get that in for the RFC to be considered closed. As it is, the RFC isn't finished. |
Also, this wasn't noted in Last Week in Pony. |
@mfelsche can you add release notes for this? |
The tutorial still needs to be updated. I am working on this in the little sparetime i have. ETA is t + 3-5 days. This wasnt noted on lwip as it is not done yet, as you correctly stated. |
@mfelsche can you add release notes for this? |
Release Notes DraftWith this RFC Pony finally adds the means to do partial arithmetic on integers. It introduces a new set of operators: |
This PR adds partial arithmetic functions and operators to all integer types.
Normal classes can also provide partial arithmetic operators, like
+?
,-?
,*?
, etc. by implementingadd_partial
,sub_partial
,mul_partial
etc. the same way the normal operators work on classes.I limited this PR to
+?
,-?
,*?
,/?
and%?
.Two question arised during implementation:
NaN
orInf
or-Inf
would be returned?shl_partial
,shr_partial
andneg_partial
too? As part of this PR?Closes #2814