Behind the scene, the Closures implementation declares classes and interfaces. And, because I strongly believe it to be conceptually the right way, such entities are declared in the innermost routine scope. For example, -------8<------- procedure Foo; type Local = reference to procedure; begin end; -------8<------- is essentially -------8<------- procedure Foo; type Local = interface procedure Invoke; end; begin end; -------8<-------
FPC does not allow the user to declare local classes/interfaces†, and this shall remain so. However, in order to /internally/ support such entities, a couple of changes is required. I have those implemented, but, firstly, let us establish that the team is on board with the general idea. † No idea why, but generic local classes/interfaces are accepted. However, FPC instantiates them in the global scope, which results in this wonderful bug: -------8<------- function Foo: TClass; type Cls<T> = class end; begin result := Cls<Char> end; function Bar: TClass; type Cls<T> = class end; begin result := Cls<Char> end; begin // BUG: 'FALSE' writeln( Foo() <> Bar() ) end. -------8<------- -- βþ _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel