<$BlogRSDUrl$>

Tuesday, October 19, 2004

There are some things that Delphi shouldn't allow 

I just discovered today that it's possible to declare a method with parameters in the interface section of a class without needing to declare the parameters in the implementation section. For example, the following code compiles just fine in Delphi 5 :-


program Yuck;
{$APPTYPE CONSOLE}
type
TSomeClass = class(TObject)
public
procedure SomeProc(ASomeParam: string);
end;

procedure TSomeClass.SomeProc;
begin
WriteLn(ASomeParam);
end;

var
lSomeClass: TSomeClass;
begin
lSomeClass := TSomeClass.Create;
try
lSomeClass.SomeProc('This is just wrong');
finally
lSomeClass.Free;
end;
end.


I would hate to maintain code that uses this technique!




Comments: Post a Comment

This page is powered by Blogger. Isn't yours?