Loading packages in your Tcl program
Archive - Originally posted on "The Horse's Mouth" - 2015-10-09 12:14:10 - Graham EllisIn Tcl, extra bundles of code can be loaded from packages which are files of more ... brought in with package require from a folder that's listed in the auto_path variable.
Packages are defined with a package provide in the source code of the package which must be indexed in a file called pkgIndex.tcl. Failure to index will result in Tcl failing to find the package. There's a built in Tcl command called pkg_mkIndex which allows you to generate the index automatically.
Namespaces are technically different to packages, but it'c common practise to define a package in a Tcl namespace to avoid any risk of conflicting names of procedures, and to make it clearer for the maintenance programmer later on to know what's loaded from where.
Example of a program that loads packages - [here]. The packages it loads are [here] (without a namespace and [here] for one with a namespace