ch-ch-changes

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Jan 27 21:47:07 PST 2009


On Wed, Jan 28, 2009 at 12:17 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
>> Also - "toe" is still a stupid name.  ;)  "first" and "last" would
>> have been my first choices, they seem so obvious.
>
> Turns out toe isn't half bad when I was coding with it - all I needed was
> something short and memorable.

Heh.  What about "a" and "z" then?  ;))

> One problem with "first" is that it sometimes suggests something else. For
> example, if I have a generator for the numbers 1 to 10 and have advanced it
> a bit, gen.first suggests I'm looking back to the very first element, not
> the state of the iteration. I agree that gen.head isn't terribly evocative
> either, but then at least it doesn't evoke something wrong :o).

I was thinking about making D ranges be to D arrays as C++ iterators
are to C++ pointers: r[0] is head and r[$ - 1] is toe.  But that has
problems, since you can't make an infinite range, since you can't say
that r[0] is legal while r[$ - 1] is not.  (D also doesn't allow
overloading $, an irritating limitation, but one that could be fixed
in order to implement such a paradigm.)

> Anyhow, how about doing what Haskell does? They use "head" and "last". And
> at least we'd be able to blame *them* if anyone doesn't like the names :o).
> Thoughts?

Without the "first" to provide contrast, "last" potentially takes on
the confusingly-overloaded English meaning of "previous".  Which isn't
the kind of ambiguity you'd want in ranges, I'll bet.

Naming is a pain in the butt.  Fine, I'll live with "head" and "toe" ;)



More information about the Digitalmars-d mailing list