Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Constructor without Visibility Declaration
Wed, Feb 8 2017 7:25 AMPermanent Link

Michael Dreher

Running the following in a browser...

var
  Form1: TForm1;

implementation

type
 TCircle = class
   x, y, radius : double;
   constructor Create; override;
 end;

constructor TCircle.Create;
begin
end;

procedure TForm1.Form1Create(Sender: TObject);
var c : TCircle;
begin           
 c := TCircle.Create;
end;

end.

...will result in a JS runtime error "Error: Persistent load error (unit1_tcircle.$p.tcircle_create is undefined)".
OK, it's my fault. I forgot to declare the TCircle constructor public. But the compiler did not report an error (Version 2.05B4, 2.06B1).

Michael Dreher
Wed, Feb 8 2017 2:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< ...will result in a JS runtime error "Error: Persistent load error (unit1_tcircle.$p.tcircle_create is undefined)".
OK, it's my fault. I forgot to declare the TCircle constructor public. But the compiler did not report an error (Version 2.05B4, 2.06B1). >>

Got it, thanks.  I think it's a confusion between the "design public" scope and the "public" scope.  The compiler does some special things for declarations in the "design public" scope, which is the default scope for classes that don't have a scope specified.

Tim Young
Elevate Software
www.elevatesoft.com
Image