The demise of T[new]
BCS
none at anon.com
Mon Oct 19 15:12:24 PDT 2009
Hello Yigal,
> On 19/10/2009 22:53, BCS wrote:
>
>> 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.
>
Yes, it should inline. What I'm saying is that unless it is /guaranteed/
that it will /always/ inline, I'm going to have an issue.
>> 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 think that T[] should be (at a minimum) the current slice semantics and
implementation (the lvalue-length and ~/~= stuff is another question). If
this happens to have the needed semantics to act as a range, all the better.
Having a clean, light construct to deal with low level memory access is just
to handy to give it up completely.
More information about the Digitalmars-d
mailing list