Info exists is indeed an elegant way of encoding the "I was there" bit
out of band, rather than in-band. There are several benefits:
- no risk of value collision (being out of band)
- code maintainability (no double enumeration of vars: init vs.
runtime)
- generality: can also be used (typically with arrays) with an
unbounded number of vars/keys
Even if you're worried by a possible performance implication, you
should not: both "if {$x}" and "if {[info exists x]}" get dedicated
bytecode instructions (loadScalar and existsScalar), and the remaining
delta is very small because "existsScalar" has a side-effect of
storing the parsedVar in the internal representation, so the hashtable
lookup penalty is paid for just once.
In short: go for [info exists] :)
-Alex