Questions about the slice operator

Jonathan M Davis jmdavisProg at gmx.com
Wed Apr 4 10:09:16 PDT 2012


On Wednesday, April 04, 2012 14:37:54 Simen Kjærås wrote:
> On Wed, 04 Apr 2012 14:21:01 +0200, Jacob Carlborg <doob at me.com> wrote:
> > On 2012-04-04 14:16, Simen Kjærås wrote:
> >> And what do we do with 3..$?
> > 
> > Hmm, that's a good point. The best I can think of for now is to
> > translate that to:
> > 
> > range(3, size_t.max)
> > 
> > Or something like:
> > 
> > struct range
> > {
> > 
> > size_t start;
> > size_t end;
> > bool dollar; // better name is needed
> > 
> > }
> > 
> > range(3, 0, true)
> 
> Not enough:
> 
> $-3..$-2
> 
> This is a hard and unpleasant one, unless we go with $ being
> defined as the length of the array we're slicing, and only valid
> inside a slice operation. (and of course some opDollar or the
> like for other containers)

I believe that we have opDollar already but that it's buggy.

http://d.puremagic.com/issues/show_bug.cgi?id=7097
http://d.puremagic.com/issues/show_bug.cgi?id=7520

Several types in Phobos already have opDollar (generally an alias for length, 
it seems).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list