1. Introduction

The xtal Tcl extension implements the Xtal language which provides a more succint syntax for working with typed arrays.

This document is the reference for Tcl commands related to working with Xtal scripts. It does not describe the language itself which is described in The Xtal Language.

See the main contents for guides and other reference documentation.

1.1. Installation and loading

Binary packages for some platforms are available from the Sourceforge download area. See the build instructions for other platforms.

To install the extension, extract the files from the distribution to any directory that is included in your Tcl installation’s auto_path variable.

Once installed, the extension can be loaded with the standard Tcl package require command.

% package require xtal
→ 1.0.0

2. Command reference

All commands are located in the xtal namespace.

2.1. Commands

compile ?-encoding ENCODING? XTALFILE TCLFILE

Translates the Xtal script in the file specified by XTALFILE to the Tcl equivalent and writes it out to the file TCLFILE. The -encoding option may be specified to indicate the character encoding and applies to both files. System encoding is assumed by default.

function NAME ARGS BODY

This command is like the Tcl proc command except that BODY is a Xtal script and not a Tcl script.

method CLASS METHOD ARGS BODY

Defines a method named METHOD for a TclOO class CLASS. BODY is a Xtal script and not a Tcl script.

objmethod OBJ METHOD ARGS BODY

Defines a object method named METHOD for a TclOO object OBJ. BODY is a Xtal script and not a Tcl script.

shell ?-prettify BOOLEAN? ?-lang LANGUAGE?

Enables the Xtal shell within a Tcl interactive session. The Xtal shell is a plug-in that adds the ability to interactively run Xtal within standard Tcl shells like tclsh and tkcon.

The command can also be used to change the shell options when it is already running.

For a full description of the Xtal shell, options and its use, see The Xtal shell.

source ?-encoding ENCODING? PATH

Like the Tcl source command except that the source file, specified by PATH, is expected to contain Xtal script which is then executed in the caller’s context. The -encoding option may be specified to indicate the character encoding of the file. Otherwise system encoding is assumed.

translate XTALSCRIPT

Translates the specified Xtal script to Tcl and returns it.

translate_file ?-encoding ENCODING? PATH

Translates the Xtal script in the file specified by PATH to the Tcl equivalent. The -encoding option may be specified to indicate the character encoding of the file. Otherwise system encoding is assumed.

xtal SCRIPT

Executes a Xtal script in the caller’s context.