deadalnix:
- added optimization to promote them on heap. Thing like
int[2] = [1, 2] can trivially avoid GC allocation.
See my usage examples (think of the examples as not having the
"s" suffix):
void main() {
// Some imports here.
foo([[1, 2]s, [3, 4]]s);
auto t1 = tuple([1, 2]s, "red");
auto aa1 = ["key": [1, 2]s];
auto pairs = 10.iota.map!(i => [i, i + 10]s);
}
A smart system can promote only the first one to value array. The
compiler has to leave the other cases to the judgement of the
programmer.
- added some support for ownership/lifetime. This will allow
the compiler to promote even more on heap.
This is what I too have said in my original post. For those
features to work well you need first a good static management of
memory ownership.
If don't expect the new syntax to be that useful if these point
are addressed. If I'm turn out to be wrong, we can reconsider
at that point.
I can show code similar to the examples above where the []s
syntax is useful.
And using a function as Andrei suggests is not a good idea:
foo(staticArray(staticArray(1, 2), staticArray(3, 4)));
I don't think lot of people is going to write code like that.
And if you are about to suggest this:
alias S = staticArray;
Well, do you like to see aliases in your code?
Bye,
bearophile