[fpc-pascal] Caller agnostic procedure variables
Michael Van Canneyt
michael at freepascal.org
Tue Feb 15 15:23:45 CET 2022
On Tue, 15 Feb 2022, Michael Van Canneyt via fpc-pascal wrote:
>
>
> On Tue, 15 Feb 2022, Ryan Joseph via fpc-pascal wrote:
>
>>
>>
>>> On Feb 15, 2022, at 8:26 PM, Sven Barth via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
>>>
>>> It's relatively "easy" to implement assigning a nested function to
> function references. However assigning a nested function variable to a
> function reference is much harder.
>>> Assigning a function reference to a nested function variable is hard as
> well.
>>>
>>
>> I'm getting lost with the terms now I think.
>> If your function takes a function reference parameter and you assign it a
> nested function pointer,
>> this is difficult? I believe this was Michaels request in that code
> snippet.
>
> Sven will need to confirm, but as I understand it:
>
> Procedure DoDemo(aTest : TProc);
For clarity, this should be something like:
Procedure DoDemo(aTest : TProc);
begin
// Do stuff
aTest;
end;
So the below procedures are not local to DoDemo...
Michael.
>
> Procedure MyTest;
>
> Procedure DoSub;
> begin
> end;
>
> begin
> DoDemo(DoSub)
> end;
>
> is easy.
>
> but
>
> Procedure DoDemo(aTest : TProc);
>
> Procedure MyTest;
>
> Var
> ASub : procedure is nested;
>
> begin
> aSub:=SomeFunctionThatReturnsANestedProc;
> DoDemo(aSub);
> end;
>
> is difficult.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list