Search code examples
namespacestclintrospectionproc

find all procs of a namespace in Tcl


let us say that I have a namespace. I want to find all of the namespace procs. For example, let us say that I have this code:

namespace eval foo { 
   proc me {} { puts "yey!" }
   proc moo {} { puts "ney!" }
}
puts [ getAllNamespaceProcs foo ] ; # getAllNamespaceProcs is what I do not know how to do

This should yield:

> { me moo }

Thanks.


Solution

  • The info procs command can be told what namespace to look in:

    info procs ::foo::*
    

    This will yield ::foo::me ::foo::moo (or the other way round; lsort it if you care) and you can filter that (e.g., with lmap and namespace tail) if you want to get the result that you mention.