-
Notifications
You must be signed in to change notification settings - Fork 21
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
Unsigned right shift operator #1012
Comments
I wouldn't be opposed to this in theory. @dsyme? |
TBH I can barely imagine a situation where someone would want generic math over the logical-shift-right-operator on signed types. I'd imagine C# are just completing a matrix as part of their generic math work. In any case we should wait for C# to do whatever they do, since among other things they will choose an |
Noting that the C# name
This will make porting code C# --> F# (if uses unsigned right shift) or F# --> C# (if uses right shift on signed integers) a bit unreliable. In any case, we can add this - but what would be the operator in F#? Any suggestions? |
the bit shifting stuff having very large operator is fine to me, trying to match C terseness in this area isn't something I feel F# needs to compete with. Porting C code, doing bitshifting, or bitshifting code in general, it seems it always require checking the fine semantics, to be done properly. Maybe this should be the job of a translate tool, and we keep the aesthetics that went into picking the current bitshifting operators that we currently enjoy in F#, it may means Through languagePrimitives only, in first place, would be the safe and conservative route, letting people define their |
Unsigned right shift operator
I propose we add the unsigned right shift operator to F#. Since C# is looking to add this operator, and F# already has all the bit-twiddling operators equivalent to C#, it only makes sense for F# to also add this operator for whatever C# has reasons for:
The existing way of approaching this problem in F# is
However, as mentioned in the quote above, this is not applicable to generic math code. Although for F# we have SRTP, it is still desirable to have this defined and built-in for standardisation.
Pros and Cons
The advantages of making this adjustment to F# are
<<<
forlsl
,>>>
forasr
and now we finally have an equivalent forlsr
.The disadvantage of making this adjustment to F# is that this may be too niche to warrant its own operator.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): XS - Just copy the implementation for
>>>
and useshr.un
instead ofshr
.Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: