Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c54f49a28eba81f3fc6fc4fdac9fdf732d4fd011
Ticket: 3480599fffffffffffffffffffffffffffffffff
pkg_mkIndex should generate deterministic pkgIndex.tcl order
User & Date: dgp on 2012-01-28 00:35:04
Changes

  1. icomment:
    My best advice is "Don't Do That".
    
    If your package is contained in multiple
    files for some reason, it's far better to make
    only one of them the master file to be [source]d to
    provide the package.  To bring the contents of
    the other files in, you can do something as simple
    as a [source] of them from the master file.  Or
    you can set up in the master file for the auto-loading
    of the other files as their contents are required.
    This is best done with your own loading-stubs of
    those commands, but you can also build on Tcl's
    tclIndex scheme if you prefer.  An example is the
    package "control" in tcllib.
    
    If you really do have a package made up of parts with
    order dependence, you really have no choice but to
    take one of those steps.  Even if pkg_mkIndex produced
    a deterministic order, there's no reason to believe it will
    pick the order needed by your code.
    
    If you have a package made up of parts that depend
    less on an explicit order, but on interdependency constraints,
    it may be that you actually have code that would be better
    represented as multiple packages, instead of one, using
    [package] to manage the dependency constraints.  In that situation,
    my preference is to install each package into its own directory with
    its own pkgIndex.tcl file.
    
    Once you've reduced the provide script of your package
    to the [source] of a single file, the contents of your
    pkgIndex.tcl likely are near as simple as:
    
    package ifneeded foo 1.0 [list source [file join $dir master.tcl]]
    
    At that point, my advice is not to use [pkg_mkIndex] at all.
    You can either hand-edit, or generate via much simpler tools.
    [pkg_mkIndex] is simply too ambitious and complex, and tries
    to take on problems that are simply unsolvable.  It's best abandoned.
    
    Another issue you might consider is that if your build is set up
    so that pkgIndex.tcl is a generated file, it arguably should not
    be checked into your version control system.
    
    
  2. login: "dgp"
  3. mimetype: "text/plain"
  4. username: "dgp"