GPS Oct 16, 2003 - Today it occurred to me that I might accidentally set the wrong variable in my Perpheon language translator, and it could cause me to have a nasty debug session, so I decided to come up with a proc that sets a variable but returns an error if it doesn't exist.
proc ?set {vPtr val} { upvar $vPtr v if {![info exists v]} { return -code error "error: variable doesn't exist." } set v $val }
Here is a log demonstrating usage:
% ?set foo bar error: variable doesn't exist. % set foo abc abc % ?set foo bar bar % set foo bar %