1. Autoimport
Justifiably, Tcl users take pride in it's compactness, simplicity and small command set.
This very attribute however, can contribute Tcl seem apparent clumsiness and
awkward usage for simple, frequently repeated operations. Moreover, the specifics
of dealing with namespaces, although
wonderful for organizing code, contributes further to Tcl's perception
of verbosity.
Autoimport offers a way to reduce these issues.
Autoimport is a feature whereby commands are dynamically imports from other
namespaces on-demand, ie. when they are first called.
This works as follows.
When an unknown command is
encountered in a Tcl program, the command [unknown] tries to autoload it.
If this resolution fails,
an error is generated, and the program gets a traceback.
Autoimport coopts [unknown] at the point of failure and tries
to import a matching subcommand from sets of well-known namespaces.
The namespace set may be specified explicitly using
[Mod uses] but, by default, Mod will use subcommands
from the main Tcl builtins commands.
Autoimport is implemented and normally used via Uses, which
takes care of both loading module code (sourcing Tcl and loading shared libraries as required) and importing commands.
© 2008 Peter MacDonald