Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-09

for .. in documentation and classes based iterators.

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort

I did an initial patch to add for..in iterator support in fcl-stl ghashmap (https://bugs.freepascal.org/view.php?id=35940)

I've looked at the docs of for..in, and it doesn't seem to name the delphi getenumerator() method in its options. I assume it is equal to point 5, the enumerator operator, because a for..in this way doesn't cause a memory leak.

"5. Any type for which an enumerator operator is defined. The enumerator operator must return a structured type that implements the IEnumerator interface. The type of the control variable’s type must equal the type of the enumerator’s GetCurrent return value type."

but maybe that could be said more explicitly?

Reply by email

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 15 lines
I did an initial patch to add for..in iterator support in fcl-stl ghashmap (https://bugs.freepascal.org/view.php?id=35940) I've looked at the docs of for..in, and it doesn't seem to name the delphi getenumerator() method in its options. I assume it is equal to point 5, the enumerator operator, because a for..in this way doesn't cause a memory leak. "5. Any type for which an enumerator operator is defined. The enumerator operator must return a structured type that implements the IEnumerator interface. The type of the control variable’s type must equal the type of the enumerator’s GetCurrent return value type." but maybe that could be said more explicitly?

What should be said more explicitly ?

Michael.

Reply by email

Marco van de Voort
to Michael Van Canneyt

Op 2019-09-03 om 12:59 schreef Michael Van Canneyt:

Show quoted text 9 lines
> "5. Any type for which an enumerator operator is defined. The > enumerator operator must return a structured type that implements the > IEnumerator interface. The type of the control variable’s type must > equal the type of the enumerator’s GetCurrent return value type." > > but maybe that could be said more explicitly? What should be said more explicitly ?

What does the delphi duck typing method getenumerator():TIterator; do with the iterator if it is of a classtype (not interface)? Where does it fit in the 5 cases outlined in the documentation article? Probably 5, but that only talks about the enumerator operator.

Reply by email

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 15 lines
Op 2019-09-03 om 12:59 schreef Michael Van Canneyt: > >> "5. Any type for which an enumerator operator is defined. The >> enumerator operator must return a structured type that implements the >> IEnumerator interface. The type of the control variable’s type must >> equal the type of the enumerator’s GetCurrent return value type." >> >> but maybe that could be said more explicitly? > > What should be said more explicitly ? What does the delphi duck typing method getenumerator():TIterator; do with the iterator if it is of a classtype (not interface)? Where does it fit in the 5 cases outlined in the documentation article? Probably 5, but that only talks about the enumerator operator.

I will improve that before 3.2 is out.

Michael.

Reply by email