Mike Mueller wrote:
>
> SetOf is a solution for this particular case of wanting to have a general
> purpose 'list' class that can be used for any kind of 'item' class. What
> about a general solution that would be something like the C++ "template"
> classes
>
> TListTemplate<itemclass> = class
> ...defined just like a collection but use <itemclass> instead of TObject
>
> then
> Items : TListTemplate<myclassthatIwantacollectionof>
It still seems that you want to go to a lot of trouble for the sake of
not having to typecast. But typecasting is good : imagine being the 5th
developer on the sub-project where you suddenly come across this :
(at 11:30 Sunday night, project due Monday morning etc, etc)
proc. Foo (aItems : TList<TObject>);
...
// Now for my specially order TList<>
aItems[0].Text := 'a';
aItems[1].Text := 'b';
aItems[2].Name := 'c';
aItems[3].Parent := Form1;
ShowMessage(IntToStr(aItems[4].Total));
MyExcelOLEObject := aItems[5].SubItem;
...
And compare it to this:
// should use "As" but not unimportant to this eg.
proc. Bar (aItems : TList);
...
// Now for my specially ordered TList
TEditBox(aItems[0]).Text := 'a';
TStringList(aItems[1]).Text := 'b';
TQuickRep(aItems[2]).Name := 'c';
TBitBtn(aItems[3]).Parent := Form1;
with aItems[4] as TChartValueList do
ShowMessage(Total);
MyExcelOLEObject := ExcelOLEObject(TMyExcelObj(aItems[5]).SubItem);
...
Certainly this is extreme, but reasonably similar examples could be
done for any Class hierarchy, and once you have had several people
working on it over several years, a lot of class hierarchys end up
looking worse. (1/3 of the developers like ToString, 1/3 like AsString,
1/3 like a descriptive property name like "name"... ;-)
> will expand out a definition of TListTemplate for that particular class.
>
> I guess this looks like a macro which means preprocessing & more than one
> pass to compile ... Mind you, macros wouldn't be so bad to have really
> would they?
>
> And while we're at it, another thing that would help would be 'inner
> classes' like in Java, then you could achieve your customized TList using
[...]
> end);
>
> What are they putting in Delphi 6? Futuristic things like this or is it
> just another set of bug fixes?
>
Inner classes futuristic?
Aren't they just a kludge because C programmers can't handle closures
;-)
(Or Sun won't trust C programmers to handle them... ;-)
> Mike
>
[...]
> > >
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"