Ryan Joseph via fpc-pascal <[email protected]> schrieb am Mi., 16. Feb. 2022, 07:59:
> > > > On Feb 16, 2022, at 2:46 AM, Sven Barth via fpc-pascal < > [email protected]> wrote: > > > > // nested function/procedure/routine variable > > type > > TFoobarNested = function: LongInt is nested; > > > > var > > f: TFoobarFuncRef; > > begin > > // anonymous function/procedure/routine > > f := function: LongInt > > begin > > end; > > end; > > "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. " > > This means if you expanded your example with: > > var > n: TFoobarNested; > begin > f := n; > > THAT would be hard? I've never passed around nested function vars before > so I don't really know the limitations of this. The important thing is the > primary use case works. > Correct. In addition to that the general assumption for function references is that they can be called even after the function they were assigned to has been left. For a nested function itself this can hold true as well (cause the compiler simply needs to transform the nested function correctly when generating the implementation for the capture object), but for a nested function variable this assumption would be wrong. Regards, Sven >
_______________________________________________ fpc-pascal maillist - [email protected] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
