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;

Comments

  1. 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.

    TFormHelper2 = class helper(TFormHelper1) for TForm

    ReplyDelete
  2. oh for .net extension methods........

    ReplyDelete
  3. David Heffernan ... which still don't support properties (;

    ReplyDelete
  4. Jeroen 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.

    Also Jon explains a possible risk of extension properties in the comment to his answer here: http://stackoverflow.com/a/619047/587106

    ReplyDelete
  5. 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

Post a Comment