Sujet : Re: Array get element with default (no error if not exist)
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.lang.tclDate : 18. Aug 2024, 17:43:41
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9t8bt$2euft$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
RodionGork <
rodiongork@github.com> wrote:
Thank you, this definitely makes sense!
I remember about issue with passing/returning array in functions. By the
way I still am not sure why it works with global for example... if they
are actually different variables, every key-pair :) e.g. like here:
https://github.com/RodionGork/languages-benchmark/blob/main/02-primes/primes_a.tcl#L7
Because the [global] command works with names of variables, not the
actual variables. It links the global variable with the given name, to
a local variable of the same name, inside the proc. If the global name
references an array, then the new local name inside the proc references
the same array.