🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.tcl
Article #132

Re: Speed and Memory with upvar

#132
From: Harald Oehlmann
Date: Thu, 19 Nov 2026 18:05
34 lines
2119 bytes
Am 19.11.2026 um 16:42 schrieb meshparts:
> I'm thinking about the differences between two methods of passing a list 
> to a procedure:
> 
> First one is classical:
> 
> proc myproc1 {l} {}
> set l [list 1 2 3]
> myproc1 $l
> 
> Second one uses upvar:
> 
> proc myproc2 {lname} {upvar $lname l}
> set l [list 1 2 3]
> myproc2 l
> 
> My tests show that first one is faster than second one. At least for 
> lists of thousends of elements.
> 
> Does the second method also has advantages regarding the memory 
> consuption or are the two methods identical from this point of view?
> 
> Thanks
> Alex

I think the main difference is the intention:
In the first case, the proc may not modify  list l in the caller space
In the second case, it is intentional, that callers variable l is modified.

So, the moment the list is modified by myproc1/2, solution 1 does create 
a copy of the list.


Technical Details
Message-ID: <11dndok$2gcm5$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11dn5cd$4ibt$1@tota-refugium.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Harald Oehlmann <wortkarg3@yahoo.com>
Newsgroups: comp.lang.tcl
Subject: Re: Speed and Memory with upvar
Date: Thu, 19 Nov 2026 19:05:08 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <11dndok$2gcm5$1@dont-email.me>
References: <11dn5cd$4ibt$1@tota-refugium.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 19 Nov 2026 18:05:09 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2634437"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18SYqYOuTUVcR/T3gapXIwf"; posting-host="13f10ea2cb416d2b06c3d52f152141bd"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Es4wwPmdgv9EJ68cI/SUfqpao54= sha256:9igEQ9425OZ9vIslVq+N2t9oUlWz42tnfPdOZUtNb6Q=
	sha1:NXdxWKMZlX4Xc7VVo1fQvKGR2FM= sha256:MPUV6vhEx5tsn+m5tJl/vMq1hzV+e4EqkBRmMeeDSnQ=
Content-Language: en-GB
In-Reply-To: <11dn5cd$4ibt$1@tota-refugium.de>