Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That's not how Tcl's namespaces work. Each procedure is associated with exactly one namespace, which is the one in which its name is located. When you use <code>namespace import</code>, an alias to the procedure is placed in the importing namespace that allows the procedure to be invoked from that other namespace, but the procedure itself remains in its original namespace and executes in that one.</p> <p>If you want to know the caller's namespace, use <code>uplevel namespace current</code> (or <code>uplevel 1 {namespace current}</code> for a slightly windier but more efficient version). This doesn't actually tell you what namespace contained the command that was used to invoke the procedure though; for that, you need this monstrosity (in the invoked command):</p> <pre><code>namespace qualifiers [uplevel 1 [list namespace which [lindex [info level 0] 0]]] </code></pre> <p>Of course, if you're needing that a lot then you're probably doing something wrong. (That's obvious, given the length and complexity of code required to get the information.)</p> <p>In particular, if you're pretending to do object orientation with this, please stop and use a real object system that gets all the tricky details right. Tcl 8.6.0 includes <a href="http://www.tcl.tk/man/tcl8.6/TclCmd/class.htm" rel="nofollow">one</a> (<a href="http://www.tcl.tk/man/tcl8.6/ItclCmd/contents.htm" rel="nofollow">two</a>, if you've got the contributed extensions), and there are many for older versions available as extension packages.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload