Why I Use D

Scott S. McCoy tag at cpan.org
Fri Apr 11 00:45:26 PDT 2008


The same thing foo[$-3] is now.

Whatever the heck that is.

:-)


On Mon, 2008-03-31 at 01:55 +0200, Simen Kjaeraas wrote:
> 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