[Richard Suchenwirth] 2006-02-07 - For doing some OO sugar, I needed a way that [interp alias]es are cleaned up when the proc scope where they were defined is left. Here's my solution with a guard variable, to which an unset [trace] is tied: proc alias {name = args} { upvar 1 __$name __$name eval [list interp alias {} $name {}] $args set __$name "" trace var __$name u "interp alias {} $name {} ;#" } proc test {} { alias up = string toupper return [up hello],[up world] } 146 % test HELLO,WORLD 277 % up this invalid command name "up" ---- [NEM] cautions though that the scope of aliases aren't really proc local, e.g.: % proc test2 {} { alias up = string toupper return [test],[up more] } % test2 invalid command name "up" ---- [RS] Right. I should better have said "short-lived". But in my use case, accidentally reusing a name is less of a concern - it will be unambiguous handles to objects, for the popular $obj method arg arg... style. My worry was that the alias table would run full, if 10,000s of such were created every hour... ---- [Category Development]