Proposal: spanalloc
#6588
-
One of the unfortunate things about I propose |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 11 replies
-
Still not great, but you do get to use |
Beta Was this translation helpful? Give feedback.
-
Related to dotnet/runtime#52065. If runtime introduces a special API which simply stack-allocates a span, we probably wouldn't add a new syntax just for creation here. Though the implementation of collection literals (#5354) may also call into that API as appropriate. |
Beta Was this translation helpful? Give feedback.
-
If a new grammar is to be added for this purpose, I would prefer suffixes or prefixes of collection literals. var list = [ 1, 2, 3 ]; // List<int>
var span = [ 1, 2, 3 ]s; // Span<int> |
Beta Was this translation helpful? Give feedback.
-
Why can't |
Beta Was this translation helpful? Give feedback.
-
I know it’s a personal decision, but if one used the actual types instead of |
Beta Was this translation helpful? Give feedback.
var span = (stackalloc byte[1024]); // typed as Span<byte>
Still not great, but you do get to use
var
.