[a100] fat arrow modifying dynamic var in outer scope Topic is solved

Discuss the future of the AutoHotkey language
sirksel
Posts: 42
Joined: 12 Nov 2013, 23:48

[a100] fat arrow modifying dynamic var in outer scope

15 Nov 2018, 21:20

Is there a limitation on fat arrow, which would not allow a function like (val, cnt) => var%cnt% := val to modify var1 ... var9, which are byref variables in the enclosing scope?

I've been trying to debug code, and have had success assigning to an outer scope array with identical code, so I'm guessing it's a known limitation. Correct? (Sorry if I overlooked it in the documentation.)
Last edited by sirksel on 16 Nov 2018, 06:32, edited 1 time in total.
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a100] fat arrow modifying byref var in outer scope  Topic is solved

16 Nov 2018, 03:18

nested functions wrote:Dynamic variable references inside a nested function can resolve to variables from the outer function only if the nested function (or one of its own nested functions) also contains a non-dynamic reference to the variable.
Byref or not doesn't matter.
sirksel
Posts: 42
Joined: 12 Nov 2013, 23:48

Re: [a100] fat arrow modifying dynamic var in outer scope

16 Nov 2018, 06:39

That answers it perfectly, Helgef. I modified my thread title from "byref var" to "dynamic var" to make it more on-point with the real issue (dynamic, not byref) -- as you've helped me understand. Thanks.
Helgef
Posts: 3303
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a100] fat arrow modifying dynamic var in outer scope

16 Nov 2018, 06:44

Some more comments can be found :arrow: here.

Cheers.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 4 guests