[fpc-devel] New feature discussion: for-in loop
Michael Van Canneyt
michael at freepascal.org
Wed Oct 21 09:02:25 CEST 2009
On Wed, 21 Oct 2009, Paul Ishenin wrote:
> Sergei Gorelkin wrote:
>
>> The question is, what advantage all this specific syntax could give over
>> simple searching the methods by name?
>
> Some people need less compiler magic, some does not care. New directive can
> reduce the magic level :)
>
> Btw, we use similar compiler magic every day. Just think of:
>
> 1. functions which all have special 'Result' variable :)
> 2. message methods which calls 'TObject.DefaultHandler' when you call
> inherited inside.
> 3. tobject methods related to interfaces
>
> I suspect there are more examples.
>
> In all the listed examples compiler searches for the special identifier.
> Therefore GetEnumerator identifier looks as very native solution for pascal.
Note that all these cases are introduced by Borland, and they are not exactly
an example of clean design. They are is what I referred to when I said that
the compiler already relies too much on TObject/IInterface methods.
Ideally, the compiler has no knowledge at all of specific classes, and a new
keyword such as Iterator (or whatever) helps in ensuring that the compiler
is not contaminated with knowledge of specific classes or methods.
Michael.
More information about the fpc-devel
mailing list