[Pas2js] Verbose Code

warleyalex warleyalex at yahoo.com.br
Thu Sep 5 19:43:21 CEST 2019


one trick is to define an fake external class that descends from the
TJSObject, there's no need to have a constructor. 

type
  TFunc = reference to function: Double;

  TCircle = class external name 'Object' (TJSObject)
    radius: Integer;
    area: TFunc;
  end;

(..)
var
  circ : TCircle;

begin
  circ := TCircle.new;
  circ.radius:= 10;
  circ.area := function(): Double
  begin
    Result := PI * circ.radius * circ.radius;
  end;




--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list