Delphi 7 Professional and probably other
versions:
With a project open, choose
Project
Options
Compiler Messages
Check boxes X Show
Hints X Show Warnings
Then a list of about 50 warnings, with check
boxes,
that the user can turn on/off. (There could
be more.)
Surely much better than an endless
philosophical
disputation on what warnings should/should not be
given:
Let the user choose -- caveat emptor.
Prof. Harley Flanders
----- Original Message -----
Sent: Friday, September 24, 2004 9:53 AM
Subject: Re: Unused parameter warnings
On 24 Sep 2004 at 6:27, CBFalconer wrote:
[....]
>
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.
May I suggest another approach? Both Delphi and
FreePascal have
"warnings" and "hints". Warnings are for serious things that
can hide
bugs, while hints are for less serious things. Can we assign some
of
these things to "hints", and then have a switch to turn hinting on and
off?
Example;
This program;
program
warn;
function bar : integer;
begin
writeln
('bar');
end;
procedure foo (x, y : integer);
begin
y :=
bar;
writeln (y);
y := 0;
end;
var
x :
integer;
y : byte;
begin
x := 1234;
writeln (y);
end.
Generates this, when compiled with
Delphi:
E:\temp\warn.pas(6) Warning: Return value of function 'bar' might be
undefined
E:\temp\warn.pas(12) Hint: Value assigned to 'y' never
used
E:\temp\warn.pas(20) Hint: Value assigned to 'x' never
used
E:\temp\warn.pas(21) Warning: Variable 'y' might not have been
initialized
And generates this, when compiled with
FPC:
warn.pas(6,1) Warning: Function result does not seem to be
set
warn.pas(8,16) Hint: Parameter X not used
warn.pas(21,15) Warning:
Variable Y does not seem to be initialized
warn.pas(8,11) Hint: Local proc
FOO is not used
warn.pas(16,1) Note: Local variable X is assigned but never
used
Best regards, The Chief
--------
Prof. Abimbola A. Olowofoyeku
(The African Chief)
web: http://www.greatchief.plus.com/