Why I Use D

Simen Kjaeraas simen.kjaras at gmail.com
Sun Mar 30 16:55:16 PDT 2008


On Mon, 31 Mar 2008 00:26:10 +0200, Scott S. McCoy <tag at cpan.org> wrote:

> You also could if array[5 .. -3] implied length -3.
>
> Similarly. array[-3] could imply array[array.length -3]...
>
> But someone suggested against that, atleast for non-compile time
> checking.  I would agree, for the non-literal instance that a negative
> integer of -5 shouldn't result in magical figuring out if the element
> needs to be pulled from the front or the back.  But the literal case
> adds expressiveness, I think.

T[int] foo;

What is foo[-3]?

And user-defined types with overloaded opIndex and opSlice.
Should [-X] work differently for them?

-- Simen



More information about the Digitalmars-d mailing list