compiler option to require the callsites of var and out parameters to be declared as such.
Original Reporter info from Mantis: Thorsten Engler
-
Reporter name: Thorsten Engler
Original Reporter info from Mantis: Thorsten Engler
- Reporter name: Thorsten Engler
Description:
program VarOutTest;
procedure Test(a: Integer; const b:Integer; var c:Integer; out d: Integer);
begin
c := a;
d := b;
end;
var
c, d: Integer;
begin
Test(1,2, var c, out d);
end;
On one hand this forces the caller to be more aware of the contract of the called routine. From reading the source it now becomes obvious which calls have side effects on passed in parameters.
On the other hand it protects well against silent contract changes (like turning a param from normal or const into var or out).
Could also be used for overload resolution (but I don't think it's a good idea to have 2 overloaded versions that just differ in one param being out or const...)
Mantis conversion info:
- Mantis ID: 8217
- Version: 2.2.0