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.