Phobos uses opSlice and opDollar without checking for it

Era Scarecrow via Digitalmars-d digitalmars-d at puremagic.com
Wed May 25 15:08:31 PDT 2016


On Wednesday, 25 May 2016 at 21:43:19 UTC, Jonathan M Davis wrote:
> Unfortunately, it's never been implemented (IIRC due to issues 
> related to AAs having length but not being ranges; the 
> implementation likely needs to check for the range-based 
> functions in addition to length). And as long as 7177 hasn't 
> been implemented, hasSlicing and isRandomAccessRange can't 
> require $, and until they require opDollar, Phobos should never 
> use $ on ranges unless they're guaranteed to be arrays or 
> guaranteed to be ranges that implemented opDollar, and that's 
> really true of _any_ D code at this point, not just Phobos.

  Hmmm if an algorithm can make use of opDollar, we should be able 
to test for it. Maybe extend the tests that include it say 
hasFullSlicing? Unless something explicitly needs opDollar then 
it probably shouldn't be included. Someone's already mentioned 
infinite ranges/arrays, and AA not using $ would cause major 
breakages.

  Are there any major patterns that we can't implement without 
opDollar? Or are there any that would perform better with it 
present?


More information about the Digitalmars-d mailing list