DIP 57: static foreach
Dicebot
public at dicebot.lv
Mon Mar 10 06:13:20 PDT 2014
On Sunday, 9 March 2014 at 21:53:45 UTC, Adam D. Ruppe wrote:
> On Sunday, 9 March 2014 at 21:47:17 UTC, bearophile wrote:
>> suggest to add to DIP57 one more thing: that the introduction
>> of static foreach should come with a warning against the usage
>> of not-static foreach on tuples (and eventually this warning
>> should become a deprecation message).
>
>
> I don't agree because foreach on a tuple is just plain foreach.
> That it unrolls is just an implementation detail that doesn't
> change much else. I think considering it to be a separate kind
> of loop is like considering foreach over arrays, ranges, and
> opApply items separate loops. Those are just different
> implementation details of the same user concept.
Can't agree. You can't call it implementation detail if it is a
property that leaks into user code and can be relied upon. I
sometimes hear statements akin to "tuple is like container and
tuple foreach is just like foreach" but it is a very idealistic
view that simply does not match current D state. Despite all
behavior hacks that try to make it look so.
So right now it _is_ a separate and distinctive kind of loop. At
the same time it is a very specialized tool and deprecating it
does not sound like a practical approach for reducing language
complexity. Probably some years later if we eventually find out
no one uses it anymore.
More information about the Digitalmars-d
mailing list