Posted to tcl by mjanssen at Thu Oct 26 11:19:49 GMT 2006view raw

  1. namespace eval debug {
  2. namespace export breakpoint
  3.  
  4. proc on {} [namespace code {proc breakpoint {{s {}}} {
  5. puts on
  6.  
  7. }
  8. }]
  9.  
  10. proc off {} [namespace code {proc breakpoint {args} {}}]
  11. off
  12. }
  13.  
  14.  
  15. namespace import ::debug::*
  16.  
  17. proc test {a} {
  18. puts [info body breakpoint]
  19. puts [info args breakpoint]
  20. breakpoint $a
  21. }
  22.  
  23. debug::on
  24. test 1
  25. test 2
  26.  
  27. # no output, if proc off is changed to:
  28. # proc off {} [namespace code {proc breakpoint {args} {return}}
  29. # the body actually gets called

Comments

Posted by dkf at Thu Oct 26 12:18:10 GMT 2006 [text] [code]

% namespace eval debug { namespace export breakpoint proc on {} {proc breakpoint {{s {}}} {puts on}} proc off {} {proc breakpoint args {}} off } % namespace import debug::* % debug::on % proc test a {puts "[info body breakpoint] - [info args breakpoint]"; breakpoint $a} % test 1 puts on - s % test 2 puts on - s % namespace import -force debug::* % test 1 puts on - s on % debug::off % test 1 - args % debug::on % test 1 puts on - s on % test 1 puts on - s on % debug::off % namespace import -force debug::* % test 1 - args

Posted by dkf at Thu Oct 26 12:19:01 GMT 2006 [text] [code]

Stranger and stranger: % namespace eval debug { namespace export breakpoint proc on {} {proc breakpoint {{s {}}} {puts on}} proc off {} {proc breakpoint args {}} off } % namespace import debug::* % debug::on % proc test a {puts "[info body breakpoint] - [info args breakpoint]"; breakpoint $a} % test 1 puts on - s % test 2 puts on - s % namespace import -force debug::* % test 1 puts on - s on % debug::off % test 1 - args % debug::on % test 1 puts on - s on % test 1 puts on - s on % debug::off % namespace import -force debug::* % test 1 - args