Please vote once and for good: range operations

Bill Baxter wbaxter at gmail.com
Wed Jan 28 21:02:20 PST 2009


On Thu, Jan 29, 2009 at 1:51 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Bill Baxter wrote:
>>
>> On Thu, Jan 29, 2009 at 1:25 PM, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>
>>> Simen Kjaeraas wrote:
>>>>
>>>> Andrei Alexandrescu wrote:
>>>>
>>>>> So please let's vote once and for all.
>>>>>
>>>>> Andrei
>>>>
>>>> Do let's. My first vote goes to first/last, with head/toe at second
>>>> place.
>>>>
>>>> --
>>>> Simen
>>>
>>> Ok, after looking at my code I discovered a huge problem with "first".
>>> ("Last" is cool.) If all you do is implement them and use them with
>>> foreach,
>>> fine. But if you need to call them manually (which is the case
>>> sometimes),
>>> you get really badly interacting terms there. Look at this, taken from
>>> real
>>> code (the filter function):
>>>
>>> while (!_input.empty && !pred(_input.first)) _input.next;
>>>
>>> I can see the putative user scratching their head: "Ok, so I start
>>> iteration
>>> with the first element, then I move to the next one... but then why the
>>> heck
>>> am I looking at the first again?"
>>>
>>> "First" must go.
>>
>> Can't you just think of it as the first of the range, not the first of
>> everything?
>
> I could, if "next" weren't called "next". If the current is called "first",
> "next" means to move to another quantum universe in which the current
> "first" is forgotten and what was after "first" in the previous universe is
> now "first". That doesn't strike me as intuitive :o).
>
>> If you ask me who is first in line, I'm going to tell you who is the
>> first in line right now, currently.  Not who was first back when the
>> line first formed.  This seems similar to me.  So not confusing at all
>> if you think of it that way.  The range is not the container.
>
> That's a good point, but... we are at liberty to choose ANY names we please.
> Is this weird "first"/"next" combo our best shot?

But unless you've got some new words to add, we've listed pretty much
every reasonable pair, and they all have issues of similar magnitude
(or at least which some fraction of people will declare is of similar
magnitude...)

--bb



More information about the Digitalmars-d mailing list