Version 4 of auto_path

Updated 2002-08-08 19:38:08

[...]

magic names

init.tcl sets auto_path as a global within an interpreter instance. As the distribution init.tcl for 8.3 says right at the top,

    # The values on the path come from several locations:
    #
    # The environment variable TCLLIBPATH
    #
    # tcl_library, which is the directory containing this init.tcl script.
    # tclInitScript.h searches around for the directory containing this
    # init.tcl and defines tcl_library to that location before sourcing it.
    #
    # The parent directory of tcl_library. Adding the parent
    # means that packages in peer directories will be found automatically.
    #
    # Also add the directory where the executable is located, plus ../lib
    # relative to that path.
    #
    # tcl_pkgPath, which is set by the platform-specific initialization routines
    #       On UNIX it is compiled in
    #       On Windows, it is not used
    #       On Macintosh it is "Tool Command Language" in the Extensions folder

Two points to emphasize from the above:

  • Notice the rather baroque mixture of platform-dependence, generation-time, and run-time assignments.
  • As is customary in idiomatic Tcl, "the directory where the executable is located" refers to tclsh (and so on), rather than, for example, my_script.tcl.

Edsger Dijkstra