Thales Clang Draft Spec

$Id: thales.wml,v 1.4 2000/09/07 12:34:24 ajk Exp $
Antti-Juhani Kaijanaho
gaia@iki.fi
Dept. of Mathematical Information Technology
University of Jyväskylä

WARNING! This document is extremely unstable. You should not depend on any of it to remain as it is.

Introduction

The ZigZag Structure

The ZigZag structure consists of cells, cell content and connections between cells along dimensions. Each cell has content (either a string or a span), and cells are connected along dimensions. Dimensions have unique names. Dimensions have two directions: the positive direction and the negative direction. A cell may have at most one connection along a dimension on a direction. The term posward means the positive direction and the term negward means the negative direction; in English text they are used analoguously to such terms as rightward and upward. A particular instance of the ZigZag structure is called a ZigZag space.

Cell references in ZigZag: the cursor mechanism

Thales Clang Syntax

Thales Clang has six syntactic forms: cell literals, primitives, cell denoters, applications, sequences and abstractions. Instances of these syntactic forms are called expressions.

All expressions have an identity cell, a cell that denotes the expression as a whole. The identity cell of all expression is a member of a rank along the dimension d.thales-syntactic-form. The headcell of that dimension determines the syntactic form of the expression. An expression can incorporate another expression as a subexpression by incorporating in its structure a clone of the subexpression's identity cell.

Cell literals

A cell literal is a cell that statically represents a cell. It is its own identity cell. The cell literal refers to the cell in the structure that it represents, using the cursor mechanism.

Primitives

A primitive is a cell that represents a primitive operation implemented outside Thales Clang. It is its own identity cell.

Primitive cells are mapped to their implementations using the following mechanism. From the home cell, a rank along d.thales-primitives enumerates all known primitives. Each primitive cell is connected posward along d.thales-primitive-binding to a cell whose content is a magic cookie (a string) used to identify the primitive.

Cell denoters

A cell denoter is a cell that dynamically represents a cell. It is its own identity cell. It is an error for a non-clone cell denoter to appear as a subexpression outside the abstraction parameter list (see section~).

Applications

An application expression is a rank of cells along d.thales-application. The cells in that rank must be identity cells or clones of identity cells. The identity cell of this expression is the headcell of the rank. The headcell of the rank must be a clone of the identity cell of either a primitive expression or an abstraction expression.

Sequences

A sequence expression is a rank of cells along d.thales-sequence. Its identity cell is the headcell of that rank, and the rest of the cells must be clones of identity cells of identity cells or identity cells of application expressions.

Abstractions

An abstraction expression is a subspace generated by the expression identity cell with respect to the dimensions d.thales-sequence and d.thales-application.

The rank along d.thales-application from the identity cell excluding the identity cell itself and the posend cell of the rank contains a list of formal parameters for this abstraction. The posend cell of the rank must be an identity cell of another expression, known as the body of the abstraction.

Informal semantics

The mechanism by which an application expression whose identity cell is a clone of a primitive is evaluated is implementation-defined.

An application expression whose identity cell is a clone of the identity cell of an abstraction is evaluated as follows:

The subexpression denoted by the headcell of the expression rank is evaluated. The resulting value will be an abstraction. A fresh environment is created with exactly as many positional slots as the abstraction value has parameters and one ``inherited environment'' slot. The environment captured by the resulting abstraction value is bound to the ``inherited environment'' slot of the fresh environment. The rest of the cells in the application rank are evaluated in negative-to-positive order and the results are bound to the corresponding positional slots. A fresh activation record is created, and the fresh environment is bound to its environment slot. The current active activation record is bound to the fresh AR's saved AR slot. The fresh AR is made current active AR. The body of the abstraction is now evaluated. The AR in the current active AR's saved AR slot is made current active AR. The result of this evaluation is the result value of the body.