Adriaan van Os wrote:
Scott Moore wrote:
IP Pascal uses:
procedure dummy(x, y: integer); var a: integer; begin reference(x); reference(y) end;
Which is straightforward. Reference is a built-in that sets the variable as referenced.
Sorry, but I fiind it absurd to write actual code to get rid of an unwanted warning (even if the actual code translates into dummy code). Why do we want warnings anyway ? Well, if there are many warnings on every build or compile, that only irritates the programmer and the warnings will miss their purpose. So, the idea is to have software that eventually compiles without warnings. There are two valid ways to get rid of warnings. The programmer carefully inspects the program source that produces the warning and then decides:
(1) the compiler is right, the source is dangerous and should be changed, òr (2) the compiler warning is irrelevant (or wrong) in the specific context of a portion of the source code, the compiler should stop complaining there.
In the second case, we need fine control over warnings, that is, a compiler directive to put specific warnings off locally with {$local W no-xxx} ... {$endlocal} or whatever.
Now, to the case of unused parameters - they don't hurt, unused parameters won't crash software. But - apparently we missed an opportunity to eliminate the unused parameter to make the software faster (at least in theory). However, this leads to problems when the parameter list of a procedure or function can not be changed, as is the case with e.g. callback routines. For those routines, we can should be able to put the check off with {$local W no-unused-parameter} ... {$endlocal}.
This brings up the more general subject of the attitude to warnings. Pascal is not C. In C many, if not most, warnings indicate a serious situation where the probability of bad code is high, if not certain. Pascal has so many more internal checks that warnings tend to be just that, and the probability that the code does what is intended is much higher.
Thus the Pascal programmer should be prepared to evaluate and accept warnings on compilation. This attitude is probably not fatal, as it would be in C. In particular an unused parameter falls into this classification.