Deutsch   English   Français   Italiano  
<v9t8bt$2euft$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Rich <rich@example.invalid>
Newsgroups: comp.lang.tcl
Subject: Re: Array get element with default (no error if not exist)
Date: Sun, 18 Aug 2024 16:43:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <v9t8bt$2euft$1@dont-email.me>
References: <962f50d6039d29a1bcdd98d8931988a3@www.novabbs.com> <ygao75szvb2.fsf@akutech.de> <850513f1dcb6a0714bffa99c137f69f9@www.novabbs.com> <v9qiej$1vbpg$1@dont-email.me> <a41ab7e0d5109e5d55f5cce6a8069813@www.novabbs.com>
Injection-Date: Sun, 18 Aug 2024 18:43:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="27a8b87db7433b5fa1dd735d9d0e6b28";
	logging-data="2587133"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Puax/xCEEw78HnKCaQ6Qn"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:197VsDzE5mpmNHr2PCiWQAzhpP0=
Bytes: 1758

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.