[fpc-pascal] Function reference doesn't capture in thread

Hairy Pixels genericptr at gmail.com
Sun Sep 18 03:02:55 CEST 2022

> On Sep 17, 2022, at 10:51 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
> Complain to the developers of Delphi then.
> I do however plan to extend anonymous (and nested) functions with a syntax that allows to select whether a variable should be by-reference or by-value. But that's still a bit off, cause I have other things to do first.

Yes that’s a very good idea and gives us more control (C++ and Swift allow explicit capture groups for example). In this example though would it even matter? The idea of capturing a loop iterator before the loops runs doesn't make sense to me. Maybe it should even be illegal or give a warning since it’s so error prone.

Speaking of that the Extended RTTI branch I did is over a year old I think now. Probably no chance of merging that without serious work. Michael got the RTL stuff done and tested everything but I’ve nearly forgotten about it since and I don’t know where it really stands. Hopefully that can be merged before it gets even more stale and decrepit. :)

>>> And they are not pointers, but the variable is moved to an object instance which implements the interface of the function reference.
>> “Moved to an object” makes me think the variable is copied but the reference behavior you describe sounds like a pointer so I’m still not 100% clear on what you mean.
> Let's take your initial example and adjust it so that i will really be captured:

Yeah I get this now. I was just being dumb with threads. The capturing isn’t even the most of my problems here.

	Ryan Joseph

More information about the fpc-pascal mailing list