The problem being it is not possible to have {collection} methods
returning an object that isn't declared?
FItems = TMySet(TMyClass);
FItems2 = TMySet(TStringList);
FItems.Add.SomeProp := 'something'; // want both of these
FItems2.Add.Strings[1] := 'Heh'; // but can't have them
However isn't the problem a syntax rather than OO issue?
ie isn't :
> with TMyClass(FItems.Add) do
already returning an object of TMyClass but Delphi/OP is saying :
"Well if you want to use this as a TMyClass, you can
bloody well write it down: its Your problem" in the spirit of
"well you can have a variable, but you must declare that you really
want one".
So the problem is with the pedantic syntax of Delphi/OP
or is it deeper than that?
Cheers.
Neven MacEwan wrote:
>
> Kurt
>
> > You want the type of the object to be included in the type of the
> > collection?
>
> That is what the current TCollection does
>
> >
> > am I right to think you want this:
> > TMySet = set of (TMyClass);
> >
> > MySet : TMySet;
> > MyOtherClass : TMyOtherClass;
> >
> > ...
> >
> > MySet.Add( MyOtherClass); // Error Here!!
> >
>
> more
>
> var
> FItems: TSetof(TMyClass)
>
> with FItems.Add do
> try
> // assign properties to an object of TMyClass
> finally
> end;
>
> And it is not possible without Type Casting (which is what TList does)
>
> with TMyClass(FItems.Add) do
> try
> // assign properties to an object of TMyClass
> finally
> end;
>
> ttfn
>
> ---------------------------------------------------------------------------
> 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"
---------------------------------------------------------------------------
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"