if I can call r(a[k]) using recursion why I can't call r(v).
indicates that the function accepts a reference to a variable
is not a "variable" in the strict context of the documentation or implementation, and therefore not passed by reference.
[AHK_L 60+]: If something other than a modifiable variable is passed to a ByRef parameter, the function behaves as though the keyword "ByRef" is absent. For example, Swap(A_Index, i) stores the value of A_Index in i, but the value assigned to Left is discarded once the Swap function returns.
is essentially an element in an array of key-value pairs, where any element could be moved or the entire array could be freed/reallocated at any time. The only safe way to refer to it is to have a reference to the object and a copy of the key (or keys:
is also valid). The current "variable reference" or "ByRef" mechanism simply isn't capable of this.
It appears I can't print a memory address of a[k] directly,
address-of operator has two functions:
[*:t66xbgb5]Retrieve the address of a variable's string buffer (see below).
[*:t66xbgb5]Retrieve the address of an object.
In the first case, only a plain "variable" reference is accepted. Since
is not a "variable" and does not contain an object,
will not work. If it contained a string, you could use
, but in this case it contains an integer. Like with the element itself (see above), the actual location in memory of this integer can change as other items are added or removed from the object, so retrieving its address is not supported.
I'm surprised that v and var_ak wouldn't be pointing to the same address.
Each variable has its own buffer for storing strings, and therefore an address which is unique to that variable (but can change). VarSetCapacity sets or retrieves the capacity of this buffer.