Manual Pages for UNIX Darwin command on man package
MyWebUniversity

Manual Pages for UNIX Darwin command on man package

package(n) Tcl Built-In Commands package(n)

NAME

package - Facilities for package loading and version control

SYNOPSIS

ppaacckkaaggee ffoorrggeett ??package package ...?

ppaacckkaaggee iiffnneeeeddeedd package version ?script?

ppaacckkaaggee nnaammeess

ppaacckkaaggee pprreesseenntt ?-eexxaacctt? package ?version?

ppaacckkaaggee pprroovviiddee package ?version?

ppaacckkaaggee rreeqquuiirree ?-eexxaacctt? package ?version?

ppaacckkaaggee uunnkknnoowwnn ?command? ppaacckkaaggee vvccoommppaarree version1 version2

ppaacckkaaggee vveerrssiioonnss package

ppaacckkaaggee vvssaattiissffiieess version1 version2

DESCRIPTION

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 ppaacckkaaggee rreeqquuiirree and ppaacckkaaggee pprroovviiddee commands are invoked in normal Tcl scripts; the other commands are used primarily

by system scripts that maintain the package database.

The behavior of the ppaacckkaaggee command is determined by its first argu-

ment. The following forms are permitted:

ppaacckkaaggee ffoorrggeett ??package package ...?

Removes all information about each specified package from this

interpreter, including information provided by both ppaacckkaaggee iiffnneeeeddeedd and ppaacckkaaggee pprroovviiddee.

ppaacckkaaggee iiffnneeeeddeedd package version ?script?

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 script. The script is saved in a database for use by subsequent ppaacckkaaggee rreeqquuiirree commands; typically, script sets up

auto-loading for the commands in the package (or calls llooaadd

and/or ssoouurrccee directly), then invokes ppaacckkaaggee pprroovviiddee to 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 package and

version, the new script replaces the existing one. If the

script argument is omitted, the current script for version ver-

sion of package package is returned, or an empty string if no

ppaacckkaaggee iiffnneeeeddeedd command has been invoked for this package and

version. ppaacckkaaggee nnaammeess

Returns a list of the names of all packages in the interpreter

for which a version has been provided (via ppaacckkaaggee pprroovviiddee) or for which a ppaacckkaaggee iiffnneeeeddeedd script is available. The order of elements in the list is arbitrary.

ppaacckkaaggee pprreesseenntt ?-eexxaacctt? package ?version?

This command is equivalent to ppaacckkaaggee rreeqquuiirree except that it

does not try and load the package if it is not already loaded.

ppaacckkaaggee pprroovviiddee package ?version?

This command is invoked to indicate that version version of

package package is now present in the interpreter. It is typi-

cally invoked once as part of an iiffnneeeeddeedd script, and again by

the package itself when it is finally loaded. An error occurs

if a different version of package has been provided by a previ-

ous ppaacckkaaggee pprroovviiddee command. If the version argument is omit-

ted, then the command returns the version number that is cur-

rently provided, or an empty string if no ppaacckkaaggee pprroovviiddee com-

mand has been invoked for package in this interpreter.

ppaacckkaaggee rreeqquuiirree ?-eexxaacctt? package ?version?

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 -eexxaacctt

switch and the version argument are specified then only the

given version is acceptable. If -eexxaacctt is omitted but version

is specified, then versions later than version are also accept-

able as long as they have the same major version number as ver-

sion. If both -eexxaacctt and version are omitted then any version

whatsoever is acceptable. If a version of package has already

been provided (by invoking the ppaacckkaaggee pprroovviiddee command), then

its version number must satisfy the criteria given by -eexxaacctt and

version and the command returns immediately. Otherwise, the

command searches the database of information provided by previ-

ous ppaacckkaaggee iiffnneeeeddeedd commands to see if an acceptable version of

the package is available. If so, the script for the highest

acceptable version number is evaluated in the global namespace;

it must do whatever is necessary to load the package, including

calling ppaacckkaaggee pprroovviiddee for the package. If the ppaacckkaaggee

iiffnneeeeddeedd database does not contain an acceptable version of the

package and a ppaacckkaaggee uunnkknnoowwnn command has been specified for the

interpreter then that command is evaluated in the global names-

pace; when it completes, Tcl checks again to see if the package

is now provided or if there is a ppaacckkaaggee iiffnneeeeddeedd script for it. If all of these steps fail to provide an acceptable version of

the package, then the command returns an error.

ppaacckkaaggee uunnkknnoowwnn ?command? This command supplies a ``last resort'' command to invoke during

ppaacckkaaggee rreeqquuiirree if no suitable version of a package can be found

in the ppaacckkaaggee iiffnneeeeddeedd database. If the command argument is supplied, it contains the first part of a command; when the command is invoked during a ppaacckkaaggee rreeqquuiirree command, Tcl appends

two additional arguments giving the desired package name and

version. For example, if command is ffoooo bbaarr and later the com-

mand ppaacckkaaggee rreeqquuiirree tteesstt 22..44 is invoked, then Tcl will execute

the command ffoooo bbaarr tteesstt 22..44 to load the package. If no version

number is supplied to the ppaacckkaaggee rreeqquuiirree command, then the ver-

sion argument for the invoked command will be an empty string. If the ppaacckkaaggee uunnkknnoowwnn command is invoked without a command argument, then the current ppaacckkaaggee uunnkknnoowwnn script is returned, or an empty string if there is none. If command is specified as an empty string, then the current ppaacckkaaggee uunnkknnoowwnn script is removed, if there is one. ppaacckkaaggee vvccoommppaarree version1 version2 Compares the two version numbers given by version1 and version2.

Returns -1 if version1 is an earlier version than version2, 0 if

they are equal, and 1 if version1 is later than vveerrssiioonn22.

ppaacckkaaggee vveerrssiioonnss package

Returns a list of all the version numbers of package for which

information has been provided by ppaacckkaaggee iiffnneeeeddeedd commands. ppaacckkaaggee vvssaattiissffiieess version1 version2 Returns 1 if scripts written for version2 will work unchanged

with version1 (i.e. version1 is equal to or greater than ver-

sion2 and they both have the same major version number), 0 oth-

erwise. VVEERRSSIIOONN NNUUMMBBEERRSS 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. PPAACCKKAAGGEE IINNDDIICCEESS

The recommended way to use packages in Tcl is to invoke ppaacckkaaggee rreeqquuiirree

and ppaacckkaaggee pprroovviiddee commands in scripts, and use the procedure

ppkkggmmkkIInnddeexx to create package index files. Once you've done this,

packages will be loaded automatically in response to ppaacckkaaggee rreeqquuiirree

commands. See the documentation for ppkkggmmkkIInnddeexx for details.

SEE ALSO

msgcat(n), packagens(n), pkgMkIndex(n)

KKEEYYWWOORRDDSS

package, version

Tcl 7.5 package(n)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™