TCL ADA SHELL
Introduction to TASH
New Thick Binding
With TASH version 8.3.2a, a new thick binding is being released. The purpose of this interface is to
Some TASH users have been attracted to TASH because they are already using Tcl/Tk and, like me, would like to use it from Ada or extend it with Ada instead of C. Many of these users are already familiar with Tcl/Tk and its C interface made public in the header files tcl.h and tk.h.
Others prefer not having to learn Tcl/Tk but would like to use, in an Ada program, some the capabilities of Tcl/Tk such as:
In my case, I'd also like to be able to write programs in Ada for which I'd normally use a scripting language such as Bourne, Perl, Tcl, or awk. These languages typically provide built-in functions for interacting with the operating system and reading and processing text files at a much higher level than do compiled languages such as C and Ada. PERL, after all, stands for Practical Extraction and Report Language.
Also, what I had formerly called the thick binding to Tcl was not really a thick binding. It was merely a rehash of the thin binding (a translation of the tcl.h header file to Ada) while using Ada data types, exceptions, and generics, in place of C data types, integer return codes, and Tcl ClientData type.
Prior to version 8.3.2a, TASH was not really taking advantage of the new Tcl object system which debuted in Tcl version 8.0. The Tcl object system is a very clever implementation of dual-ported and typed variables intended to speed the execution of Tcl but yet be backwards compatible with the fact that Tcl variables were all of string type. You can read more about it in What's New in Tcl 8.0.
So, with the new thick binding, I have set out to implement Tcl/Tk functionality in an Ada style.
These packages have been implemented so far:
To promote simplicity of use, users of the thick binding need not create and initialize a Tcl interpreter. This is done automatically upon elaboration of the thick binding package. The interpreter itself is in the private part of the package Tash and is in a protected type so that multiple tasks may freely call any Tash operation. One limitation, of course, is that you can have only one interpreter. This seemed like a reasonable compromise to gain the simplification of leaving out the interpreter parameter in all subprogram calls.
For a concrete example of using the new thick binding, see the plang program in the apps directory.
TASH includes both thinner and thin bindings to Tcl. The thinner binding is a direct translation of the public Tcl interface, tcl.h. It is implemented in the Ada packages Tcl. It includes all the definitions in tcl.h, both functions and data types. All data types are implemented with Ada equivalents from Interfaces.C. All functions take C data types and use return codes for status information.
In addition to the thinner binding, TASH provides a thin binding to Tcl. This binding replaces C data types with Ada types (e.g. String is used in place of Interfaces.C.Strings.Chars_Ptr), uses exceptions in place of return codes and uses generic packages to to implement Tcl clientdata types.
The TASHELL Interpreter
The Tcl distribution includes a Tcl shell interpreter, named tclsh. The TASH binding derives its name from the Ada version of the Tcl shell interpreter: Tcl Ada SHell. Just like tclsh, tashell reads and interprets a Tcl script. It is also a good starting point for building a custom Tcl interpreter in which new Tcl commands are implemented in Ada rather than C.
An early paper describing the rationale of the design of TASH is available in several different formats in the docs directory.
Tk Thin Binding
TASH also includes both thin and thick bindings to Tk. The thin binding is a direct translation of the public Tk interface, tk.h, and is implemented in the Ada package, Tcl.Tk.
Tk Thick Binding
An early, experimental thick binding to Tk is provided in the Ada package, Tcl.Tk.Ada. This binding does not support all Tk widgets and has not yet been upgraded to take advantage of the new TASH thick binding or the Tcl object system.
The TWASHELL Interpreter
TWASHELL is the Tcl Windowing Ada SHell. It is the Ada version of the Tcl/Tk wish program. Just like wish, it reads and interprets a Tcl/Tk script. It is also a starting point for building a custom Tcl/Tk interpreter in which new Tcl/Tk commands are implemented in Ada rather than C.
An early paper describing how TWASH is a Platform-Independent toolkit for development of Graphical User Interfaces is available in several different formats in the docs directory.