Alignments, semantics from asserts, auto-count

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jul 31 18:54:35 PDT 2009


Ellery Newcomer wrote:
>> -------------------------
>>
>> This is unrelated, but I need D to become more handy:
>>
>> If I don't put a number there arr becomes a dynamic array, so if I want a static array I must count items first. Even C is more handy here. Can some auto-guessing syntax be added, like this?
>>
>> int[$] arr = [6,5,-1,-1,-3,-4,4,-3,1,3,0,-4,6,-3,3,4,-4];
>> int[?] arr = [6,5,-1,-1,-3,-4,4,-3,1,3,0,-4,6,-3,3,4,-4];
>>
>> Thank you.
>>
>> Bye,
>> bearophile
> 
> What's wrong with
> 
> auto arr = [6,5,-1,-1,-3,-4,4,-3,1,3,0,-4,6,-3,3,4,-4];
> 
> ?

Well we've concluded a while ago that it's vastly better for everyone if 
the automatic type of array literals is T[], not T[n]. So you need to 
declare the size, which is redundant, hence OP's request.

Andrei



More information about the Digitalmars-d mailing list