Repost: make foreach(i, a; range) "just work"

Regan Heath regan at netmail.co.nz
Tue Feb 25 09:34:24 PST 2014


On Mon, 24 Feb 2014 17:58:51 -0000, Jesse Phillips  
<Jesse.K.Phillips+D at gmail.com> wrote:

> On Monday, 24 February 2014 at 10:29:46 UTC, Regan Heath wrote:
>> No, not good enough.  This should just work, there is no good reason  
>> for it not to.
>>
>> R
>
> I have long since given up believing this should be in the language, I'm  
> satisfied with the reasons I gave for why it is not in the language and  
> why it is not needed to be in the language.
>
> You asked for feedback, I've given mine to you. I'm ok with you  
> disagreeing with that.

Sure, no worries.  :)

I'd just like to list your objections here and respond to them all, in one  
place, without the distracting issues surrounding the 3 extra schemes I  
mentioned.  Can you please correct me if I miss represent you in any way.

1. Adding 'i' on ranges is not necessarily an index and people will expect  
an index.
2. You don't need to count iterations very often.
3. Your point about the "range gets a new value and foreach would compile  
but be wrong"
4. This area of D is not important enough to polish
5. We will have enumerate soon, and won't need it.

I think this is every point you made in opposition of the change I want  
(excluding those in opposition of the 3 additional schemes - which in  
hindsight I should just have left off)

I believe objection #3 is invalid.  The foreach in the example given is a  
flattened tuple foreach, not the range foreach I want to change.  Making  
the change I want will have no effect on the given example.

I think the strongest objection here is #1, #2 and #4 are fairly  
subjective and #5 just seems a little odd to me, why would you "want" to  
type more rather than less?

For my point of view, it seems an obvious lack in D that the range foreach  
doesn't have the same basic functionality as the array foreach.  That's  
pretty much my whole argument, it should just work in the same way as  
arrays.

But, as you say we're free to disagree here, I was just about to suggest  
we were at an impasse myself.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list