Version 5 of package present

Updated 2004-12-15 15:51:59

package present ?-exact? package ?version?

"This command is equivalent to package require except that it does not try and load the package if it is not already loaded." Its canonical description appears in the man page [L1 ].


etdxc Sorry for being so literal, but I presume this means that it tries to load the package only when it is not already loaded.

CL agrees that the man page is unsatisfying. I submit this alternative:

  • If package is loaded, the command returns its version;
  • If package is not loaded, the command branches to error "package $package not present".

LV Here's an example:

 $ tclsh
 % package names
 Tcl
 % package present Tk
 package Tk is not present
 % package require Tk
 8.5
 % package present Tk
 8.5

DGP has been heard to say, "the one place I find [package present] useful as defined is in the script portion of a package that has both C and script portions."


See also:


Tcl syntax help - Category Command - Category Introspection