Hi,
I was reviewing some old code that used TCollection & TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem?

Mailing lists / fpc-pascal / 2011-11
10 messages · 6 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
I was reviewing some old code that used TCollection & TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem?
Graeme Geldenhuys wroteI was reviewing some old code that used TCollection & TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem?
At the very least, backward compatibility with existing code. We even still ship a Turbo Pascal-compatible "objects" unit.
Jonas
I was reviewing some old code that used TCollection & TCollectionItem descendants. This…
I have tons of code that uses them. Lazarus has tons of code that uses them. There is no way that we're going to rewrite all that stuff.
So: yes, even if only for backwards compatibility.
Nothing stops people from not using it, and use generics instead, if they are so inclined.
Michael.
I have tons of code that uses them. Lazarus has tons of code that uses them. There is no way that we're going to rewrite all that stuff.
Sorry for any confusion. I did not post this with the intention of removing TCollection/TCollectionItem classes from FPC. I'm simply asking from a functionality point of view. Can Generics replace the usage of TCollection/TCollectionItem in all cases? Purely from a functionality point of view, it seems like it should be possible - but I know nothing of Generics (never used them).
I know Lazarus IDE uses TCollection in many property editors. Could Generics even replace those use cases too? I guess this might be better asked in the Lazarus mailing list.
At the very least, backward compatibility with existing code. We even still ship a Turbo…
Jonas Maebe > wroteAt the very least, backward compatibility with existing code. We even still ship a Turbo Pascal-compatible "objects" unit.
Please see my reply to Michael. I had no intentions in recommending the removal of TCollection. I'm just comparing functionality of Generics with TCollection.
Sorry for any confusion. I did not post this with the intention of removing…
You should see it differently: there is a generics collection which performs the same function as TCollection/TCollectionitem.
The difference is mainly that in the case of TCollection(Item) you need to override the items property; With generics, you can skip this step. At the expense of copying the whole TCollection code each time you create a specialized descendent.
Michael.
It's also possible to create a generic descendent of TCollection, where the only duplicated code is the property override. This is probably the best of both worlds: reusing the TCollection while moving to generics. Best regards
Thierry
----- Mail Original -----
De: "michael vancanneyt"
À: "FPC-Pascal users discussions"
Envoyé: Mardi 8 Novembre 2011 13h22:31 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [fpc-pascal] Generics vs TCollection
...
The difference is mainly that in the case of TCollection(Item) you need to override the items property; With generics, you can skip this step. At the expense of copying the whole TCollection code each time you create a specialized descendent.
Michael.
Sorry for any confusion. I did not post this with the intention of removing…
In my experience generics are very good, but they are not without problems. There are some limitations in the implementation and I have already hit some bumps in the road when using them (search the mailling list, I don't remember exactly the issues)
But I can't compare them to collections, because I never use them except in the LCL parts that use them, my favorites are TFPList, and the generic equivalent (TFPGList or something like that).
It's also possible to create a generic descendent of TCollection, where the only…
tcoq wroteIt's also possible to create a generic descendent of TCollection, where the only duplicated code is the property override. This is probably the best of both worlds: reusing the TCollection while moving to generics.
Hm. I fail to see this: Where is the gain in that ?
Michael.
Michael Van Canneyt wroteHm. I fail to see this: Where is the gain in that ?
+1