1. Pre use: Library construction Members of a library must be grouped in a logical collection. An identifying name must be assigned to the library. Revision information must be assigned to the library. 2. Runtime: Library identification The application must be able to find the required library. 3. Runtime: Library loading The library must be loaded into the application either with load or source. 4. Runtime: Introspection Determine if a library is loaded, and if so, what revision is loaded.For example, code may prefer to have version x.y of a library, with workarounds if version v.w is found instead.Many of the requirements described above are met with the current package command, however the package command predates several modern Tcl language features (namespaces and vfs), and was designed to support large scale libraries - compiled extensions or large Tcl-source collections (ie. http, or DRH's Tree widget) that are designed to be built into an application.There is not good support for small scale libraries of modules designed to be built into larger subsystems, which are then built into applications. A stack or tree data structure, or a complex widget with internal state are examples of this scale of library.The package command works well for Large style entities that reside on a locally mounted disk.The package command does not support finding libraries on unmounted file systems, or small scale libraries.The current package command does not support these file finding needs:
1. Finding libraries on any platform except the locally mounted file system. 2. Finding a library with a complex matching rule (ie. A revision that is more than X but less than Y)The current package command does not support these Small mode program features:
1. Load library into an application specified namespace. 2. Loading multiple copies of a library.Options
1. Extend package command to support the unmet requirements. 2. Create a new command similar to package to support Small mode development needs. 3. Create a new set of library commands to support all the requirements of package. In this case options include: 3.a Separate the library creation, library loading and library introspection functionality into separate commands. 3.b Create a single command (and subcommands) to implement all the functionality. 3.c Develop external support for software libraries, as the C compiler does with the ar and ld commands. 3.c.1 Use a wrapping mechanism similar to prowrap, sdx or freewrap to create single file execution modules. 3.c.2 Use external Tcl script to generate a Tcl Library, similar to a .a, .dll, .so or .jar file, and add a command to the Tcl core to duplicate package require or #include functionality. 3.c.3 Use an external Tcl script to create separate index files (As pkg_mkIndex does now), and a more generic package require command implementation.Comments on or edits to this page are welcome.
schlenk One should mention the new Tcl modules, which were introduced in Tcl 8.5 in this context, which address some of the issues, especially from 3.c.Loading multiple copies of a library (in a single interpreter) is a rare requirement from my POV. What's the use case for it; it just sounds like a waste of memory. Loading a library into an application specified namespace is not trivial. It is more common to load the package and import the exported API via namespace import into the namespace one wants.I don't really see why the current package mechanism is seen as not useful for small mode development. What's wrong for example with the tcllib struct packages which fit into your proposed small mode?