Static arrays, typeof and IFTI?

Don nospam at nospam.com
Tue Oct 11 13:31:38 PDT 2011


On 11.10.2011 18:54, bearophile wrote:
> Andrei Alexandrescu:
>
>> I was more enthused about that, but later I realized there are very few
>> situations in which one reasonably has a fixed-size array that is large
>> enough to make counting inadequate and is also updated often enough to
>> make the feature worthwhile. It's one of those features that are nice to
>> have but are not really missed in real code.
>
> I am not going to appreciate a language/compiler that accepts and compiles this program silently. This trap has caused a bug in my code time ago:
>
> int[3] a = [1, 2];
> void main() {}

I've hit that bug many, many times. But...

> The usage of [$] in that case avoids that kind of bug...

How? The code above would still compile. Would be much better to just 
ban assigning an array literal to an static array of different length.



More information about the Digitalmars-d mailing list