"isDroppable" range trait for slicing to end

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 31 00:30:27 PDT 2012


On Wednesday, October 31, 2012 08:13:08 monarch_dodra wrote:
> BTW: Once you are done, maybe you could present here what it
> means exactly to be slice-able? AFAIK, your current proposal
> allows for infinite ranges to verify "hasSlicing", if they can be
> sliced between [a ... b], whereas Dmitry seems to think that
> should not be so. At all.

It works now, but I'm open to removing it, since it _is_ odd to be able to 
slice an infinite range and get a completely different type from out. opSlice 
with opDollar combined with take would give you the same effect:

take(infRange[a .. $], b - a);

But without at least having opSlice with opDollar, you'd be forced to use drop 
or popFrontN, which would be O(n) rather than O(1).

> Well in conclusion, sorry to have brought a crappy solution :/ I
> guess we had something simple all along...

Well, live and learn. It happens to us all from time to time. I'd forgotten 
about opDollar prior to this discussion (mostly because it wasn't working), 
and it's quite applicable to hasSlicing.

- Jonathan M Davis


More information about the Digitalmars-d mailing list