Posted to tcl by colin at Sat Mar 03 00:36:17 GMT 2007view raw

  1. package require extend
  2.  
  3. package provide namespace 1.0
  4.  
  5. # Extra useful namespace commands
  6.  
  7. extend namespace {
  8. # return a flattened namespace hierarchy containing all
  9. # descendents of the given namespace
  10. proc tree {namespace} {
  11. set result {}
  12. foreach ns [namespace children $namespace] {
  13. lappend result $ns
  14. lappend result {*}[tree $namespace]
  15. }
  16. return $result
  17. }
  18. }
  19.