[fpc-devel] Suggestion: reference counted objects

Boian Mitov mitov at mitov.com
Wed Sep 24 04:14:53 CEST 2014


Actually the Delphi compatible code would be :

procedure TApp.Create(Sender: TObject);
begin
  MyButton.SetOnClick(
    procedure 
    begin
      Alert('Button clicked');
    end );
end;

There is no comas in the procedure declaration.
We have even created multicast anonymous methods in Mitov.Runtime so you can add more than one anonymous methods to an event.

procedure TApp.Create(Sender: TObject);
begin
  MyButton.OnClick.Add(
    procedure 
    begin
      Alert('Button clicked and called me');
    end )
  .Add( 
    procedure 
    begin
      Alert('Button clicked and called me too');
    end );
end;

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------

From: Dmitry Boyarintsev 
Sent: Tuesday, September 23, 2014 7:00 PM
To: FPC developers' list 
Subject: Re: [fpc-devel] Suggestion: reference counted objects

About productive code. Should it look like this (note "Test" name is removed from procedure declaration)?

procedure TApp.Create(Sender: TObject);
begin
  MyButton.SetOnClick(procedure; begin
      Alert('Button clicked');
  end);
end;

thanks,
Dmitry


--------------------------------------------------------------------------------
_______________________________________________
fpc-devel maillist  -  fpc-devel at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140923/635ac181/attachment.html>


More information about the fpc-devel mailing list