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

Alexander Klenin klenin at gmail.com
Tue Oct 20 11:11:49 CEST 2009


On Tue, Oct 20, 2009 at 19:34, Michael Van Canneyt
<michael at freepascal.org> wrote:
> You don't know this with an iterator since you depend on the implementation
> of the iterator. The loop could loop forever then...

Just as it can when using iterators explicitly. No difference here.

> Secondly:
> You promote a certain class/interface to a language feature. The compiler
> then depends on the presence of a certain class with some 'known' methods in
> the RTL.
> Both points are simply wrong from a language point of view.
> It is bad enough that the second point is already so for interfaces and even
> TObject, (a very serious design flaw by Borland) but extending this even
> further to include actual language features such as the for loop is 2
> bridges too far as far as I'm concerned.

Well, for better or worse, tight integration of language and RTL is an intrinsic
feature of Pascal language since it's inception.

Just look at the original spec:
Write, Writeln, Read, Readln, Pred, Succ, Reset -- almost all standard functions
are "magic"!
Borland just continued the tradition started by Wirth.
Now that is so ingrained in ObjectPascal that there is no point in resisting:
arrays/SetLength, RTTI/GetXXXProp, the whole TObject, string/Copy, the
list goes on...

Almost every feature in modern Pascal is broken this sense.
Still, this might not be such a bad thing -- see C++/STL for
the opposite method driven to it's logical conclusion.
So I guess a measured dose of language/RTL integration is actually good.

-- 
Alexander S. Klenin



More information about the fpc-devel mailing list