Version 2 of Ensemble

Updated 2002-10-11 16:25:20

Purpose: discuss the concept of command ensemble

This concept has also been called "major/minor" commands by some people (like myself) who didn't know the fancier name of ensemble.

Tcl has several kinds of commands.

The first, a simple command like set, provides a very simple interface. One passes either one or two arguments. Depending on the number of arguments, set either outputs the value of the variable, or it sets the variable to a value.

A slightly more complex variation of this is a command that takes arguments. puts for instance has an optional -nonewline flag as well as an optional output channel and an output string.

Next in complexity comes the ensemble. An example of this command would be string. What makes it more complex is that string is an umbrella name for a variety of related functionality. String is the major command name, the minor subcommand names are things like bytelength,compare, etc.

See TIP http://purl.org/tcl/tip/112.html for a TIP to include support for developing this type of command in Tcl.


Since every object command is an ensemble, having support for ensembles as part of the language (presumably coded in C) would make pure Tcl object and megawidget frameworks much more efficient. -- WHD


Category Tutorial