Revised RFC on range design for D2
Bill Baxter
wbaxter at gmail.com
Fri Sep 12 07:50:01 PDT 2008
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
?
I'm actually ok with either "done" or "empty". "Done" is weird on a
random access range, but "empty" is weird on file input range, or a
generator. Or on the HMM example which is "done" when it reaches an
end state, but is not really "empty".
"head to toe" is a perfectly common expression, at least in American
English. Not sure why you don't like it. But tip to toe is kinda
cool for being 1 less letter! And no less clear.
"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").
--bb
More information about the Digitalmars-d-announce
mailing list