1. Namespace-Refactor
Tcl commands are highly structured, and
much of it's builtin functionality is provided via
sub-commands, eg. [string first] and [file tail].
However, at present (version 8.5) sub-commands are not implemented
(or accessible) as actual
commands, say within the ::string or ::file
namespaces.
Refactoring refers to
the decomposition of Tcl builtins sub-commands
into namespaces (using ensembles if possible).
For example, [string length] is redefined as [::string::length].
The results is a richer and easier to use language
that is better suited for
programming in the large.
Ultimately refactoring can simplify Tcl development.
Refactoring offers
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 Wize.
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 TkScript.
© 2008 Peter MacDonald