[fpc-pascal] assigning a local function to a var
Joao Morais
post at joaomorais.com.br
Thu Jul 10 21:33:46 CEST 2008
David Emerson wrote:
> Joao: creating a named type isn't a solution, as it only moves the
> problem of declaration into the "type" section, where the very same
> problem persists. Thanks for responding, though.
Did you test? I did and it works.
==========
function func_a(pass_str: ansistring): boolean;
begin
writeln(pass_str, ' A');
func_a := true;
end;
function func_b(pass_str: ansistring): boolean;
begin
writeln(pass_str, ' B');
func_b := false;
end;
type
tmy_fnc = function(pass_str: ansistring): boolean;
var
my_fnc: tmy_fnc;
begin
my_fnc := @func_a;
my_fnc('hello');
end.
==========
Joao Morais
More information about the fpc-pascal
mailing list