resizeable arrays: T[new]

Walter Bright newshound1 at digitalmars.com
Mon Jun 4 10:17:37 PDT 2007


Tom S wrote:
>> A few possible alternatives:
>>
>> T[new]    // Proposed
> 
> Looks awkward, yeah. And it would produce false hits for anyone doing 
> new-hunting (happens when you care about allocations, but prototype 
> using 'new').

I'm not necessarily sold on that syntax, but it's workable and unambiguous.

> 
>> T[$]    // Since $ already means "length" for arrays
> 
> I don't like it... Looks like an out of bounds error to my parser ;)

There are parsing ambiguities with that I wish to avoid.


>> T[*]    // Indicating the index could be anything
> ++votes;

That is used for VLA's in C99, which could mislead people.



More information about the Digitalmars-d-announce mailing list