Question: in what cases do these two info commands differ?
set a 1 set b [info exists a]and
set c [info vars a]The doc for info exists indicates that the variable exists and has a value in either the current or global space.Certainly, one potential problem is if the variable has any pattern characters in it.Are there other differences between the two?MG May 18th - [info exists varName] will return 1 if a variable named varName exists, and 0 if it doesn't. [info vars varName] returns a list of all the variables which match the pattern varName. For instance...
1 % set var1 bleh bleh 2 % set var2 bleh bleh 3 % set var3 bleh bleh 4 % info exists var1 1 5 % info exists var4 0 6 % info vars var1 var1 7 % info vars var4 8 % info exists var* 0 9 % info vars var* var1 var2 var3CHL July 18th - There is a difference when the variable exists and has no value. In that case [info exist varName] will return 0 whereas [info vars varName] will return a list containing varName. For instance...
1 % namespace eval nspace { variable novalue } 2 % info exists nspace::novalue 0 3 % info vars nspace::novalue nspace::novalue
See also: