What a strange limitation, isn't it ?
What a strange limitation, isn't it ?
type
TFormHelper1 = class helper for TForm
procedure Hello1;
end;
TFormHelper2 = class helper for TForm
procedure Hello2;
end;
procedure TFormHelper1.Hello1;
begin
ShowMessage('Hello1 : ' + Caption);
end;
procedure TFormHelper2.Hello2;
begin
ShowMessage('Hello2 : ' + Caption);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Hello1; // not defined !
Hello2;
end;
type
TFormHelper1 = class helper for TForm
procedure Hello1;
end;
TFormHelper2 = class helper for TForm
procedure Hello2;
end;
procedure TFormHelper1.Hello1;
begin
ShowMessage('Hello1 : ' + Caption);
end;
procedure TFormHelper2.Hello2;
begin
ShowMessage('Hello2 : ' + Caption);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Hello1; // not defined !
Hello2;
end;
Helpers are like Highlander - there can only be one. And yes, stupid limitation. But in case of a class helper you can at least inherit them.
ReplyDeleteTFormHelper2 = class helper(TFormHelper1) for TForm
oh for .net extension methods........
ReplyDeleteDavid Heffernan ... which still don't support properties (;
ReplyDeleteJeroen Wiert Pluimers Which is why they are called extension methods, right? And in the case of a helper or extension which cannot add any fields a property is just syntax sugar for a Getter/Setter call.
ReplyDeleteAlso Jon explains a possible risk of extension properties in the comment to his answer here: http://stackoverflow.com/a/619047/587106
Stefan Glienke it is. Hence the smiley. BTW: Which comment by Jon do you mean? The one about them being able to do more than one thing? Any method could do that.
ReplyDelete