Posted to tcl by aspect at Wed Feb 12 05:29:06 GMT 2020view raw
- set ::result ""
- proc ok {result} {
- set ::result $result
- tailcall return 1
- }
- proc notok {result} {
- set ::result $result
- tailcall return 0
- }
- proc res {} {
- return $::result
- }
- proc q {} {
- notok "I can't do that Dave"
- }
- proc z {} {
- ok "I like that, please do it again"
- }
- proc a {} {
- if {![q]} {
- notok [res]
- }
- puts "doing other stuff"
- ok "done"
- }
- if {[a]} {
- puts "success! result is [res]"
- } else {
- puts "failure! result is [res]"
- }