On Wednesday, August 21, 2013 00:23:09 John Colvin wrote: > What I was trying to say was: is there a good reason they are > always dynamic arrays? > > What would break if they were made static by default but dynamic > on direct assignment to a dynamic array?
Static arrays are unsafe in many situations, especially if you end up slicing them by accident. The semantics of static arrays are also very different, since they're value types. Static by default would be a very bad idea IMHO. Obviously, static arrays can be desirable, but the programmer needs to be careful any time that they're used. Having the compiler avoid allocating a dynamic array in any situation where a static one is clearly warranted is certainly desirable, as it avoids unnecessary allocations, but that's very different from making static the default. - Jonathan M Davis
