Version 1 of TclIndex

Updated 2002-03-21 15:52:33

[Explain pkgIndex.tcl (one of the magic names), package, ...]

[Mention pertinence to "How to change a running system"?]

Be careful not to be confused by the title. Files named tclIndex are special to the Tcl auto-loader, powered by the unknown command.

Files named pkgIndex.tcl are special to tclPkgUnknown, the command registered by default with [package unknown].

The two mechanisms are different, though they (unfortunately) share the global variable $::auto_path.


If you're building a library of tcl scripts, you should consider using utilizing one of Tcl's auto-loading mechanisms.

If you put a bunch of library scripts in a directory (or set of relative directories), you can use the auto_mkindex command (documented on Tcl's library manual page) to generate a special index file named tclIndex. This index file contains references to all the procedures defined in all the files.

You can then modify your application's auto_path variable to include this new library directory. The auto-loading mechanism will scan the index, and when you call one of the indexed procedures, it will know where to find it. No 'source' commands required.