I am having some problems understanding the use of uplevel in TCL. I am reading Brent Welch's Practical programming in TCL and Tk and there is an example in uplevel that I cannot understand. Here it is:
proc lassign {valueList args} {
if {[llength $args] == 0} {
error "wrong # args:lassign list varname ?varname...?"
}
if {[llength $valueList] == 0} {
#Ensure one trip through the foreach loop
set valueList [List {}]
}
uplevel 1 [list foreach $args $valueList {break}]
return [lrange $valueList [llength $args] end]
}
Can someone please explain it to me? The explanation in the book does not help me enough :(
uplevel #1
with coroutines. This was considered to be the first practical use ever for that particular form, even though it has been legal for decades. – Radack