[fpc-devel] New feature discussion: for-in loop

Sergei Gorelkin sergei_gorelkin at mail.ru
Wed Oct 21 15:18:00 CEST 2009


Alexander Klenin пишет:
> On Wed, Oct 21, 2009 at 23:15, Michael Van Canneyt
> <michael at freepascal.org> wrote:
> 
>> This is all just nitpicking. Iterators as a language construct are a very ugly
>> hack to save some typing, no matter how you turn it. Nice maybe for
>> languages with dynamic typing and so on, but really not on it's place in Pascal.
> 
> I beg to disagree.This is completely backwards -- like saying that
> "while" loop is an
> ugly hack to save some typing of "goto" operators.
> Iterators and foreach loops are very important tools of structured coding.
> The fact that "for..in" may be expressed in terms of lower-level primitives
> does not decrease its importance, just like existence of "goto" does
> not decrease
> the importance of "while".
> 
One can always say vice versa, that 'goto' is an ugly hack and 'while' 
is the solution.

In general, the more I read the discussion, the more I agree with Michael.
We should actually discuss:
1) What is the problem we need to solve
2) What existing solutions already exist and can be used
3) What are the advantages and downsides of each existing solution
4) And after that, we could come up to a design of the new feature.

Instead, the discussion is almost ultimately about how to modify the 
language.

The strategic view of the situation is also very desirable. For example,
things can change considerably once we have generics are completed, and 
maybe there's simply no need trying to fit the iterators into today's state.

Regards,
Sergei



More information about the fpc-devel mailing list