#  | # 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 simplify and "Ada-fy" the capabilities of the Tcl scripting language, make access to Tcl facilities task-safe, and manage memory allocation of TASH (Tcl) objects. 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: list handling text file processing regular expression pattern matching and substitution platform-independent file and directory functions associative arrays execute other programs and connect to their standard input and output C-style printf platform-independent GUI toolkit 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:
Package | Purpose
--- | ---
Tash | This is the parent package of the new thick binding packages. It declares a tagged, controlled type which is the base type for all Tash data types. The body of this package implements the Tash data types finalization subprograms, creates a Tcl interpreter, and provides task-safe access to the interpreter.
Tash.Lists | Implements the Tash list object which provides a heterogenous list handling data type. Typically list handling functions are included such as insert, append, and delete. Other functions implemented are capabilities to create lists by splitting strings at specified characters, join list elements to form a string, and sort lists.
Tash.Integer_Lists | This is an instantiated generic package for inserting, appending, and fetching Integer list data elements.
Tash.Float_Lists | This is an instantiated generic package for inserting, appending, and fetching Float list data elements.
Tash.Regexp | Provides regular expression pattern matching and substitution on strings and Tash lists.
Tash.Arrays | Provides associative array capabilities. Array element indices are strings and element values are strngs, lists, integers, or floats.
Tash.Integer_Arrays | This is an instantiated generic package for handling Integer array elements.
Tash.Float_Arrays | This is an instantiated generic package for handling Float array elements.
Tash.file | Provides platform-independent file and directory handling capabilities such as getting and setting file attributes, time last accessed, time last modified, getting file name portions (directory, extension, tail, root), determining whether a file exists, is executable, is readable, is writable, or is a directory, etc.
Tash.file_io | Provides functions for opening, closing, reading, and writing files. Particularly useful is the capability to open and read or write from a command pipeline.
Tash.Platform | Provides information about the platform such as byte order, machine (intel, PPC, 68k, or sun4m), OS, OS version, platform (windows, macintosh, or unix), and user name.
Tash.system | Provides system information such as the process identifier of the current process.
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. ### Thinner Binding 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. ### Thin Binding 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.