www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Please vote once and for good: range operations

reply Denis Koroskin <2korden gmail.com> writes:
Vladimir Panteleev Wrote:

 On Thu, 29 Jan 2009 06:25:58 +0200, Andrei Alexandrescu  
 <SeeWebsiteForEmail erdani.org> wrote:
 
 Simen Kjaeraas wrote:
 Andrei Alexandrescu wrote:

 So please let's vote once and for all.

 Andrei

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.

I don't think that "next" is an appropriate name here. Since it is an action, it should be named as one - "next" sounds more like a function (which doesn't modify the instance). Have you considered "forward"? -- Best regards, Vladimir mailto:thecybershadow gmail.com

Agree, "advance" would be a better name, though (imo).
Jan 29 2009
parent reply Chad J <gamerchad __spam.is.bad__gmail.com> writes:
Denis Koroskin wrote:
 Vladimir Panteleev Wrote:
 
 On Thu, 29 Jan 2009 06:25:58 +0200, Andrei Alexandrescu  
 <SeeWebsiteForEmail erdani.org> wrote:

 Simen Kjaeraas wrote:
 Andrei Alexandrescu wrote:

 So please let's vote once and for all.

 Andrei

place. -- Simen

("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.

action, it should be named as one - "next" sounds more like a function (which doesn't modify the instance). Have you considered "forward"? -- Best regards, Vladimir mailto:thecybershadow gmail.com

Agree, "advance" would be a better name, though (imo).

Same, it seems BETTER. Though, it seems like it's suboptimal as well. As I understand it we aren't so much moving rightward a head that's reading a tape, but instead we are incrementally chopping off the leftmost elements until none are left. So it is possible (though not intuitive) to draw analogies and write metaphors: we are advancing our knife each time we chop off a bit of carrot. Anyways, while technically incorrect as far as I can tell, it isn't aesthetically displeasing to me, so in some odd way I am alright with next. Hmmm... maybe "chop" is a good word for this... - Chad
Jan 29 2009
next sibling parent Daniel Keep <daniel.keep.lists gmail.com> writes:
Chad J wrote:
 Denis Koroskin wrote:
 Agree, "advance" would be a better name, though (imo).

Same, it seems BETTER. Though, it seems like it's suboptimal as well. As I understand it we aren't so much moving rightward a head that's reading a tape, but instead we are incrementally chopping off the leftmost elements until none are left. So it is possible (though not intuitive) to draw analogies and write metaphors: we are advancing our knife each time we chop off a bit of carrot. Anyways, while technically incorrect as far as I can tell, it isn't aesthetically displeasing to me, so in some odd way I am alright with next. Hmmm... maybe "chop" is a good word for this... - Chad

That's why I suggested "advanceFront" and "retreatBack." I don't think there's a single, short word to exactly express the concept "move the front of a view of some sequence one element towards the end." -- Daniel
Jan 29 2009
prev sibling parent "Joel C. Salomon" <joelcsalomon gmail.com> writes:
Chad J wrote:
 As I understand it we aren't so much moving rightward a head that's
 reading a tape, but instead we are incrementally chopping off the
 leftmost elements until none are left.  So it is possible (though not
 intuitive) to draw analogies and write metaphors:  we are advancing our=

 knife each time we chop off a bit of carrot.

 Hmmm... maybe "chop" is a good word for this...

How about =93chomp=94 and =93regurgitate=94? ;)
Jan 30 2009