[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Let us compare Ousterhout's design goals for Tcl in [Tcl], and see how Q fits them:
This has been a major goal in designing Q, and has motivated most of the decisions discussed in this paper.
Q is a fully programmable very-high-level language.
This has not such a priority for Q. Compared to Tcl, Q is a big language. The interpreter is efficient enough for interactive use, and there is an (un-finished) compiler that translates Q into C++. However, the run-time is much bigger than Tcl (though much smaller than typical Lisp systems). On the other hand, much of the system size consists of the builtin types and routines, and the system is modular enough to be incrementally loadable (autoloading will soon be added).
Because Q has a rich hierarchical type system, it is more reasonable to support a simple interface to C++ applications. This Q does very well. Most of the primitive functions are written as Q stub routines that invoke a C++ primitive. For example:
:(:x take :y~Numeric)=external DoTake |
take
function takes two arguments,
one of which must be numeric, and the body of the function
is implemented by the C++ function DoTake
.
Writing DoTake
is also easy:
Object* DoTake(Object* x, Numeric* y) { ... } |
Numeric
is a sub-class of Object
.)
The Q module containing take
is compiled into a C++
program, whose object file is linked with that containing DoTake
.
Nothing more is needed. The linking can be dynamic or static.
The C++ mechanism for static initializers is used to enter take
into the appropriate tables.
It is practical to combine the features of a shell into a full-fledged programming languages. I hope I have shown that careful orthogonal design can give a moderate-sized very powerful multi-purpose language.
Using object-oriented programming (and C++ in particular) made it much easier to manage the many possible combinations in a rich language (such as different expression types and different output modes).
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |