Static arrays, typeof and IFTI?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Oct 11 06:35:50 PDT 2011
On 10/11/11 2:56 AM, bearophile wrote:
> Norbert Nemec:
>
>> However there does not seem to be any way to state
>> int[...whatever...] myvar = [1,2,3,4];
>> enum N = typeof(myvar).init.length;
>> and let the compiler deduce that N==4.
>
> Since years some people (among them there is me too) are asking for this syntax:
>
> int arr[$] = [1,2,3,4];
>
> Vote for it here (an enhancement request from 2006!):
> http://d.puremagic.com/issues/show_bug.cgi?id=481
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.
Andrei
More information about the Digitalmars-d
mailing list