RFC on range design for D2
Michel Fortin
michel.fortin at michelf.com
Mon Sep 8 20:31:58 PDT 2008
On 2008-09-08 17:50:54 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> feedback would be highly appreciated. See:
>
> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html
That looks great. I want to suggest renaming a few functions to make
them more consistant and (hopefully) more expressive, as I see I'm not
the only one frowning on them.
So right now you're defining this:
r.getNext
r.putNext
r.left
r.next
rightUnion(r, s)
rightDiff(r, s)
r.right
r.pop
leftUnion(r, s)
leftDiff(r, s)
Here's my alternate naming proposal:
r.headNext
r.putNext
r.head
r.next
r.nextUntil(s)
r.nextAfter(s)
r.rear
r.pull
r.pullUntil(s)
r.pullAfter(s)
Note that r.headNext is literally r.head followed by r.next when you
have a forward iterator. You could also add "rearPull" to
bidirectional ranges if you wanted. :-)
The syntax is a little different for binary functions (union, diff) as
I changed them to members to make things easier to read and more in
line with the regular next and pull.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d-announce
mailing list