-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 Span.StackAlloc<T> method #29605
Comments
This is likely impossible because You'd be much better suggesting language features for VB.Net and F# to support stack-allocation a la C#. It would be a lot easier for them to implement it as a language feature than it would be to change the runtime and likely the compiler to detect this pattern. |
This would not be impossible, it would just require the runtime to specially recognize the method and to treat it as part of the calling method (this is how the F# already has support for stackalloc today via their I would think, if something like this was exposed, it would be better suited first as |
Thanks. |
CC. @KathleenDollard |
@tannergooding TIL - However, it still would require runtime changes as you mention, which I'm guessing are harder to justify than language changes. |
You can use |
Closing as a dup of #25423. |
C# allows to allocate objects in the stack to be used with Span and Memory:
Span<byte> bytes = stackalloc byte[10];
I suggest to add a
StackAlloc
method to these classes to allow other languages like VB.NET an F# to do the same:dim bytes = Span.StackAlloc(of byte)(10)
The text was updated successfully, but these errors were encountered: