-
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
Add a safe stackallocspan function that returns a Span #720
Comments
The big blocker to something like this is that FSharp.Core would have to target either:
And likely do so as another binary. So this would increase the number of binaries in the package to three, which isn't ideal. |
Edit: yeah, it doesn't seem like a good idea. |
This should be declined in favour of dotnet/runtime#52065. |
dsyme
changed the title
Add a safe stackalloc function that returns a Span
Add a safe stackallocspan function that returns a Span
Jun 16, 2022
Declining per @Happypig375's comment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I propose we add a function that returns a
Span
pointing to stack memory.The existing way of approaching this problem in F# is ...
I propose that the function's signature would be as the above. Furthermore, explicit type arguments should not be required. Even in constructs like
Unchecked.defaultof
andtypeof
, they are required, but can be circumvented by typing something liketypeof<_>
(when it doesn't make any sense at all).The function above causes the compiler to complain twice about unverifiable code. The proposal should not produce any compiler warnings, just like in C#.
Also, returning a
stackalloc
edSpan
from a function that created it should be forbidden in compile-time to avoid memory corruption, just like C#. For example, if I remove theinline
modifier above, it would have led into some serious stack smashing occurrence.Pros and Cons
The advantages of making this adjustment to F# are the ability to simply and safely exploit the memory in the stack and feature parity with the C# compiler.
The disadvantages of making this adjustment to F# are (the section is intentionally left blank)
Extra information
Estimated cost (XS, S, M, L, XL, XXL): M (for the last paragraph of my proposal,
XS for the rest).Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: