Sign in Join

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

Mailing lists / fpc-devel / 2007-10

type classes

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner

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;
?

Mattias

Reply by email

Florian Klaempfl
to Mattias Gaertner
Show quoted text 9 lines
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 :)

Reply by email

Florian Klaempfl
to Florian Klaempfl
Show quoted text 12 lines
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 :)

Reason is probably http://www.freepascal.org/mantis/view.php?id=8180

Reply by email

Mattias Gaertner
to Florian Klaempfl: In theory yes, in pratice it seems to be buggy :)
Show quoted text 12 lines
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.

Mattias

Reply by email

Peter Vreman
to Mattias Gaertner
you wrote 17 lines
On Sun, 21 Oct 2007 13:46:57 +0200 Florian Klaempfl 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.

Peter

Reply by email

Micha Nelissen
to Peter Vreman
Peter Vreman wrote
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.

Sounds like they define the result type of a constructor at constructor definition time. Strange then that inherited constructors do work ?

Micha

Reply by email

Mattias Gaertner
to Peter Vreman: Also delphi handles things strange. The following code is from webtbf/tw3930a.pp. The…
Show quoted text 38 lines
At 14:03 21-10-2007, you wrote: >On Sun, 21 Oct 2007 13:46:57 +0200 >Florian Klaempfl 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

Reply by email