Yes, the reasoning is as in your first example. Perhaps this explains it a bit further:
Simba Code:
procedure setVal(var Self: Int32; NewVal: Int32);
begin
WriteLn('Regular proc: ', @Self);
end;
procedure Int32.setVal(NewVal: Int32);
begin
WriteLn('Type proc: ', @Self);
end;
procedure test(const a: Int32); overload;
begin
//setVal(a, 123); <-- Will not compile: "Variable expected"
a.setVal(456); // <-- Will pass "nil" for self, because a is constant/immutable
end;
procedure test(const a: ^Int32); overload;
begin
setVal(a^, 123); // <-- Dereference is always writable, so can pass as variable
a^.setVal(456); // <-- Dereference is always writable, so can pass as variable
end;
var
i: Int32 = 1;
begin
test(i);
test(@i);
end;
I would like to make "a.setVal(456)" give a compiler error too, but currently that would interfere with code like "WriteLn(@Int32.setVal)" if executed in the above example.