1mNAME0m
       package - Facilities for package loading and version control

1mSYNOPSIS0m
       1mpackage forget ?4m22mpackage24m 4mpackage24m 4m...24m?
       1mpackage ifneeded 4m22mpackage24m 4mversion24m ?4mscript24m?
       1mpackage names0m
       1mpackage present 22m?1m-exact22m? 4mpackage24m ?4mversion24m?
       1mpackage provide 4m22mpackage24m ?4mversion24m?
       1mpackage require 22m?1m-exact22m? 4mpackage24m ?4mversion24m?
       1mpackage unknown 22m?4mcommand24m?
       1mpackage vcompare 4m22mversion124m 4mversion20m
       1mpackage versions 4m22mpackage0m
       1mpackage vsatisfies 4m22mversion124m 4mversion20m


1mDESCRIPTION0m
       This  command keeps a simple database of the packages available for use
       by the current interpreter and how to load them into  the  interpreter.
       It supports multiple versions of each package and arranges for the cor-
       rect version of a package to be loaded based on what is needed  by  the
       application.   This  command  also detects and reports version clashes.
       Typically, only the 1mpackage require 22mand 1mpackage  provide  22mcommands  are
       invoked  in  normal Tcl scripts;  the other commands are used primarily
       by system scripts that maintain the package database.

       The behavior of the 1mpackage 22mcommand is determined by  its  first  argu-
       ment.  The following forms are permitted:

       1mpackage forget ?4m22mpackage24m 4mpackage24m 4m...24m?
              Removes  all  information about each specified package from this
              interpreter, including  information  provided  by  both  1mpackage0m
              1mifneeded 22mand 1mpackage provide22m.

       1mpackage ifneeded 4m22mpackage24m 4mversion24m ?4mscript24m?
              This  command  typically  appears  only  in system configuration
              scripts to set up the package database.   It  indicates  that  a
              particular  version  of  a  particular  package  is available if
              needed, and that the package can be added to the interpreter  by
              executing  4mscript24m.  The script is saved in a database for use by
              subsequent 1mpackage require 22mcommands;  typically, 4mscript24m sets  up
              auto-loading  for  the  commands  in  the package (or calls 1mload0m
              and/or 1msource 22mdirectly), then invokes 1mpackage provide  22mto  indi-
              cate  that  the package is present.  There may be information in
              the database for several different versions of a single package.
              If  the  database  already  contains information for 4mpackage24m and
              4mversion24m, the new 4mscript24m  replaces  the  existing  one.   If  the
              4mscript24m  argument is omitted, the current script for version 4mver-0m
              4msion24m of package 4mpackage24m is returned, or an empty  string  if  no
              1mpackage  ifneeded  22mcommand has been invoked for this 4mpackage24m and
              4mversion24m.

       1mpackage names0m
              Returns a list of the names of all packages in  the  interpreter
              for  which  a version has been provided (via 1mpackage provide22m) or
              for which a 1mpackage ifneeded 22mscript is available.  The order  of
              elements in the list is arbitrary.

       1mpackage present 22m?1m-exact22m? 4mpackage24m ?4mversion24m?
              This  command  is  equivalent  to 1mpackage require 22mexcept that it
              does not try and load the package if it is not already loaded.

       1mpackage provide 4m22mpackage24m ?4mversion24m?
              This command is invoked to  indicate  that  version  4mversion24m  of
              package  4mpackage24m is now present in the interpreter.  It is typi-
              cally invoked once as part of an 1mifneeded 22mscript, and  again  by
              the  package  itself when it is finally loaded.  An error occurs
              if a different version of 4mpackage24m has been provided by a  previ-
              ous  1mpackage  provide 22mcommand.  If the 4mversion24m argument is omit-
              ted, then the command returns the version number  that  is  cur-
              rently  provided,  or an empty string if no 1mpackage provide 22mcom-
              mand has been invoked for 4mpackage24m in this interpreter.

       1mpackage require 22m?1m-exact22m? 4mpackage24m ?4mversion24m?
              This command is typically invoked by Tcl code that wishes to use
              a  particular  version  of  a particular package.  The arguments
              indicate which package is wanted, and the command ensures that a
              suitable  version of the package is loaded into the interpreter.
              If the command succeeds, it returns the version number  that  is
              loaded;   otherwise  it  generates an error.  If both the 1m-exact0m
              switch and the 4mversion24m argument  are  specified  then  only  the
              given  version  is acceptable.  If 1m-exact 22mis omitted but 4mversion0m
              is specified, then versions later than 4mversion24m are also  accept-
              able  as long as they have the same major version number as 4mver-0m
              4msion24m.  If both 1m-exact 22mand 4mversion24m are omitted then  any  version
              whatsoever  is  acceptable.  If a version of 4mpackage24m has already
              been provided (by invoking the 1mpackage  provide  22mcommand),  then
              its version number must satisfy the criteria given by 1m-exact 22mand
              4mversion24m and the command  returns  immediately.   Otherwise,  the
              command  searches the database of information provided by previ-
              ous 1mpackage ifneeded 22mcommands to see if an acceptable version of
              the  package  is  available.   If so, the script for the highest
              acceptable version number is invoked; it  must  do  whatever  is
              necessary to load the package, including calling 1mpackage provide0m
              for the package.  If the 1mpackage ifneeded 22mdatabase does not con-
              tain  an acceptable version of the package and a 1mpackage unknown0m
              command has been specified for the interpreter then that command
              is  invoked;   when it completes, Tcl checks again to see if the
              package is now provided or if there is a 1mpackage ifneeded 22mscript
              for  it.   If  all  of these steps fail to provide an acceptable
              version of the package, then the command returns an error.

       1mpackage unknown 22m?4mcommand24m?
              This command supplies a ``last resort'' command to invoke during
              1mpackage require 22mif no suitable version of a package can be found
              in the 1mpackage ifneeded 22mdatabase.  If the  4mcommand24m  argument  is
              supplied,  it  contains  the  first part of a command;  when the
              command is invoked during a 1mpackage require 22mcommand, Tcl appends
              two  additional  arguments  giving  the desired package name and
              version.  For example, if 4mcommand24m is 1mfoo bar 22mand later the  com-
              mand  1mpackage require test 2.4 22mis invoked, then Tcl will execute
              the command 1mfoo bar test 2.4 22mto load the package.  If no version
              number is supplied to the 1mpackage require 22mcommand, then the ver-
              sion argument for the invoked command will be an  empty  string.
              If  the  1mpackage  unknown  22mcommand  is invoked without a 4mcommand0m
              argument, then the current 1mpackage unknown 22mscript  is  returned,
              or an empty string if there is none.  If 4mcommand24m is specified as
              an empty string, then the  current  1mpackage  unknown  22mscript  is
              removed, if there is one.

       1mpackage vcompare 4m22mversion124m 4mversion20m
              Compares the two version numbers given by 4mversion124m and 4mversion224m.
              Returns -1 if 4mversion124m is an earlier version than 4mversion224m, 0 if
              they are equal, and 1 if 4mversion124m is later than 1mversion222m.

       1mpackage versions 4m22mpackage0m
              Returns  a  list of all the version numbers of 4mpackage24m for which
              information has been provided by 1mpackage ifneeded 22mcommands.

       1mpackage vsatisfies 4m22mversion124m 4mversion20m
              Returns 1 if scripts written for 4mversion224m  will  work  unchanged
              with  4mversion124m  (i.e.  4mversion124m is equal to or greater than 4mver-0m
              4msion224m and they both have the same major version number), 0  oth-
              erwise.


