The demise of T[new]

Yigal Chripun yigal100 at gmail.com
Mon Oct 19 14:19:26 PDT 2009


On 19/10/2009 22:53, BCS wrote:
> Hello Yigal,
>
>> On 19/10/2009 19:10, BCS wrote:
>>
>>> Hello Yigal,
>>>
>>>> I think that Arrays and AAs need to be removed from the language. I
>>>> prefer to have a collections framework as part of Phobos without
>>>> special cases in the language for specific containers.
>>>>
>>> If it can be assured that all the current array ops will get inlined
>>> is all cases and can result in identical asm I'd be willing to
>>> consider this.
>>>
>>>> List!(Foo) list = new Array!(Foo); // instead of Foo[new]
>>>>
>>> For me to not dislike the idea you would also need to find a cleaner
>>> syntax.
>>>
>> See Leandro Lucarella's posts which describe the same idea.
>>
>> currently, AAs and arrays are implemented in the run-time. What I
>> suggest is to move them to the stdlib. I don't see how such a move can
>> impact performance which you're concerned with above.
>
> // a is an array of ints
>
> int b;
> if(a.length > 5) b = a[5];
> else b = a[$/2];
>
> No runtime in that at all now.

I don't see a reason why this can't be inlined by the compiler if Array 
is a lib type.
>
>> on the contrary,
>> moving these types outside the runtime will make it easier to improve
>> their implementations.
>>
>> regarding syntax, what's cleaner than calling an array an "Array"?
>> T[new] is less clear and hackish.
>>
>
> if T[new] gets done as Array!T, what does T[] look like?
T[] should be replaced by Ranges which are already implemented in Phobos.
>
> I'm not to worried about the fancy feature, it the bone simple stuff
> staying bone simple that I'm looking after.
>






More information about the Digitalmars-d mailing list