Peter Schorn wrote:
Dear all,
while porting from CodeWarrior Object Pascal to GPC I noticed the following differences which might be worthwhile to address in GPC.
1) Mutual recursive object type declaration program prog1; { compile with gpc --mac-pascal prog1.pas } type t1 = object function f: t2; { error: unknown identifier `t2' } { above works in CodeWarrior Object Pascal as objects are always references } end;
t2 = object function g: t1; end;
function t1.f: t2; begin f := nil; end; function t2.g: t1; begin g := nil; end; begin end.
As a workaround this can be solved by introducing a common super class and subsequent casting.
The object can be declared forward (also see the mailing list archives) {$mac-objects} program prog1; type t2 = object; forward; t1 = object function f: t2; end; t2 = object function g: t1; end; function t1.f: t2; begin f := nil; end; function t2.g: t1; begin g := nil; end; begin end. Regards, Adriaan van Os