[fpc-devel] Suggestion for change: Overly strict check
Ales Katona
almindor at gmail.com
Mon Oct 2 11:46:09 CEST 2006
Having same function names as parameter names per se isn't a biggy but
the biggest problem is:
TFirst = class
protected
FFirst: Integer;
public
property First: Integer read FFirst write FFirst;
end;
TTest = class(TFirst)
FSomething: Integer;
public
procedure DoWithFirst(a, First: Integer);
end;
implementation
procedure TTest.DoWithFirst(a, First: Integer);
begin
First:=a; // ???
FSomething:=First; // ???
end;
Ofcourse the intention was setting FSomething to value of argument First
and setting FFirst to value of First. It CAN be achieved with "FFirst"
or "self.First" but it's just a stupid example of how easily you can
overlook things especialy if some parts are hidden in another unit
somewhere in an ancestor.
Also notice that in mode delphi there's not a single warning about this.
And believe me things like this CAN happen and will take you 3 days to
find out...
I name my arguments "aName" since this incident and not because
{$objfpc}...
PS: there are worse cases but I can't remember a better example now
Ales
More information about the fpc-devel
mailing list