As far as I understand, in tcl if you want to pass a named array to a function, you have to access the upper scope of the caller via the upvar
command within th
As Michael indicated, there are several ways, plus a wiki page that discusses it. Just to have some of that information here, some options are:
By Upvar
proc by_upvar {&arrName} {
upvar 1 ${&arrName} arr
puts arr(mykey)
set arr(myotherkey) 2
}
set myarr(mykey) 1
by_upvar myarr
info exists myarr(myotherkey) => true
By array get/set
proc by_getset {agv} {
array set arr $agv
puts arr(mykey)
set arr(myotherkey) 2
return [array get arr]
}
set myarr(mykey) 1
array set mynewarr [by_upvar myarr]
info exists myarr(myotherkey) => false
info exists mynewarr(myotherkey) => true