Revised RFC on range design for D2

Sergey Gromov snake.scaly at gmail.com
Fri Sep 12 07:58:38 PDT 2008


Bill Baxter <wbaxter at gmail.com> wrote:
> On Fri, Sep 12, 2008 at 11:22 PM, Sergey Gromov <snake.scaly at gmail.com> wrote:
> > Bill Baxter <wbaxter at gmail.com> wrote:
> >> But I do have some suggestions nonetheless!  Marked with ==> below.
> >>
> >> -- Universal --
> >> r.done
> >> r.init
> >>
> >> --- Input : Universal ---
> >> e=r.head
> >> e=r.next
> >> r1=r.release  ==> r.transfer?  Release sounds like ref counting (e.g. in COM)
> >>                           Also seems like r.transfer(r1) could make
> >> implementation more efficient.
> >>                           Or perhaps make it a .swap like STL.  Maybe
> >> you have something against .swap?
> >>
> >> -- Output : Universal --
> >> r.put(e)
> >>
> >> -- Forward : Input, (optional) Output  --
> >> r1 = r
> >> r.head = e
> >> t=r.after(s)
> >>
> >> -- Bidirectional : Forward --
> >> e = r.toe
> >> r.toe = e
> >> r.reduce           ==> r.retreat  -- aka "pull back"
> >> t = r.before(s)
> >>
> >> -- Random access : Bidirectional --
> >> l = r.length
> >> e = r[n]
> >> r[n] = e
> >> r1 = r[n1..n2]
> >> ------------
> >>
> >> Just those two!
> >
> > I've got a bit of insight!  XD
> >
> > -- Common
> > r.empty
> >
> > -- InOut
> > v = r.next;     => T R.next();
> > r.next = v;     => T R.next(T v);
> >
> > -- Forward: InOut, copyable
> > v = r.tip
> > r.tip = v
> > r1 = r.before(s)
> > r1 = r.after(s)
> >
> > -- Bidir: Forward
> > v = r.prev
> > r.prev = v
> > v = r.toe
> > r.toe = v
> >
> > -- Random: Bidir
> > no changes
> >
> > prev() seems very misleading, otherwise I like it.
> >
> 
> So basically you changed
> done ==> empty
> head ==> tip
> retreat ==> prev
> ?

The insight was about get/put ==> next.  That's the most significant 
change, others are merely renames as you rightfully point out.  Hence 
the "prev" which should mean both "get at the end" and "put to the end".

> "prev" is horrible.  I still like "retreat" best so far.  We need the
> contrapositive of "next" not the "opposite".  :-)  And since that
> doesn't exist we should just go for a word that sorta means the right
> thing and won't be  confused with being the opposite (or with being
> something else entirely like "reduce").

v = r.retreat
r.retreat = v

It's definitely better than prev.  Thank you for proposing.  I'm not a 
native speaker so inventing names could be a tricky business for me.


More information about the Digitalmars-d-announce mailing list