Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's not that simple: a package in Tcl appears to be a more abstract thing than that in Python.</p> <p>First, there are two kinds of packages: "classic" and <a href="http://wiki.tcl.tk/12999" rel="noreferrer">"modules"</a> which have different underlying mechanisms for finding what to load in response to the <code>package require ...</code> command.</p> <p>Next, both kinds of packages are able to do whatever they wish to provide their functionality. It means they can be (but not limited to):</p> <ul> <li>Pure Tcl packages, <code>source</code>'ing just one Tcl file or any number of files.</li> <li>Packages implemented in C or another compiled language, which are in the form of dynamic library which gets <code>load</code>ed when the package is required.</li> <li>A combination of the above, when there's a C library and a layer of Tcl code around it (usually providing helper/convenience commands).</li> </ul> <p>Hence the question per se has little sense as only <em>modules</em> are represented by exactly one self-contained file but "classic" packages are free to implement themselves as they see fit.</p> <p>On the other hand, each package normally provides (using one way or another) certain information to the package subsystem which can be retreived (and parsed) using the <code>package ifneeded</code> command. For instance, on my Windows system with ActiveState Tcl 8.5.x, I have:</p> <pre><code>% package require csv 0.7.2 % package ifneeded csv 0.7.2 package provide csv 0.7.2;source -encoding utf-8 {C:/Program Files/Tcl/lib/teapot/package/tcl/teapot/tcl8/8.3/csv-0.7.2.tm} </code></pre> <p>Note that what <code>package ifneeded</code> returns is just a <em>Tcl script</em> which is meant to be <code>eval</code>uated to get the package loaded, so parsing of this information is bound to be inherently ad-hoc and fragile.</p>
 

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