Top 5

Denis Koroskin 2korden at gmail.com
Fri Oct 10 06:46:11 PDT 2008


On Fri, 10 Oct 2008 17:43:42 +0400, Denis Koroskin <2korden at gmail.com>  
wrote:

> On Fri, 10 Oct 2008 17:22:10 +0400, Andrei Alexandrescu  
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> Sergey Gromov wrote:
>>> My T[] is useful when you want to recursively split a megabyte file  
>>> into a couple thousands of tokens, and then modify some of those  
>>> tokens.  For that, your T[] must be lightweight, it must reference a  
>>> bigger piece of data, and it must guarantee not to write anything into  
>>> memory outside its boundaries.
>>>  The Array is for appending.  It must always own its memory.   
>>> Therefore you should be able to pass it around by reference, so Array  
>>> is a *class* and cannot be nearly as lightweight as T[].
>>>  You see, many of their properties are orthogonal.  If you drop one,  
>>> you lose flexibility.
>>>
>>>> Besides, Array!(T) is not a good name for build-in type.
>>>  Names are placeholders here, not an actual proposal.
>>
>> What's wrong with making Array a library type?
>>
>> Andrei
>
> Then, you'll have to drop new T[] syntax in favor of new Array!(T);

Not too bad if you stop thinking about T[] as a resizable array:

T[n] foo; // an array of fixed size (n)
T[] bar = array.all(); // fixed-sized, too

It will take time to get used to it, but it seems resonable to me.



More information about the Digitalmars-d mailing list