Smart pascal source code
type
TTest = record
Field: Integer;
class function Sum(const a, b: TTest): TTest; overload;
class function Sum(const a: TTest; i: Integer): TTest; overload;
class function Create(i: Integer): TTest; static;
end;
class function TTest.Sum(const a, b: TTest): TTest;
begin
Result.Field := a.Field + b.Field;
end;
class function TTest.Sum(const a: TTest; i: Integer): TTest;
begin
Result := Sum(a, TTest.Create(i));
end;
class function TTest.Create(i: Integer): TTest;
begin
Result.Field := i;
end;
var r := TTest.Sum(TTest.Create(10), 2);
WriteLn(r.Field);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
12
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
function Copy$TTest(s,d) {
d.Field=s.Field;
return d;
}
function Clone$TTest($) {
return {
Field:$.Field
}
}
function Sum$1(a, b) {
var Result = {Field:0};
Result.Field = a.Field+b.Field;
return Result
}
function Sum(a$1, i) {
return Sum$1(a$1,Create$3(i));
}
function Create$3(i$1) {
var Result = {Field:0};
Result.Field = i$1;
return Result
}
var r = {Field:0};
/* <<< main JS >>> */
r = Sum(Create$3(10),2);
WriteLn(r.Field);