I have a generic List-like class tMyList<B>
with a method Each() which iterated over each element and calls anonymous procedure tMyList<A>.enumProc
with paramenter - the current item of type <B>
.
I want to implement the class as an Interface for easier lifetime management.
The problem is I cannot declare the Each method in the iMyList<A>
interface, because tMyList<A>.enumProc
type is unknown. As far as I know Interfaces does not support nested types?
Here is the code:
tMyList<B> = class;
iMyList<A> = interface
procedure each(enumProcedure: iMyList<A>.enumProc); // ERROR - Undeclared identifier: 'enumProc'
end;
tMyList<B> = class(tInterfacedObject, iMyList<B>)
type
enumProc = reference to procedure(item: iMyList<B>);
public
procedure each(enumProcedure: enumProc);
end;
*
Implementing Enumerator is not an option in this particular case