TinyTcl

An experimental (and rudimentary) Tcl interpreter in C++

                        "TinyTcl Is Not Yet Tcl"

Project status as of January 5, 1999

  - passes some basic Tcl 7.6 tests from "concat.test" and "list.test"
  - still fails on a handful of these, but several dozen pass
  - needed kludges in "all" to make tests work, other files unmodified
  - major omission: no arg checking on built-in commands whatsoever
  - exception handling works, but error checks are almost non-existent
  - current approach uses a "switchable object representation", lists
    and arrays are converted when accessed as such, replacing the
    string representation (and back when accessed as string again)
  - arrays are not special, as strings they simply act/look like lists
    of the form: "key1 value1 key2 value2 ..." (all keys are sorted)
  - performance is still very low, but byte-code compilation or any
    other similar technique is expected to be relatively easy to add
  - new semantics for major/minor commands:
        proc abc def {arg1 arg2 args} {blah...}
    defines script to run when "abc def ..." is called
    allows mixing builtins and scripts
  - upvar and uplevel work (but don't recognize a level arg yet)
  - no namespaces, but a first step to add this has been made
  - no variable tracing, might need a considerable amount of work
  - expr works, but no floating point and no math functions
  - strings are based on an new/unconventional "TsString" class:
        - implemented with <ptr,len> tuples, accepts binary data
        - no terminating chars, extra class provides 0-terminated copy
        - main motivation: prepare for use of memory-mapped files
        - buffering is designed to work with non-contiguous segments
        - allows delayed concatenation, join, and substring sharing
  - uses STL internally for lists and arrays, but no STL in core API
  - string, list, and array references use automatic reference counts
  - simple C++ virtual call based package mechanism, a lot of cmds
    are separately packaged in "tclcmds.cpp" (and therefore optional)
  - only "glob" and "source" implemented for I/O (Windows), and "puts"
  - developed on MSVC 6 (Win98), less than 4000 lines of C++ (64k EXE)
  - also works on Linux/egcs and Cygwin B20.1 (with auto_ptr disabled)
  - don't look for any documentation, this is all there is...

Download

Source and Win32 EXE:

        /pub/etc/tinytcl.zip

Directory structure:

        tcl/src/        contains source code
        tcl/unix/       is the build area for Unix and Cygwin
        tcl/win/        contains the MSVC 6 project file (*.dsw)

Copyright and license information

  The following notice applies to all files in this distribution:
  --------------------------------------------------------------------
  Copyright 1998,1999 by Coen Siegerink.
                          All Rights Reserved
  Permission to use, copy, modify, distribute, and license this
  software and its documentation for any purpose is hereby granted,
  provided that existing copyright notices are retained in all copies
  and that this notice is included verbatim in any distributions.
  THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  --------------------------------------------------------------------

Plans and support

This is highly-experimental (read: buggy and incomplete) code, and is part of a much larger project dealing with scripting and persistence. I am releasing this code for free use, and am making a risky assumption: that any of this might inspire others.

Having said that, I do intend to make changes and improve this, so please submit bug reports and patches of changes you make.