Posted to tcl by aspect at Wed Feb 12 05:29:06 GMT 2020view raw

  1. set ::result ""
  2.  
  3. proc ok {result} {
  4. set ::result $result
  5. tailcall return 1
  6. }
  7.  
  8. proc notok {result} {
  9. set ::result $result
  10. tailcall return 0
  11. }
  12.  
  13. proc res {} {
  14. return $::result
  15. }
  16.  
  17. proc q {} {
  18. notok "I can't do that Dave"
  19. }
  20.  
  21. proc z {} {
  22. ok "I like that, please do it again"
  23. }
  24.  
  25. proc a {} {
  26. if {![q]} {
  27. notok [res]
  28. }
  29. puts "doing other stuff"
  30. ok "done"
  31. }
  32.  
  33. if {[a]} {
  34. puts "success! result is [res]"
  35. } else {
  36. puts "failure! result is [res]"
  37. }
  38.