Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you list all the namespaces in an instance of TCL?

How do you list all the namespaces loaded in an instance of tclsh?

Chenz

like image 583
Crazy Chenz Avatar asked Oct 18 '25 16:10

Crazy Chenz


1 Answers

Try running this proc from the TCLer's Wiki

    proc listns {{parentns ::}} {
        set result [list]
        foreach ns [namespace children $parentns] {
                eval lappend result [listns $ns]
                lappend result $ns
        }
        return $result
    }

When I run it, I get the following output:

% listns
::platform ::activestate::teapot::link ::activestate::teapot ::activestate ::tcl
::clock ::tcl::info ::tcl::dict ::tcl::tm ::tcl::mathop ::tcl::unsupported ::tcl
::mathfunc ::tcl::chan ::tcl::string ::tcl
%

So, to get ALL namespaces, you simply need to do this:

set all_namespaces [concat [listns] "::"]
like image 171
TrojanName Avatar answered Oct 22 '25 06:10

TrojanName



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!