summaryrefslogtreecommitdiffstats
path: root/doc/package.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/package.n')
-rw-r--r--doc/package.n20
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/package.n b/doc/package.n
index aafce5e..913d3af 100644
--- a/doc/package.n
+++ b/doc/package.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: package.n,v 1.22 2007/12/13 15:22:33 dgp Exp $
+'\" RCS: @(#) $Id: package.n,v 1.23 2008/10/17 10:22:25 dkf Exp $
'\"
.so man.macros
.TH package n 7.5 Tcl "Tcl Built-In Commands"
@@ -29,7 +29,6 @@ package \- Facilities for package loading and version control
\fBpackage prefer \fR?\fBlatest\fR|\fBstable\fR?
.fi
.BE
-
.SH DESCRIPTION
.PP
This command keeps a simple database of the packages available for
@@ -47,11 +46,13 @@ The behavior of the \fBpackage\fR command is determined by its first argument.
The following forms are permitted:
.TP
\fBpackage forget ?\fIpackage package ...\fR?
+.
Removes all information about each specified package from this interpreter,
including information provided by both \fBpackage ifneeded\fR and
\fBpackage provide\fR.
.TP
\fBpackage ifneeded \fIpackage version\fR ?\fIscript\fR?
+.
This command typically appears only in system configuration
scripts to set up the package database.
It indicates that a particular version of
@@ -73,6 +74,7 @@ or an empty string if no \fBpackage ifneeded\fR command has
been invoked for this \fIpackage\fR and \fIversion\fR.
.TP
\fBpackage names\fR
+.
Returns a list of the names of all packages in the
interpreter for which a version has been provided (via
\fBpackage provide\fR) or for which a \fBpackage ifneeded\fR
@@ -80,10 +82,12 @@ script is available.
The order of elements in the list is arbitrary.
.TP
\fBpackage present\fR
+.
This command is equivalent to \fBpackage require\fR except that it
does not try and load the package if it is not already loaded.
.TP
\fBpackage provide \fIpackage \fR?\fIversion\fR?
+.
This command is invoked to indicate that version \fIversion\fR
of package \fIpackage\fR is now present in the interpreter.
It is typically invoked once as part of an \fBifneeded\fR script,
@@ -96,6 +100,7 @@ empty string if no \fBpackage provide\fR command has been
invoked for \fIpackage\fR in this interpreter.
.TP
\fBpackage require \fR\fIpackage \fR?\fIrequirement...\fR?
+.
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
@@ -141,11 +146,13 @@ package, then the command returns an error.
.RE
.TP
\fBpackage require \-exact \fIpackage version\fR
+.
This form of the command is used when only the given \fIversion\fR
of \fIpackage\fR is acceptable to the caller. This command is
equivalent to \fBpackage require \fIpackage version\fR-\fIversion\fR.
.TP
\fBpackage unknown \fR?\fIcommand\fR?
+.
This command supplies a
.QW "last resort"
command to invoke during
@@ -167,30 +174,36 @@ If \fIcommand\fR is specified as an empty string, then the current
\fBpackage unknown\fR script is removed, if there is one.
.TP
\fBpackage vcompare \fIversion1 version2\fR
+.
Compares the two version numbers given by \fIversion1\fR and \fIversion2\fR.
Returns -1 if \fIversion1\fR is an earlier version than \fIversion2\fR,
0 if they are equal, and 1 if \fIversion1\fR is later than \fBversion2\fR.
.TP
\fBpackage versions \fIpackage\fR
+.
Returns a list of all the version numbers of \fIpackage\fR
for which information has been provided by \fBpackage ifneeded\fR
commands.
.TP
\fBpackage vsatisfies \fIversion requirement...\fR
+.
Returns 1 if the \fIversion\fR satisfies at least one of the given
requirements, and 0 otherwise. Each \fIrequirement\fR is allowed to
have any of the forms:
.RS
.TP
min
+.
This form is called
.QW min-bounded .
.TP
min-
+.
This form is called
.QW min-unbound .
.TP
min-max
+.
This form is called
.QW bounded .
.RE
@@ -329,8 +342,10 @@ Once you have done this, packages will be loaded automatically
in response to \fBpackage require\fR commands.
See the documentation for \fBpkg_mkIndex\fR for details.
.SH EXAMPLES
+.PP
To state that a Tcl script requires the Tk and http packages, put this
at the top of the script:
+.PP
.CS
\fBpackage require\fR Tk
\fBpackage require\fR http
@@ -339,6 +354,7 @@ at the top of the script:
To test to see if the Snack package is available and load if it is
(often useful for optional enhancements to programs where the loss of
the functionality is not critical) do this:
+.PP
.CS
if {[catch {\fBpackage require\fR Snack}]} {
# Error thrown - package not found.