Please read the more recent version of this paper
Please read the
more recent version of this paper on my new website.
Abstract
C++ and Java are two well-known languages that offer primitives and in-language
support for object oriented programming. That does not mean that object oriented
programming is impossible in other languages. Object orientation is really just
a way of thinking; it has more to do with design than with implementation.
Look at the source code of the TCL interpreter for a great example of object
oriented programming in C (not C++!). If you are disciplined enough to always
pass a pointer to a struct as the first parameter to a function, you can see
such a function as a 'method' of the struct. You do not need actual language
support to create object-oriented code.
TCL does not offer object oriented primitives, but it is flexible enough to
accomodate new primitives. This paper decribes a well known technique, object
commands, to add some object primitives to TCL. Once you understand how
object commands work, you will be able to figure out the code of most object
packages and extensions.
This paper assumes that you are familiar with TCL, and that you have written at
least a few simple scripts in TCL.
|