-
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
Native interop for C#13 params enhancements #1377
Comments
Definitely not S, this should go hand in hand or together with type directed / user defined collections. |
The other big part of this is |
I think it's complimentary, yes. My problem with the priority attribute is that we can safely introduce support for it for tiebreakers, but I am still a bit hesitant about just generally supporting it - not 100% sure it's the greatest idea. For tie breakers, I think we'll make it for 9, for broader support, I think it should be a separate suggestion. |
The motivation is not the same as the proposal here. The perf benefits would come from passing stackalloc'd values for the Following the text in this suggestion, doing: WriteNames(ReadOnlySpan([|"Don"; "Don"|])) // calls the ReadOnlySpan overload Would not be any better, since it still allocates an array. Based on what I have seen in the BCL so far (other usages of this C# feature can vary across libraries of course, but this is the dominant usage so far), the net benefit of this feature meeting the motivation could be achieved by: That way, this avoids the need to detect all forms user defined collections, as well as following betterness rules for overload picking. |
That's why I think it should go together with type directed collections (or universal collections syntax). |
It is a tradeoff between supporting everything which C# can and keeping up to date with it, vs. being pragmatic and admitting that passing stackalloc'd values to |
More practically speaking, in the priority choice between:
I see more value in the latter. |
If we are aiming at only treating I suppose there are multiple things here:
|
I propose we better interop with the new C# params capabilities
C# 13 is enhancing
params
. It used to only work with arrays:Now it can work with whatever collection:
C# works in the way that the most efficient overload is used on the caller side. Hence
will be resolved to the
ReadOnlySpan
overload, providing the best perf possible in this case.I propose we allow F# do the same here - automatically pick the best overload.
The existing way of approaching this problem in F# is
Currently there is no automagic overload resolution here hence we'd need to construct the collections manually:
Not smooth.
Pros and Cons
The advantages of making this adjustment to F# are
Potential perf perks out of the box (with no code adjustments) when moving to a new lang version. Embracing the power of Span.
The disadvantages of making this adjustment to F# are
Probably not trivial IL complication.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S (for someone who understands how params interop works now) or M (for others)
Related suggestions: (put links to related suggestions here)
#1267
#1120
#1013
Affidavit (please submit!)
Please tick these items 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: