Hello,
Using gpc to compile (some parts of) Borland's objects unit, I noticed this (so far):
1) References to an incomplete type are not accepted. In the code below, CopyFrom uses a variable S of type TStream, while TStream is not yet finished:
type PStream = ^TStream; TStream = object(TObject) Status: Integer; ErrorInfo: Integer; constructor Init; procedure CopyFrom(var S: TStream; Count: Longint); ...
BP accepts this, gpc barfs: "type name expected, identifier `Tstream' given"
2) Something simular appens in the implementation part:
procedure TStream.Error(Code, Info: Integer); type TErrorProc = procedure(var S: TStream); begin Status := Code; ErrorInfo := Info; if StreamError <> nil then TErrorProc(StreamError)(Self); end;
This results in an error:
objects.pas: In function `Tstream_Error': objects.pas:141: `object' type definition only allowed at top level objects.pas:141: parse error before `Procedure' objects.pas:142: pointer domain type `Terrorproc' undefined objects.pas:145: undeclared identifier `Terrorproc' (first use this function) objects.pas:145: (Each undeclared identifier is reported only once objects.pas:145: for each function it appears in.) objects.pas:145: parse error before `(' objects.pas:145: missing semicolon objects.pas:145: missing semicolon
3) Obviously, `self' is treated different too...
All of this with the latest-but-one alpha release, in BP mode with extended syntax.
BTW: of course, what I was trying out, was how much trouble it would be to port TVision to GPC. Seems we have a long way to go....
Greetings, JanJaap