What's the point of static arrays ?

wjoe invalid at example.com
Thu Jul 9 12:12:06 UTC 2020


+ The size is known at compile time.

vs.

- Can neither grow nor shrink them
- Can't append elements
- Can't remove elements
- Can't slice them
- Can't range them
- Assignment copies the whole array, as in int[5] a; auto b = a;
- Size is limited by stack
- Stack overflow issues


Some of the cons could be considered a feature.
Also GC but it's possible to make a dynamic array implementation 
which avoids the GC.

I'm not considering supposed performance benefits/penalties 
because these need to be profiled.

Considering the many downsides why would I ever want to choose a 
static over a dynamic array ?



More information about the Digitalmars-d-learn mailing list