Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Wed Jan 6 11:11:41 UTC 2021
On Wednesday, 6 January 2021 at 10:55:39 UTC, Ola Fosheim Grøstad
wrote:
> int[_] = …
>
> or
>
> _[_] …
To expand on this with more examples, you might want to constrain
"auto" in various ways with pattern matching:
// ensure static array of something with length 4
_[4] v = f();
// ensure that I get a MyContainer with some unspecified type
elements
MyContainer<_> c = g();
// define a function that swaps the content of an array of length
2
void swap(ref _[2] a){ … }
// it would also be shorter than auto, but not sure if that is a
good thing
_ x = 3 // same as "auto x = 3"
More information about the Digitalmars-d-announce
mailing list