@Marco
"VAR" is a token for read/write. If for some reason you want to change semantics for warnings for some minor cases, that is the way to go.
var is to tell the compiler that the variable should be passed by reference.
However did you come by that idea? , it is read/write calling convention semantics.
I came to that idea when reading a Pascal standards report written by "some guy" who goes by the name of Niklaus Wirth. On page 72 of his report he writes:
In program 11.2 none of the values in array g are altered; i.e.
g is not a result. Consequently g could have been defined as a
value parameter without affecting the end result. To understand
why this was not done. it is helpful to look at the
implementation.
A procedure call allocates a new area for each value parameter;
this represents the local variable. The current value of the
actual parameter is "copied" into this location; exit from the
procedure simply releases this storage.
If a parameter is not used to transfer a result of the
procedure, a value parameter is generally preferred. The
referencing is then quicker, and one is protected against
mistakenly altering the data. However in the case where a
parameter is of a structured type (e.g. an array), one should be
cautious, for the copying operation is relatively expensive, and
the amount of storage needed to allocate the copy may be large.
Because referencing of each element in the array occurs only
once, it is desirable to define the parameter as a variable
parameter.
That seems to be clear. var may be used just for performance reasons and avoid potential memory problems. IOW, there is
no implication whatsoever as to what the use of a
var is going to be. The only thing it tells the compiler is that the variable will be passed by reference and
absolutely nothing about whether the variable is only read, only written or read and written.
That's where I got that "idea".
Yes, the a warnings-only directive is micromanaging. But even more so is inventing new syntax for it.
To be precise (which is a necessary characteristic when writing compilers), there is no new syntax. There would be a new keyword which would syntactically take the place of "var", "out" and/or "constref" depending on how the programmer intends to use the variable.
That keyword would provide information to the compiler to allow it to flag potential problems it cannot identify without it.
I can't help but wonder how you allowed the "constref" and "out" "inventions". Those two things are as useless as "inout" since, according to you, var already does everything they do.