[fpc-devel] type classes
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Oct 21 14:34:10 CEST 2007
On Sun, 21 Oct 2007 14:10:37 +0200
Peter Vreman <peter at freepascal.org> wrote:
> At 14:03 21-10-2007, you wrote:
> >On Sun, 21 Oct 2007 13:46:57 +0200
> >Florian Klaempfl <florian at freepascal.org> wrote:
> >
> > > Mattias Gaertner schrieb:
> > > > Is it possible to use TTranslateStrings = type TStrings?
> > > > I ask because, the compiler allows it, but stops later with only
> > > > this message:
> > > > lcl/interfaces/gtk2/interfaces.pas(1,1) Fatal: Compilation
> > > > aborted
> > > >
> > > > Question:
> > > > Is it allowed to use
> > > > NewClass = type SomeClass;
> > > > ?
> > >
> > > In theory yes, in pratice it seems to be buggy :)
> >
> >Thanks for the quick response.
>
> Also delphi handles things strange. The following code is from
> webtbf/tw3930a.pp. The code looks correct, but delphi fails with
> "Incompatible types: 'TMyStringList' and 'TStringList'". That makes
> typed classes not very usefull unless you override all constructors.
>
>
> uses
> Classes;
>
> type
> TMyStringList = type TStringlist;
>
> var
> list : TMyStringList;
>
> begin
> list:=TMyStringList.Create;
> end.
It might sound strange, but this 'incompatible types' is good.
I need it only for RTTI. A TMyStringList will never be created.
Basically I need
type
TTranslateStringsText = type TStrings;
TMyComponent = class(TPersistent)
...
published
property Items: TTranslateStringsText read ... write ...;
end;
The implementation will always use TStrings, not TTranslateStringsText.
Only the RTTI information should show TTranslateStringsText.
Especially this must work:
Items:=TStringList.Create;
BTW, I don't know what other sense is in 'type someclass'. Maybe
Borland thought the same.
Mattias
More information about the fpc-devel
mailing list