Posted to tcl by Setok at Mon Nov 07 12:46:56 GMT 2022view pretty
proc typedVar {var assert} { uplevel [list trace add variable $var write [list apply {{expr var key op} { set val [uplevel set $var] if $expr { } else { error "Variable value does not match spec" } }} $assert]] } # Example: typedVar b {[string is integer]}; set b 242; set b "front"