Smart pascal source code
type
TRect = record
Left, Right: Integer;
function Width: Integer;
begin
Result := Right - Left;
end;
end;
function P_Copy(R: TRect): Integer;
begin
Result := R.Width;
end;
function P_Const(const R: TRect): Integer;
begin
Result := R.Width;
end;
function P_Var(var R: TRect): Integer;
begin
Result := R.Width;
end;
procedure Test_Copy_Const;
var R: TRect;
Begin
R.Left := 0;
R.Right := 64;
WriteLn(P_Copy(R));
WriteLn(P_Const(R));
End;
procedure Test_Copy_Var;
var R: TRect;
Begin
R.Left := 0;
R.Right := 48;
WriteLn(P_Copy(R));
WriteLn(P_Var(R));
End;
procedure Test_Const_Var;
var R: TRect;
Begin
R.Left := 0;
R.Right := 24;
WriteLn(P_Const(R));
WriteLn(P_Var(R));
End;
Test_Copy_Const;
Test_Copy_Var;
Test_Const_Var;
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
64
64
48
48
24
24
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
function Copy$TRect(s,d) {
d.Left=s.Left;
d.Right=s.Right;
return d;
}
function Clone$TRect($) {
return {
Left:$.Left,
Right:$.Right
}
}
function TRect$Width(Self$1) {
return Self$1.Right-Self$1.Left;
}
function Test_Copy_Var() {
var R = {Left:0,Right:0};
R.Left = 0;
R.Right = 48;
WriteLn(P_Copy(Clone$TRect(R)));
WriteLn(P_Var(R));
};
function Test_Copy_Const() {
var R$1 = {Left:0,Right:0};
R$1.Left = 0;
R$1.Right = 64;
WriteLn(P_Copy(Clone$TRect(R$1)));
WriteLn(P_Const(R$1));
};
function Test_Const_Var() {
var R$2 = {Left:0,Right:0};
R$2.Left = 0;
R$2.Right = 24;
WriteLn(P_Const(R$2));
WriteLn(P_Var(R$2));
};
function P_Var(R$3) {
return TRect$Width(R$3);
};
function P_Copy(R$4) {
return TRect$Width(R$4);
};
function P_Const(R$5) {
return TRect$Width(R$5);
};
/* <<< main JS >>> */
Test_Copy_Const();
Test_Copy_Var();
Test_Const_Var();