Let's take a look at this function:
procedure TestConcatenation;
var
r1 : TRec;
begin
r1 := r1 + 65;
end;
The compiler actually implements it like this:
procedure TestConcatenation;
var
r1 : TRec;
tmp : TRec;
begin
tmp := r1 + 65;
r1 := tmp;
end;
The compiler introduces a temporary local to store the result of r1 + 65
. There's a very good reason for that. If it did not, where would it write the result of your addition operator? Since the ultimate destination is r1
, if your addition operator writes directly to r1
it is modifying its input variable.
There is no way to stop the compiler generating this temporary local.