[Lazarus] Hints usability (was: Re: Large program size - 1.8 MB for empty GUI project)

JoshyFun joshyfun at gmail.com
Fri Apr 10 17:19:25 CEST 2009


Hello Christian,

Friday, April 10, 2009, 1:20:43 AM, you wrote:

CI> That's really 2 statements:
CI> A) There should be a way to tell the compiler that the hint is expected
CI> Well, I can't see why this is a given. By definition, hints are things
CI> that _can_ be potentially dangerous, but it's impossible to determine
CI> for sure. Warnings point out things which are always potentially dangerous.

As warnings are usually bad practice maybe they can be isolated with a
simple {$WANINGS OFF}{$WARNINGS ON} and they are quite rare in a
program.

But now hints are being too verbose, almost anybody initializes a
string because by definition is is being initialized to '' (nil) and
it is garanteed, so why add some code to reset it to the expected
value :-?

In other words MY (capital, as it is my problem, maybe not the problem
of other people) is that the amount of expected hints are hidding the
non-expected ones.

>> In my case for the "Parameter not used" I'm using a heavily overloaded
>> procedure "UseParameter" which does nothing and my code is clear of
>> this kind of hints. The problem is that I must updated the
>> "UseParameter" each time I use a new parameter type.
CI> I'm not sure what you mean? Can you give a small example?

unitparameters.pas
------------------
{$HINTS OFF}
procedure UseParameter(const A: integer); overload;
begin
end;

procedure UseParameter(const A: String); overload;
begin
end;

procedure UseParameter(const A: TObject); overload;
begin
end;

{$HINTS ON}

OtherUnit.pas
-------------
uses ...,unitparameter;

procedure ClickPos(Sender: TObject; X,Y: integer);
begin
  UseParameter(Sender);
  UseParameter(X);
  UseParameter(Y);
  Beep;
end;

This "technique" keeps my code more or less clean of expected non-used
parameter hints, and when releasing program I perform a search and
replace for "UseParameter" -> "//UseParameter".

Maybe an array of variants could be used to simplify, but then
variants come in play and I do not like them if I can code without ;)

-- 
Best regards,
 JoshyFun




More information about the Lazarus mailing list