Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2011 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1519485 to your computer and use it in GitHub Desktop.
Save anonymous/1519485 to your computer and use it in GitHub Desktop.
lists are passed as values in TCL
#!/usr/bin/env tclsh
proc f {L} {
puts "f: before: L = $L"
lappend L 20
puts "f: after: L = $L"
}
proc g {_L} {
upvar ${_L} L
puts "g: before: L = $L"
lappend L 30
puts "g: after: L = $L"
}
set L {1 2 3}
puts "initial: L = $L"
lappend L 4
puts "after lappend: L = $L"
f $L
puts "after calling f: L = $L"
g L
puts "after calling g: L = $L"
$ ./list.tcl
initial: L = 1 2 3
after lappend: L = 1 2 3 4
f: before: L = 1 2 3 4
f: after: L = 1 2 3 4 20
after calling f: L = 1 2 3 4
g: before: L = 1 2 3 4
g: after: L = 1 2 3 4 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment