T[new]

bearophile bearophileHUGS at lycos.com
Sun Aug 9 14:00:51 PDT 2009


Walter Bright:

I like this general proposal, it sounds like something that can improve D a little. There are many other things that have to be improved in D, but baby steps are enough to go somewhere :-)

>Slices will retain the old:
>     T[] slice;
> syntax. Resizeable arrays will be declared as:
>     T[new] array;

Such syntaxes have to be chosen wisely. I don't fully understand that syntax. And maybe I don't fully like it.
I think the default (simpler) syntax has to be the most flexible and safer construct, that is resizable arrays. Slices can be seen as an optimization, so they can have a bit longer syntax.


> Under the hood, a T[new] will be a single pointer to a library defined 
> type. This library defined type will likely contain three properties:
>      size_t length;
>      T* ptr;
>      size_t capacity;

Weren't you suggestion to use the start pointer - end pointer instead?


> 2. make arrays implementable on .net

I don't care of such thing. dotnet already has C# and C# is probably better than D, and it's similar anyway. So I don't think people will use D on dotnet. So even if creating a D for dotnet can be positive, I don't want D2 to change its design to allow a better implementation on dotnet.

The question by Brad Roberts looks important, it has to find some kind of answer:
>What will happen with slices over a T[new] when the underlying T[new] must be moved due to resizing?<

Bye,
bearophile



More information about the Digitalmars-d mailing list