On Wed, 21 Oct 2009, Alexander Klenin wrote:
On Wed, Oct 21, 2009 at 23:15, Michael Van Canneyt
<mich...@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".
Well, I think you can't compare the two cases.
I see little gain in changing
while Something(f) do
F.Somethingelse
to
For f in Something do
F.SomethingElse
The number of lines is equal, the amount of typed characters also is equal.
It's not more readable, either, IMHO.
When there is a big difference between the following goto and the while loop
it is supposed to be equal to:
:jumphere;
If Something(F) then
begin
F.SomeThingElse;
Goto jumphere;
end;
Here you need quite a few more lines and even an extra label definition, and
I don't think anyone will dispute that the while loop is more readable...
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel