Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> 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 > functionswill do this for you. > > I'm sorry I forgot! This thing keeps coming up for me and driving me nuts > but I knew I asked in passing before. > > So "reference to procedure" are going to be the new standard? To extend my > example it would look like this? I please remind me, is there a closure > involved which is capturing state and adding overhead? > 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 allocations, but that would be a future optimization. > I'm curious what this type actually is also, maybe a dispatch table which > wraps the existing types or is it something totally new? > A function reference is essentially a reference counted interface with a single method named "Invoke". And before you ask: no, we're not going to add yet another type that combines all four when a function reference does that perfectly well already even if it might be more expensive (note: it's not the call that is that much more expensive, but the creation). Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal