Created
November 10, 2014 10:01
-
-
Save muspellsson/8883c02c8551810bfaaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc invariant {var {expression ""} {msg "Illegal value"}} { | |
uplevel trace variable $var w \ | |
\[list invariant_check \{$expression\} \{$msg\}] | |
} | |
proc invariant_check {expression msg v1 v2 mode} { | |
if {$expression == ""} { | |
error "Cannot modify!" | |
} | |
if {![uplevel expr \{$expression\}]} { | |
error $msg | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment