Shout out to D at cppcon, when talkign about ranges.
Eric Niebler via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 9 14:58:43 PDT 2015
On Wednesday, 7 October 2015 at 14:59:28 UTC, Trass3r wrote:
> On Tuesday, 6 October 2015 at 22:39:01 UTC, Ulrich Küttler
> wrote:
>> Yes, this is an explanation. Thanks. So the argument being C++
>> customs. Now that you mention it, this seems to be the
>> argument in Eric's D4128 paper, too.
>>
>> I was hoping for a somewhat deeper reasoning. Out of
>> curiously, I am still trying to grasp all the implications.
>> Ranges are hard.
>
> Another one is "odd number of iterators algorithms"
>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4128.html#appendix-3-d-ranges-and-algorithmic-complexity
>
> D’s choice of algorithmic basis operations is inherently less
> efficient than C++’s.
Glad that you guys found my rationale. Yes, those are the two big
reasons. Trying to express algorithms without any clear
abstraction of "position within range" (independent of ranges) is
hard and awkward, and occasionally causes algorithms to be less
efficient.
IMO, James Touton's "position-based ranges"[1] was/is a viable
design of a ranges-first interface that also had a (very weak but
sufficient) notion of position. It might be a direction for D if
you ever find it necessary.
It's true that the initial version of Boost.Range wasn't terribly
interesting. As early as 12/2004, I was working on a set of
extensions to Boost.Range that added range adaptors that chain.
(See https://svn.boost.org/svn/boost/sandbox/boost/range_ex.)
Lazy range operations that compose is where range-based design
starts. That's as far back as I can trace my work on "real
ranges". This work was eventually merged into Boost.Range as
Range v2.
On Thursday, 1 October 2015 at 08:37:37 UTC, Walter Bright wrote:
> Range iteration over arrays have been around in D since the
> beginning and a more general proposal first appears here:
>
> http://www.digitalmars.com/d/archives//12773.html
I don't see any generic description there of what constitutes a
range or how to leverage it in user code, just a discussion of
the foreach language construct.
> I found a link to Thorsten's Boost range:
>
> http://www.boost.org/doc/libs/1_34_0/libs/range/doc/intro.html
> http://www.boost.org/doc/libs/1_34_0/libs/range/doc/range.html
>
> It returns an iterator, so I don't think it is what we'd
> consider a range to be today.
>
> Matthew's ranges had the following members:
>
> current
> advance
> is_open
>
> corresponding to front, popFront, and empty.
>
> So I'd say given what I can dig up, that D's ranges were more
> advanced than Boost's were at the time.
Walter, you seem to suggest that Real Ranges have a
popFront/front interface. Naturally by that metric C++ ranges
don't count! But IMO that's not what matters. What matters is the
programming model that ranges permit. Boost.Range's model where
ranges are a layer over iterators can and does support that
model, as my range proposal and my range_ex library from 2004
demonstrate.
To be honest, this whole conversation is kind of funny to me. It
reminds me of the Bugs Bunny cartoon where Marvin the Martian
plants his flag on Earth and says, "I claim this planet in the
name of [Digital] Mars!" We Earthlings respectfully disagree. :-)
Eric
[^1]
http://www.open-std.org/pipermail/ranges/2014-March/000499.html
More information about the Digitalmars-d
mailing list