1mVERSION NUMBERS0m
       Version  numbers  consist  of  one or more decimal numbers separated by
       dots, such as 2 or 1.162 or 3.1.13.1.  The first number is  called  the
       major version number.  Larger numbers correspond to later versions of a
       package, with leftmost numbers having greater significance.  For  exam-
       ple,  version  2.1  is  later  than 1.3 and version 3.4.6 is later than
       3.3.5.  Missing fields are equivalent to zeroes:  version  1.3  is  the
       same  as  version  1.3.0  and  1.3.0.0,  so it is earlier than 1.3.1 or
       1.3.0.2.  A later version number is assumed to  be  upwards  compatible
       with  an  earlier version number as long as both versions have the same
       major version number.  For example, Tcl scripts written for version 2.3
       of  a  package  should  work  unchanged  under versions 2.3.2, 2.4, and
       2.5.1.  Changes  in  the  major  version  number  signify  incompatible
       changes:  if code is written to use version 2.1 of a package, it is not
       guaranteed to work unmodified with either version 1.7.3 or version 3.1.


1mPACKAGE INDICES0m
       The recommended way to use packages in Tcl is to invoke 1mpackage require0m
       and  1mpackage  provide  22mcommands  in  scripts,  and  use  the  procedure
       1mpkg_mkIndex  22mto  create  package  index  files.  Once you've done this,
       packages will be loaded automatically in response  to  1mpackage  require0m
       commands.  See the documentation for 1mpkg_mkIndex 22mfor details.


1mSEE ALSO0m
       msgcat(n), packagens(n), pkgMkIndex(n)


1mKEYWORDS0m
