Feature request - Enumerating lists [delphi]?

Hello Remobjects team,

I demonstrated some capabilities of Remobjects to a colleague today. We couldn’t help but notice that Remobjects lists do not support enumerators (version 7.0.69.1081).

So constructs like "for person in personlist do… " do not work.

I very much like enumerators because they make my code cleaner and avoid dumb errors like iterating “from 0 to count”. May I humbly ask to add this feature?

I too would like to see this natively in the code. At the moment I’m using some auto generated class helpers (using the RODL as the source of information) to provide the functionality.

Regards,
Will.

Hi,

Does “RemObjects lists” mean array in RODL (TROArray) ? If so, yes it doesn’t support “for in” iteration, this issue is logged as #63676.

Yes, exactly.

As a newbie I’m probably missing something here, but doesn’t the “for each” construct do this? From the wiki:


For Each
’For each’ can be used to iterate over anything that implements the IEnumerable interface. ‘For each’ uses this syntax:

for each el: String in mylist do

for each matching el: String in mylist do

for each el in mylist do

for el in mylist do
In the first two cases the variable is typed, if it’s not typed the type is inferred from the IEnumerable (it will fail if it can’t). The matching keyword will only execute the loop for values that really are of that type, so it will skip any non-strings. In the last case the ‘each’ keyword is left out, which is optional. The ‘for each’ is skipped completely if the value after in is nil.

Does this differ from what the OP is asking for?

It is not exactly the same, what you describe is the Microsoft Com way to do it.

To use “For in” a regular Delphi tlist-derived class it needs to implement a method “GetEnumerator” that returns a tListenumerator.

Ah, thanks! I enjoy learning new stuff. Having said that, won’t the Oxygene way deliver the same objectives?