Posted to tcl by mjanssen at Thu Oct 26 11:19:49 GMT 2006view raw
- namespace eval debug {
- namespace export breakpoint
- proc on {} [namespace code {proc breakpoint {{s {}}} {
- puts on
- }
- }]
- proc off {} [namespace code {proc breakpoint {args} {}}]
- off
- }
- namespace import ::debug::*
- proc test {a} {
- puts [info body breakpoint]
- puts [info args breakpoint]
- breakpoint $a
- }
- debug::on
- test 1
- test 2
- # no output, if proc off is changed to:
- # proc off {} [namespace code {proc breakpoint {args} {return}}
- # 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