1. Namespace-Refactor
Tcl is highly structured language, providing
much of it's builtin functionality via
sub-commands within higher level commands, eg. [string first] and [file tail].
However, at present (version 8.5) sub-commands are not implemented
or accessible as individual
commands, say within the ::string or ::file
namespaces.
Refactoring refers to
the decomposition of Tcl builtins sub-commands
into namespaces, using ensembles if available.
For example, [string length] is redefined as [::string::length].
The results is Tcl/Mod ,
a richer and easier to use language
that is
better suited for
programming in the large.
Ultimately refactorings goal is to simplify Tcl development.
Refactoring when implemented, offers several significant
advantages such as:
simplified backward compatibility/extensibility,
improved introspection,
self-documentation, and support for command-completion (for editors).
This last is via the Extern command, which provides
prototype definitions used for compile time code checking by Weld.
Namespace-refactoring also
leads into advanced features such as Autoimport and Uses.
Two basic approaches may be used to refactor the Tcl core. The first
involves a rewrite of the core C code (see Refactoring Patch).
Unfortunately, this is a binary change, making it
unusable with existing Tcl interpreter installations.
A second and simpler approach (and the one used by Mod) uses plain Tcl
to manually create namespaces and use aliases for subcommands.
The actual overriding of the builtin commands (eg. string) may be restricted
to debugging and/or development time.
Extern definitions for Tcl/Tk
builtin commands
are provided by Mod via [interp alias]. This approach supports
versions of Tcl as far back as 8.3 (ie. around 2000) are refactorable.
This allows refactoring to be used now, in a version independant way.
Similarly, Tk is refactored, including widgets via Tk/Mod.
© 2008 Peter MacDonald