[fpc-pascal] "Is nested" vs "of object" compatibility with global functions

Hairy Pixels genericptr at gmail.com
Sun May 29 11:25:43 CEST 2022



> On May 29, 2022, at 2:26 PM, Martin Frb via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> Actually afaik you push an extra param in for "is nested" as well as for "of object.
> 
> But for "of object" it is the first param, for "is nested" it is the last.

So you can cast nested or object to each other and the compiler doesn’t complain the parameters have bad values so this confirms what you’re saying.

Anyways the lesson learned today playing with these is that we still shouldn’t just make all our function pointers “reference to” because each time you add one of these anonymous functions in a function it will add some setup code at runtime, even if it’s not called. If you’re doing something realtime the penalty will add up fast and be a real problem if you’re not careful.

Luckily anonymous functions are available on the other types so we can use those without incurring runtime penalties but we still can’t write caller-agnostic functions which have no runtime penalty and accept global, nested or object function pointers.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list