upvrar in namespace

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

upvrar in namespace

Post by caesar »

Why can't use upvar on a variable that is defined outside the proc that is in a namespace?

I tried something like:

Code: Select all

namespace eval blah {
	set foo 1
	proc moo {x} {
		upvar #0 $x var
		puts $var
	}
}
and other ways but all fail. From what I read a upvar #0 should be the equivalent of a global call but that fails as well, meaning the var variable isn't created.

If I take the code outside the namespace then it's working as expected. What am I doing wrong?
Once the game is over, the king and the pawn go back in the same box.
Post Reply