Re: [TCL] Strange behavior, or so I think, for package require
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: [TCL] Strange behavior, or so I think, for package require

From: Don Porter <dgp@email.nist.gov>
Date: Mon Apr 03 2006 - 17:51:47 CEST

Andrew Falanga wrote:
> Why does that first call to package require seem to "include" virtually
> all possible packages in the auto_path variable?

First, note that [package names] does *not* return all packages
that are "present" in the interp. It returns names of all packages
that Tcl knows how to make present in the interp.

Try [package unknown] in your interpreter. It will return
tclPkgUnknown. That indicates it is the [tclPkgUnknown] command
that is registered to find installed packages. This is the default.

Why does [tclPkgUnknown] go find all packages when it goes looking
for just one? Because that's how it was written. The design intent
is lost to history, best I can tell, but this has been the default
behavior of Tcl as long as the [package] command has existed, so
I'm surprised that you are surprised by it.

If you wish, you can use [package unknown] to register a different
package finding command that operates more to your liking, but
you may run into compatibility issues with packages that assume
the default finder when performing their install.

-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter@nist.gov             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|
Received on Sun Apr 30 02:57:39 2006