Re: [fpc-pascal] Creating capturers

2023-11-05 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Sa., 4. Nov. 2023, 15:48: > > > > On Nov 4, 2023, at 4:22 PM, Sven Barth > wrote: > > > > Then don't assign them every "frame". If you just keep them around then > they aren't more expensive than a virtual method call. > > And any other mechanism would involve the heap as

Re: [fpc-pascal] Creating capturers

2023-11-04 Thread Hairy Pixels via fpc-pascal
> On Nov 4, 2023, at 4:22 PM, Sven Barth wrote: > > Then don't assign them every "frame". If you just keep them around then they > aren't more expensive than a virtual method call. > And any other mechanism would involve the heap as well, because that's how > anonymous functions that capture

Re: [fpc-pascal] Creating capturers

2023-11-04 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Sa., 4. Nov. 2023, 01:42: > > > > On Nov 3, 2023, at 8:31 PM, Sven Barth > wrote: > > > > If you need a catch all type, then you should use function references. > There is no need to invent yet another type. > > The only thing it can not handle is the assignment of nested

Re: [fpc-pascal] Creating capturers

2023-11-03 Thread Hairy Pixels via fpc-pascal
> On Nov 3, 2023, at 8:31 PM, Sven Barth wrote: > > If you need a catch all type, then you should use function references. There > is no need to invent yet another type. > The only thing it can not handle is the assignment of nested function > pointers (in contrast to nested functions directl

Re: [fpc-pascal] Creating capturers

2023-11-03 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Fr., 3. Nov. 2023, 12:37: > > > > On Nov 3, 2023, at 2:08 PM, Sven Barth > wrote: > > > > By default the purpose of anonymous functions assigned to function > references *is* that they can escape their scope. This will not change, > because they were after all introduced

Re: [fpc-pascal] Creating capturers

2023-11-03 Thread Hairy Pixels via fpc-pascal
> On Nov 3, 2023, at 2:08 PM, Sven Barth wrote: > > By default the purpose of anonymous functions assigned to function references > *is* that they can escape their scope. This will not change, because they > were after all introduced for Delphi-compatibility and there won't be any > designat

Re: [fpc-pascal] Creating capturers

2023-11-03 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Fr., 3. Nov. 2023, 02:00: > > > > On Nov 2, 2023, at 1:44 PM, Sven Barth > wrote: > > > > Now for nested as well as anonymous routines the compiler determines > whether a capturer is required at the point that the nested or anonymous > routine is assigned to a function re

Re: [fpc-pascal] Creating capturers

2023-11-02 Thread Hairy Pixels via fpc-pascal
> On Nov 2, 2023, at 1:44 PM, Sven Barth wrote: > > Now for nested as well as anonymous routines the compiler determines whether > a capturer is required at the point that the nested or anonymous routine is > assigned to a function reference (cause otherwise it can be handled as a > nested f

Re: [fpc-pascal] Creating capturers

2023-11-02 Thread Hairy Pixels via fpc-pascal
> On Nov 2, 2023, at 1:44 PM, Sven Barth wrote: > > The most important piece of knowledge is that in a routine with nested (or > anonymous) routines the nested (or anonymous) routines aren't compiled down > to machine code right away. The compiler first parses the whole hierarchy > until it'

Re: [fpc-pascal] Creating capturers

2023-11-01 Thread Sven Barth via fpc-pascal
Am 01.11.2023 um 06:18 schrieb Hairy Pixels via fpc-pascal: I'm curious how the capturer is created in the case of anonymous functions. I know the function needs to create a capturer when nested functions are declared but what happens if there is an anonymous function which is declared in the

[fpc-pascal] Creating capturers

2023-10-31 Thread Hairy Pixels via fpc-pascal
I'm curious how the capturer is created in the case of anonymous functions. I know the function needs to create a capturer when nested functions are declared but what happens if there is an anonymous function which is declared in the code section? I think the compiler will only know about the r