Here is a code example:
set my_ref {$undefined_array(some_key)}
set my_val [subst $my_ref]
which returns:
can't read "undefined_array(some_key)": no such variable
while executing
"subst $my_ref"
According to http://wiki.tcl.tk/1501
Looks like there is no way to catch this right now
When
subst
attempts to perform substitutions on the text you gave it, it needs an existing variable with a matching name. If no such variable exists,subst
throws aTCL LOOKUP VARNAME
exception.How to catch that? You can catch the exception after
subst
has failed as usual, withcatch
ortry
. The discussion you referred to was AFAICT about catching exceptions beforesubst
has failed, which I believe still isn't possible.ETA:
Proof-of-concept for my "discriminating try" comment. This code has tons of potential problems but at least demonstrates basically how it could be done. In the example, the handler reacts by creating a variable that has its own name in uppercase as value.