Jonathan M Davis:

> If anything, I'd argue that you shouldn't be allowed to use ref with iota,
> because instead of iterating over a fixed set of values,

Isn't an interval of natural numbers something fixed?



> (and a language which really has no relation to D no less)<

I remember the word "Python" on the home page of the D language, but you are 
right, Python is not much significant here, if only for being a language that 
tries to be semantically clean. Turning foreach into a semantic hodge-podge is 
not good.

--------------------

Martin Nowak:

> It can be very useful to skip array elements.

Perl too is very useful, but turning the foreach semantics into something so 
dirty is not a good idea, given the presence of the normal for loops that allow 
you do any thing.

--------------------

Andrej Mitrovic:

> The ref keyword isn't magic, and immutability isn't the answer to everything.

ref is not magic, but here it's used in a dirty way. And I think this will 
cause troubles. We will see.

--------------------

Marco Leise:

Actually it is light syntax sugar over a for loop.

But it doesn't look like it. It looks like a higher level language construct. 
So much that in years of usage of D foreach I have not thought that 
incrementing the item of an interval, you skip to the successive one instead of 
just incrementing it.

Allowing foreach to act just as light syntax sugar on a for means allowing it 
to be a significant leaking abstraction 
(http://en.wikipedia.org/wiki/Leaky_abstraction ) and this is not good for a 
language, even a system language.

Bye,
bearophile

Reply via email to