Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-16 Thread Adriaan van Os via fpc-pascal
Sven Barth via fpc-pascal wrote: "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. " "is nested" means that the actual function passed can be either global or local

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-16 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mi., 16. Feb. 2022, 07:59: > > > > On Feb 16, 2022, at 2:46 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > // nested function/procedure/routine variable > > type > > TFoobarNested = function: LongInt is nested; > > > > var

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mi., 16. Feb. 2022, 03:14: > > > > On Feb 15, 2022, at 11:09 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > For a global function the compiler has to generate a wrapper that gets > rid of the Self parameter of the interface.

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 16, 2022, at 12:18 AM, Thomas Kurz via fpc-pascal > wrote: > > What release are anonymous functions planed for? FPC 3.4.0? They aren't even in trunk yet. Could be months or years. Regards, Ryan Joseph ___ fpc-pascal maillist - f

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 11:09 PM, Sven Barth via fpc-pascal > wrote: > > For a global function the compiler has to generate a wrapper that gets rid of > the Self parameter of the interface. > The compiler generates this interface at compile time right? And then when the scope of the calling

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 16, 2022, at 2:46 AM, Sven Barth via fpc-pascal > wrote: > > // nested function/procedure/routine variable > type > TFoobarNested = function: LongInt is nested; > > var >f: TFoobarFuncRef; > begin > // anonymous function/procedure/routine > f := function: LongInt >

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Am 15.02.2022 um 15:05 schrieb Ryan Joseph via fpc-pascal: On Feb 15, 2022, at 8:26 PM, Sven Barth via fpc-pascal 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 hard

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Thomas Kurz via fpc-pascal
> The "Reference to procedure" that will be part of anonymous functionswill do > this for you. What release are anonymous functions planed for? FPC 3.4.0? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Di., 15. Feb. 2022, 15:02: > > > > On Feb 15, 2022, at 8:32 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > A function reference is simply an interface of which the Invoke method > can be called on the instance instead of man

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Michael Van Canneyt via fpc-pascal schrieb am Di., 15. Feb. 2022, 15:29: > > > 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@lists.freepascal.org> wrote: > >> > >> It's relatively "easy" to implement ass

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Michael Van Canneyt via fpc-pascal
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 wrote: It's relatively "easy" to implement assigning a nested function to function references. However assign

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Michael Van Canneyt via fpc-pascal
On Tue, 15 Feb 2022, Ryan Joseph via fpc-pascal wrote: On Feb 15, 2022, at 8:26 PM, Sven Barth via fpc-pascal 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 hard

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 8:26 PM, Sven Barth via fpc-pascal > 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

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 8:32 PM, Sven Barth via fpc-pascal > wrote: > > A function reference is simply an interface of which the Invoke method can be > called on the instance instead of manually doing "Foo.Invoke". > > The real "magic" is when the compiler generates the *implementation* of sai

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Di., 15. Feb. 2022, 13:14: > > > > On Feb 15, 2022, at 5:15 PM, Sven Barth > wrote: > > > > It contains a capture object that backs the method. > > If nothing is captured and the right hand side is a direct function or > method pointer then the compiler coul

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Di., 15. Feb. 2022, 13:06: > > > > On Feb 15, 2022, at 3:32 PM, Michael Van Canneyt via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > I requested that this: > > > > procedure TMyObject.Demo; > > > > Procedure DoSub; > > begin > >Writeln

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Di., 15. Feb. 2022, 13:16: > > > > On Feb 15, 2022, at 7:10 PM, Michael Van Canneyt > wrote: > > > > In Delphi it is not. In FPC it should be :-) > > Indeed should be but that's what I'm trying to figure out with how this is > implemented. > > Why wouldn't D

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 7:10 PM, Michael Van Canneyt > wrote: > > In Delphi it is not. In FPC it should be :-) Indeed should be but that's what I'm trying to figure out with how this is implemented. Why wouldn't Delphi be able to do this I wonder. The calling mechanism in this object is not

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 5:15 PM, Sven Barth wrote: > > It contains a capture object that backs the method. > If nothing is captured and the right hand side is a direct function or method > pointer then the compiler could in principle create something that is > essentially static to avoid alloc

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Michael Van Canneyt via fpc-pascal
On Tue, 15 Feb 2022, Ryan Joseph via fpc-pascal wrote: On Feb 15, 2022, at 3:32 PM, Michael Van Canneyt via fpc-pascal wrote: I requested that this: procedure TMyObject.Demo; Procedure DoSub; begin Writeln('Sub'); end; begin DoTest(DoSub); end; So that means "reference to pro

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 3:32 PM, Michael Van Canneyt via fpc-pascal > wrote: > > I requested that this: > > procedure TMyObject.Demo; > > Procedure DoSub; > begin >Writeln('Sub'); > end; > > begin > DoTest(DoSub); > end; So that means "reference to procedure" is not compatible with "

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Di., 15. Feb. 2022, 08:34: > > > > On Feb 15, 2022, at 2:09 PM, Michael Van Canneyt via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > I've answered this question before: > > > > The "Reference to procedure" that will be part of anonymous > fu

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Michael Van Canneyt via fpc-pascal
On Tue, 15 Feb 2022, Ryan Joseph via fpc-pascal wrote: On Feb 15, 2022, at 2:09 PM, Michael Van Canneyt via fpc-pascal wrote: I've answered this question before: The "Reference to procedure" that will be part of anonymous functionswill do this for you. I'm sorry I forgot! This thing

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-14 Thread Ryan Joseph via fpc-pascal
> On Feb 15, 2022, at 2:09 PM, Michael Van Canneyt via fpc-pascal > wrote: > > I've answered this question before: > > The "Reference to procedure" that will be part of anonymous functionswill do > this for you. I'm sorry I forgot! This thing keeps coming up for me and driving me nuts but I

Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-14 Thread Michael Van Canneyt via fpc-pascal
On Tue, 15 Feb 2022, Ryan Joseph via fpc-pascal wrote: This has been a constant problem for me with FPC and wanted to make a formal post with code examples since I've only mentioned it in passing before. How can it be achieved to have a caller agnostic procedure variables? I've tried making

[fpc-pascal] Caller agnostic procedure variables

2022-02-14 Thread Ryan Joseph via fpc-pascal
This has been a constant problem for me with FPC and wanted to make a formal post with code examples since I've only mentioned it in passing before. How can it be achieved to have a caller agnostic procedure variables? I've tried making some big crazy dispatch record that uses generics but becau