[Issue 16073] Ranges without opDollar not supported

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jan 20 10:27:52 PST 2017


https://issues.dlang.org/show_bug.cgi?id=16073

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #12 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to greenify from comment #10)
> > All of these useless options left to sloppy range implementations don't bring value.
> 
> This has probably been proposed before, but what about letting the compiler
> insert an opDollar alias if length is defined? This should greatly help to
> avoid sloppy implementation differences and one can still opt to use the
> opDollar overloads for superior performance.

https://issues.dlang.org/show_bug.cgi?id=7177 covers fixing it so that ranges
that define length automatically get opDollar, but it's never gone anywhere.
There has been discussion on it from time to time, but without implementing it,
requiring ranges to work with $ is going to break a lot of code, since odds are
that very few folks are implementing opDollar. Phobos itself doesn't do it
consistently.

But it's pretty ridiculous that we can't use $ with anything but arrays (which
is basically where we sit now), and it really should be fixed. I did fix it
some time ago so that isRandomAccessRange and hasSlicing verify that $ works
correctly if it works (at least verifies it as much as can be done statically),
but they've never required that $ works, because so few ranges implement
opDollar, and issue #7177 has never been implemented. I'd have changed
isRandomAccessRange and hasSlicing to require that $ work years ago if it
weren't for that.

--


More information about the Digitalmars-d-bugs mailing list