It's not quite right. Depending on the record it might indeed work like an out-parameter (or more precisely a var-parameter) and then the code would work; e.g. a record that contains a managed type will be passed like this, while others will use a copy.
Are you sure that isn't misleading too?
Or I am overlooking something, and it might be considered a severe side effect....
Afaik, implementation detail, some result param are var param. But, they always get a temp var passed from the caller. So you don't have a reference to the callers var.
Which from a users point of view makes it an out param.
Otherwise, If I am assigning the returned result to a global var, that global vars content could change, before the result is returned. And that afaik it should not (actually must not?)
At least below, the record is not behaving like a var param:
program Project1;
{$Mode objfpc}
type TFoo = record s, s2,s3,s4,s5: ansistring; end;
var a: tfoo;
function x: tfoo;
begin
Result.s := StringOfChar('a', 10+Random(2));
writeln( a.s); // Does write bbbb
end;
begin
a.s := StringOfChar('b', 2+Random(2));
a := x; // a is not passed as var param
end.
Even though, implementation wise it is, but with a temp var.
Of course there is a case were it can be observed. If peeking at uninitialized values. When calling "a:=x;" twice, the 2nd call will see the returned value of the 1st call.