It's not that simple: a package in Tcl looks more abstract than in Python.
Firstly, there are two types of packages: “classic” and “modules” , which have different basic mechanisms for finding what to load in response to the package require ...
command.
Then both types of packages can do whatever they want to ensure their functionality. This means that they can (but not limited to):
- Pure Tcl,
source
'packages are just one Tcl file or any number of files. - Packages implemented in C or another compiled language, which are in the form of a dynamic library that receives
load
ed when a package is required. - The combination above when there is a C library and a Tcl code layer (usually providing helper / convenience commands).
Therefore, the question in itself has little meaning, since only the modules are represented by exactly one stand-alone file, but the “classic” packages are free to implement on their own.
On the other hand, each package usually provides (using one or another) certain information in the package subsystem, which can be restored (and analyzed) using the package ifneeded
. For example, on my Windows system with ActiveState Tcl 8.5.x, I have:
% 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}
Note that what package ifneeded
returns is just a Tcl script that must be eval
uated to load the package, so parsing this information is inevitably inherent ad-hoc and fragile.
source share