[fpc-devel] c-blocks (darwin aarch64)

Ondrej Pokorny lazarus at kluug.net
Mon Apr 18 10:30:04 CEST 2016


On 18.04.2016 10:18, Jonas Maebe wrote:
> Delphi does not support assigning procedures to variables representing 
> anonymous functions

It does. Both for procedure of object and plain procedure:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
   System.SysUtils;

type
   TRefProc = reference to procedure;

   TMyObj = class(TObject)
   public
     procedure Test2;
   end;

   procedure Test;
   begin
     Writeln('hello');
     Readln;
   end;

{ TMyObj }

procedure TMyObj.Test2;
begin
   Writeln('hello2');
   Readln;
end;

var
   xR: TRefProc;
   xO: TMyObj;
begin
   xR := Test;
   xR();

   xR := xO.Test2;
   xR();
end.

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160418/bf48f3dc/attachment.html>


More information about the fpc-devel mailing list