Version 3 of Distribution Mechanisms

Updated 2007-08-24 00:00:04 by KJN

Distribution mechanisms for Tcl source and binaries

  • Teacup - a tool for fetching and managing modules from a repository
  • Tcl Modules - a single file that contains a package and can be sourced
  • package require - command for loading packaged code that is usually installed in Tcl's lib directory
  • source - command to load a Tcl source file
  • load - load a shared library (DLL or SO file)
  • auto_load - load a command using the tclIndex files in the auto-load path

KJN I have started this page because I am beginning to get confused by the number of possible distribution mechanisms. Has auto_load been made obsolete by package?

Neil Madden pointed out [L1 ] that package require delegates actual loading of packages to either source (for Tcl scripts) or load (for binary extensions).

Please discuss.


LV I'm confused by what you mean by distribution mechanism. Do you mean formats in which code can be distributed to users or do you mean mechanisms by which users can locate new extensions or do you mean "means by which a program can invoke other code''' or what?

The reason I ask is because Teacup seems different than the other items on the above list - and there are certainly other repositories other than teacup.

Also, I don't see listed in the above list things like "zip files", "starkits", "tar files", "opening a file and reading in code", "exec", "opening a pipe", etc.

Perhaps after we know better what you are after, more information can be added.


KJN Sorry for the lack of clarity - I followed Tcl Modules which had been placed in Category Distribution.

I'm interested in the ways that binary libraries or source code can be organised, so that they can be requested by a script, either automatically or by a simple command, when their functionality is needed.

The simplest way to do this when organising one's own Tcl code is to use source; but when a piece of code has well-defined functionality, and is intended for re-use in different projects, it is convenient to organise it as a package: this is how most libraries are provided at present.

Tcl Modules and Teacup are innovations, and I would be glad of any comments on how these fit in with the older commands. Teacup appears to differ from package require by fetching modules from a repository, rather than looking in the system's Tcl installation.

auto_load appears to be an older mechanism, but it is not marked in the manual as deprecated.


See also:


Category Distribution