A domain-specific language, or dsl is a language purpose-built for a specific problem domain. Tcl is itself is purpose-built for creating domain-specific languages by extending an interpreter with domain-specific commands.
A domain-specific language is a programming language designed explicitly to express activities in a certain domain, and either incidentally or purposefully limits itself to those expressions directly relevant to that domain.
Some examples:
Controversial examples:
Aside from the concept of domain suitability alluded to above, many have tried to further pin down the defining characteristics of a DSL. For instance, see [L1 ] [L2 ] [L3 ]. Microsoft has its own visual-programming take on DSLs: [L4 ].
Tcl itself was designed as a primordial domain-specific language, ready to be extended into any specific domain via the customization of available commands in a given Tcl interpreter. John Ousterhout had written several tools for IC design, each sporting its own domain-specific language, and wrote Tcl as a single reusable DSL to end this pattern of implementing an ad-hoc quirky command interface for each program.
One tool method of extending Tcl into some domain is to create a safe interpreter and populate it with an appropriate set of commands.
NEM: Some people make the distinction between an embedded DSL and other forms of DSL. An embedded DSL extends some host language to add constructs relevant to some domain. In this case you have the full power of the host language available as well as the domain-specific features. Tcl lends itself well to this sort of DSL (regexp and expr are two examples). Lisp is another language good for EDSL development. The other choice is to make the DSL standalone, typically by writing an interpreter or compiler for it. In Tcl you can do that, as lexfiend says, by making use of interp and removing (or hiding) those commands that aren't needed and adding back in domain-specific ones. Another approach, popular in Java land, is to use XML to define a the syntax of a DSL. Visual DSLs are periodically trendy.
AM 2006-03-03: I consider the script in Solving the advection-diffusion equation an example of a domain-specific language:
CMcC 2006-09-13: Tcl is eminently suitable as a target for compilation of DSLs, in that it has a very regular/minimal syntax and a rich and extensible semantics. Tcl's syntax supports trees (as lists of lists) and lexically colouring elements with semantics (by using [] instead of {} to delineate sub-tree nodes.) It is therefore possible, and quite often effective, to transform (compile) a DSL into Tcl, then evaluate the product.
This is how I implement STX ... parsing the input text into functional units, basically duples (function and text-or-subexpression) and then lexically converting these into invocations of tcl-supplied semantics.