On Mon, 23 Oct 2017 20:04:36 +0700
Ryan Joseph <r...@thealchemistguild.com> wrote:

> > On Oct 23, 2017, at 4:56 PM, Sven Barth via fpc-pascal 
> > <fpc-pascal@lists.freepascal.org> wrote:
> > 
> > What exactly are you trying? If the nested function accesses its outer 
> > scope then it definitely won't work. For that you'd need to wait for 
> > anonymous function support (which are planned - at least a far as I'm 
> > concerned - to also support nested functions). 
> >   
> 
> I cast DoThis to the type but the arguments are not correct not and a does 
> not equal 0.

program test1;

{$mode objfpc}{$H+}
{$ModeSwitch nestedprocvars}

type
  TCallback = procedure (a: integer) is nested;

procedure DoCallback;
  procedure DoThis(a: integer);
  begin
    writeln(a);
  end;
var
  callback: TCallback;
begin
  callback := @DoThis;
  callback(100);
end;

begin
  DoCallback;
end.

Keep in mind what Sven wrote. You cannot use "callback" outside of
DoCallBack, because FPC does not yet support Delphi's "reference to".

Mattias
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to