{"id":6268,"date":"2022-12-20T18:58:05","date_gmt":"2022-12-20T21:58:05","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/package-mann\/"},"modified":"2022-12-20T18:58:05","modified_gmt":"2022-12-20T21:58:05","slug":"package-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/package-mann\/","title":{"rendered":"package (mann)"},"content":{"rendered":"<h1 align=\"center\">package<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#VERSION NUMBERS\">VERSION NUMBERS<\/a><br \/> <a href=\"#PACKAGE INDICES\">PACKAGE INDICES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">package \u2212 Facilities for package loading and version control<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>package forget<\/b> ?<i>package package &#8230;<\/i>? <b><br \/> package ifneeded<\/b> <i>package version<\/i> ?<i>script<\/i>? <b><br \/> package names <br \/> package present<\/b> <i>package<\/i> ?<i>requirement&#8230;<\/i>? <b><br \/> package present \u2212exact<\/b> <i>package version<\/i> <b><br \/> package provide<\/b> <i>package<\/i> ?<i>version<\/i>? <b><br \/> package require<\/b> <i>package<\/i> ?<i>requirement&#8230;<\/i>? <b><br \/> package require \u2212exact<\/b> <i>package version<\/i> <b><br \/> package unknown<\/b> ?<i>command<\/i>? <b><br \/> package vcompare<\/b> <i>version1 version2<\/i> <b><br \/> package versions<\/b> <i>package<\/i> <b><br \/> package vsatisfies<\/b> <i>version requirement&#8230;<\/i> <b><br \/> package prefer<\/b> ?<b>latest<\/b>|<b>stable<\/b>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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 correct 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 <b>package require<\/b> and <b>package provide<\/b> commands are invoked in normal Tcl scripts; the other commands are used primarily by system scripts that maintain the package database.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The behavior of the <b>package<\/b> command is determined by its first argument. The following forms are permitted: <b><br \/> package forget<\/b> ?<i>package package &#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Removes all information about each specified package from this interpreter, including information provided by both <b>package ifneeded<\/b> and <b>package provide<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>package ifneeded<\/b> <i>package version<\/i> ?<i>script<\/i>?<\/p>\n<p style=\"margin-left:22%;\">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 <i>script<\/i>. The script is saved in a database for use by subsequent <b>package require<\/b> commands; typically, <i>script<\/i> sets up auto-loading for the commands in the package (or calls <b>load<\/b> and\/or <b>source<\/b> directly), then invokes <b>package provide<\/b> to indicate 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 <i>package<\/i> and <i>version<\/i>, the new <i>script<\/i> replaces the existing one. If the <i>script<\/i> argument is omitted, the current script for version <i>version<\/i> of package <i>package<\/i> is returned, or an empty string if no <b>package ifneeded<\/b> command has been invoked for this <i>package<\/i> and <i>version<\/i>.<\/p>\n<p style=\"margin-left:11%;\"><b>package names<\/b><\/p>\n<p style=\"margin-left:22%;\">Returns a list of the names of all packages in the interpreter for which a version has been provided (via <b>package provide<\/b>) or for which a <b>package ifneeded<\/b> script is available. The order of elements in the list is arbitrary.<\/p>\n<p style=\"margin-left:11%;\"><b>package present<\/b> ?<b>\u2212exact<\/b>? <i>package<\/i> ?<i>requirement&#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">This command is equivalent to <b>package require<\/b> except that it does not try and load the package if it is not already loaded.<\/p>\n<p style=\"margin-left:11%;\"><b>package provide<\/b> <i>package<\/i> ?<i>version<\/i>?<\/p>\n<p style=\"margin-left:22%;\">This command is invoked to indicate that version <i>version<\/i> of package <i>package<\/i> is now present in the interpreter. It is typically invoked once as part of an <b>ifneeded<\/b> script, and again by the package itself when it is finally loaded. An error occurs if a different version of <i>package<\/i> has been provided by a previous <b>package provide<\/b> command. If the <i>version<\/i> argument is omitted, then the command returns the version number that is currently provided, or an empty string if no <b>package provide<\/b> command has been invoked for <i>package<\/i> in this interpreter.<\/p>\n<p style=\"margin-left:11%;\"><b>package require<\/b> <i>package<\/i> ?<i>requirement&#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">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.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">A suitable version of the package is any version which satisfies at least one of the requirements, per the rules of <b>package vsatisfies<\/b>. If multiple versions are suitable the implementation with the highest version is chosen. This last part is additionally influenced by the selection mode set with <b>package prefer<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">In the \u201cstable\u201d selection mode the command will select the highest stable version satisfying the requirements, if any. If no stable version satisfies the requirements, the highest unstable version satisfying the requirements will be selected. In the \u201clatest\u201d selection mode the command will accept the highest version satisfying all the requirements, regardless of its stableness.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">If a version of <i>package<\/i> has already been provided (by invoking the <b>package provide<\/b> command), then its version number must satisfy the <i>requirement<\/i>s and the command returns immediately. Otherwise, the command searches the database of information provided by previous <b>package ifneeded<\/b> 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 <b>package provide<\/b> for the package. If the <b>package ifneeded<\/b> database does not contain an acceptable version of the package and a <b>package unknown<\/b> command has been specified for the interpreter then that command is evaluated in the global namespace; when it completes, Tcl checks again to see if the package is now provided or if there is a <b>package ifneeded<\/b> script for it. If all of these steps fail to provide an acceptable version of the package, then the command returns an error.<\/p>\n<p style=\"margin-left:11%;\"><b>package require \u2212exact<\/b> <i>package version<\/i><\/p>\n<p style=\"margin-left:22%;\">This form of the command is used when only the given <i>version<\/i> of <i>package<\/i> is acceptable to the caller. This command is equivalent to <b>package require<\/b> <i>package version<\/i>&#8211;<i>version<\/i>.<\/p>\n<p style=\"margin-left:11%;\"><b>package unknown<\/b> ?<i>command<\/i>?<\/p>\n<p style=\"margin-left:22%;\">This command supplies a \u201clast resort\u201d command to invoke during <b>package require<\/b> if no suitable version of a package can be found in the <b>package ifneeded<\/b> database. If the <i>command<\/i> argument is supplied, it contains the first part of a command; when the command is invoked during a <b>package require<\/b> command, Tcl appends one or more additional arguments giving the desired package name and requirements. For example, if <i>command<\/i> is <b>foo bar<\/b> and later the command <b>package require test 2.4<\/b> is invoked, then Tcl will execute the command <b>foo bar test 2.4<\/b> to load the package. If no requirements are supplied to the <b>package require<\/b> command, then only the name will be added to invoked command. If the <b>package unknown<\/b> command is invoked without a <i>command<\/i> argument, then the current <b>package unknown<\/b> script is returned, or an empty string if there is none. If <i>command<\/i> is specified as an empty string, then the current <b>package unknown<\/b> script is removed, if there is one.<\/p>\n<p style=\"margin-left:11%;\"><b>package vcompare<\/b> <i>version1 version2<\/i><\/p>\n<p style=\"margin-left:22%;\">Compares the two version numbers given by <i>version1<\/i> and <i>version2<\/i>. Returns -1 if <i>version1<\/i> is an earlier version than <i>version2<\/i>, 0 if they are equal, and 1 if <i>version1<\/i> is later than <i>version2<\/i>.<\/p>\n<p style=\"margin-left:11%;\"><b>package versions<\/b> <i>package<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a list of all the version numbers of <i>package<\/i> for which information has been provided by <b>package ifneeded<\/b> commands.<\/p>\n<p style=\"margin-left:11%;\"><b>package vsatisfies<\/b> <i>version requirement&#8230;<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns 1 if the <i>version<\/i> satisfies at least one of the given requirements, and 0 otherwise. Each <i>requirement<\/i> is allowed to have any of the forms:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>min<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"53%\">\n<p>This form is called \u201cmin-bounded\u201d.<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>min-<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"53%\">\n<p>This form is called \u201cmin-unbound\u201d.<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\">min-max<\/p>\n<p style=\"margin-left:32%;\">This form is called \u201cbounded\u201d.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">where \u201cmin\u201d and \u201cmax\u201d are valid version numbers. The legacy syntax is a special case of the extended syntax, keeping backward compatibility. Regarding satisfaction the rules are:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\">\n<p>[1]<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p>The <i>version<\/i> has to pass at least one of the listed <i>requirement<\/i>s to be satisfactory.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\">\n<p>[2]<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p>A version satisfies a \u201cbounded\u201d requirement when<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:32%;\">[a]<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"15%\"><\/td>\n<td width=\"6%\"><\/td>\n<td width=\"57%\">\n<p style=\"margin-top: 1em\">For <i>min<\/i> equal to the <i>max<\/i> if, and only if the <i>version<\/i> is equal to the <i>min<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"15%\">\n<p>[b]<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"57%\">\n<p>Otherwise if, and only if the <i>version<\/i> is greater than or equal to the <i>min<\/i>, and less than the <i>max<\/i>, where both <i>min<\/i> and <i>max<\/i> have been padded internally with \u201ca0\u201d. Note that while the comparison to <i>min<\/i> is inclusive, the comparison to <i>max<\/i> is exclusive.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"15%\">\n<p>[3]<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"57%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:32%; margin-top: 1em\">A \u201cmin-bounded\u201d requirement is a \u201cbounded\u201d requirement in disguise, with the <i>max<\/i> part implicitly specified as the next higher major version number of the <i>min<\/i> part. A version satisfies it per the rules above.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\">\n<p style=\"margin-top: 1em\">[4]<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">A <i>version<\/i> satisfies a \u201cmin-unbound\u201d requirement if, and only if it is greater than or equal to the <i>min<\/i>, where the <i>min<\/i> has been padded internally with \u201ca0\u201d. There is no constraint to a maximum.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><b>package prefer<\/b> ?<b>latest<\/b>|<b>stable<\/b>?<\/p>\n<p style=\"margin-left:22%;\">With no arguments, the commands returns either \u201clatest\u201d or \u201cstable\u201d, whichever describes the current mode of selection logic used by <b>package require<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">When passed the argument \u201clatest\u201d, it sets the selection logic mode to \u201clatest\u201d.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">When passed the argument \u201cstable\u201d, if the mode is already \u201cstable\u201d, that value is kept. If the mode is already \u201clatest\u201d, then the attempt to set it back to \u201cstable\u201d is ineffective and the mode value remains \u201clatest\u201d.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">When passed any other value as an argument, raise an invalid argument error.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">When an interpreter is created, its initial selection mode value is set to \u201cstable\u201d unless the environment variable <b>TCL_PKG_PREFER_LATEST<\/b> is set. If that environment variable is defined (with any value) then the initial (and permanent) selection mode value is set to \u201clatest\u201d.<\/p>\n<h2>VERSION NUMBERS <a name=\"VERSION NUMBERS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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 example, 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. In addition, the letters \u201ca\u201d (alpha) and\/or \u201cb\u201d (beta) may appear exactly once to replace a dot for separation. These letters semantically add a negative specifier into the version, where \u201ca\u201d is \u22122, and \u201cb\u201d is \u22121. Each may be specified only once, and \u201ca\u201d or \u201cb\u201d are mutually exclusive in a specifier. Thus 1.3a1 becomes (semantically) 1.3.\u22122.1, 1.3b1 is 1.3.\u22121.1. Negative numbers are not directly allowed in version specifiers. A version number not containing the letters \u201ca\u201d or \u201cb\u201d as specified above is called a <b>stable<\/b> version, whereas presence of the letters causes the version to be called is <b>unstable<\/b>. 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.<\/p>\n<h2>PACKAGE INDICES <a name=\"PACKAGE INDICES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The recommended way to use packages in Tcl is to invoke <b>package require<\/b> and <b>package provide<\/b> commands in scripts, and use the procedure <b>pkg_mkIndex<\/b> to create package index files. Once you have done this, packages will be loaded automatically in response to <b>package require<\/b> commands. See the documentation for <b>pkg_mkIndex<\/b> for details.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">To state that a Tcl script requires the Tk and http packages, put this at the top of the script:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>package require<\/b> Tk <b><br \/> package require<\/b> http<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">if {[catch {<b>package require<\/b> Snack}]} { <br \/> # Error thrown &#8211; package not found. <br \/> # Set up a dummy interface to work around the absence <br \/> } else { <br \/> # We have the package, configure the app to use it <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">msgcat(n), packagens(n), pkgMkIndex(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">package, version<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  package \u2212 Facilities for package loading and version control <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2635,2880],"class_list":["post-6268","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-package"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6268"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6268\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}