Feature request: allow "array" properties to define an enumerator
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
Array properties cannot define an enumerator, which is bad because you can have many array properties within one class but only one enumerator.
Syntax suggestion:
TTest = class
// ...
function GetObjectEnumerator: TTestObjectEnumerator;
property Objects[Index: Integer]: TObject read GetObject enumerator GetObjectEnumerator;
end;
Usage:
var
Test: TTest;
Obj: TObject;
begin
//...
for Obj in Test.Objects do
//...
end;
-----
This syntax is completely new and unique so it does not break any legacy code.
Please note that the "enumerator" keyword can be used only for "array" properties because normal properties can have a default enumerator defined.
----- String index type is valid as well, because enumerator doesn't care of the index type: property Objects[Index: string]: TObject read GetObject enumerator GetObjectEnumerator;
-----
This allows e.g. code like:
procedure TForm1.Button1Click(Sender: TObject);
var
Cont: TControl;
begin
for Cont in Controls do
//...
end;
Mantis conversion info:
- Mantis ID: 28820
- Build: trunk
- Version: 3.1.1