Add chaos to Tcl. Probably one of the most profound changes to the language ever. Currently [set] is untouched but hopefully that too can be chaosified. ====== ## Brings some quantum-like chaos to any Tcl program ## Author: Kristoffer Lawson, setok@setok.co ## Idea from Tiago Roberti Sampaio set ChaosFactor 0.5 set SchrodingerBody { ::chaos::if {rand() < $::ChaosFactor} { ::chaos::return } } proc chaosify {cmd} { rename $cmd ::chaos::$cmd proc $cmd {args} " $::SchrodingerBody ::chaos::uplevel \[::chaos::list ::chaos::$cmd \{*\}\$args\] " } foreach cmd [info commands] { if {$cmd ne "if" && $cmd ne "proc" && $cmd ne "rename" && $cmd ne "global" && $cmd ne "chaosify" && $cmd ne "set"} { chaosify $cmd } } rename if ::chaos::if proc if {args} " $::SchrodingerBody ::chaos::if \{*}\$args " rename global ::chaos::global proc global {args} " $::SchrodingerBody ::chaos::global \{*}\$args " rename rename ::chaos::rename proc rename {args} " $::SchrodingerBody ::chaos::rename \{*}\$args " ::chaos::rename proc ::chaos::proc ::chaos::proc proc {name arguments body} { set body $::SchrodingerBody$body ::chaos::proc $name $arguments $body } #chaosify puts set animal cat puts $animal puts $animal for {set i 0} {$i < 10} {incr i} { puts "The Internet is for $animal videos" } proc test {} { puts horse } test test test test test ====== <>[Radical Language Modification]