The A Project->Overview of A
Overview of A
  First Encounter
  Current Status
  GNU License
Getting Started
Overview of A
  Structure of Data
  Relation to other APLs
  Language Reference
  System Fns and Vars
Where next

Vector Home

Overview of A

This page has been reproduced from original A+ documentation provided by Morgan Stanley at Copyright remains with the authors.

Summary of the A Programming Language

A+ is an array-oriented programming language that provides

  • a rich set of primitive functions that act efficiently on arrays
  • general operators that control the ways functions are applied to arrays.

In A+, the ordinary concept of arrays has been enhanced to provide

  • a means by which files can be treated as ordinary arrays
  • a variety of simple, straightforward ways of displaying and editing data on a screen, with automatic synchronization between displayed data and the contents of variables
  • generalized, spreadsheet-like interactions among variables.

These features are realized in A+ by furnishing global variables with

  • the attribute of being specific to one A+ process or more generally accessible
  • visual attributes such as font and color, analogous to the ordinary attributes of shape and type
  • asynchronous execution of functions that have been associated with variables and events
  • definitions describing the spreadsheet-like relations among their values.

Global variables with associated definitions involving other global variables are called dependencies. The values for an interrelated set of dependencies are automatically kept as current as needed: if an object changes, any variable that is dependent upon it is recalculated just before the next use of that dependent variable. Although these spreadsheet-like relations are not new in principle, the definitions on which they are based can employ the full A+ programming language. In particular, the spreadsheet concept of a cell is not restricted to a scalar in A+, but can be any array, so that much more data can be managed by these relations than is usual for spreadsheets, and more efficiently. Similarly, the spreadsheet paradigm is not limited to numeric relations. For example, the concept of a view in a relational database can be realized as a dependency on the source data.

Other A+ features are

  • conventional control structures
  • contexts, or separate namespaces, in a single workspace

Some Features of the A+ Language

The primitive functions of A+, a variant of APL, can be classified as scalar, structural, or specialized. A scalar primitive is applied independently to the individual elements of its array arguments, but syntactically it can be applied to an entire array, providing a very efficient implicit control structure. The scalar primitives include the ordinary arithmetic functions, comparison functions, logical functions, and certain other mathematical functions. A structural primitive is one that can be defined completely in terms of the indices of its right argument: it rearranges or selects the elements of that argument but otherwise leaves them unmodified. The specialized primitive functions include, for example, ones for sorting arrays and inverting matrices.

Leading Axis Operations

Most A+ structural primitive functions, and functions derived from the operators called Reduce and Scan, apply to the leading axis of the right argument (cf. "The Structure of Data"). These structural A+ primitives are Catenate, Take, Drop, Reverse, Rotate, Replicate, and Expand. The subarrays obtained by

  • specifying only the leading axis index, and
  • specifying it to be a single, scalar value
are called the items of the array. Another way to say that a structural function applies to the leading axis is to say that it rearranges the items, but not the elements within the items.

Rank Operator

The concepts of leading axis and item are generalized by treating an array as a frame defined by the array's leading m axes holding cells of rank n defined by the array's trailing n axes, where m+n is the rank of the array. A function f is applied to all cells of rank n with the expression f@n. The rank operator (@) applies uniformly to all functions of one or two arguments: primitive, derived, or defined, except Assignment and (because of its syntax) Bracket Indexing (@ does apply to Choose, which is semantically equivalent).

Mapped Files

Mapped files are files accessed as simple arrays. These files can be very large (currently of the order of a gigabyte). Only the parts of a file that are actually referenced are brought into real memory, and therefore operations that deal only with parts of files are particularly efficient. Unless the files are extremely large, the transition from application prototypes dealing with ordinary arrays to production applications using mapped files requires only minimal code modification.


A workspace is where computation takes place and where all immediately available A+ objects reside - variables, functions, operators, and so on. An array can be displayed on a screen with the show function. The array in the workspace and the screen view share the same storage. Changes to the array in the workspace are immediately reflected on the screen. Changes can be made to the screen view of the array, and they immediately change the array in the workspace. (The word workspace is also used in a different sense in screen management, to denote the leading top-level window.)


Callbacks are automatic invocations of functions that have been associated with variables and events. Specification of a variable or selection of a row in its screen display, for example, can trigger the execution of a callback function. Callbacks provide a complete means of responding to asynchronous events.


Dependencies are global variables with associated definitions. When a dependent variable is referenced its definition will be evaluated if, generally speaking, any objects referenced in the definition have changed since its last evaluation. Otherwise, its stored value is returned. Thus dependencies, like functions, always use the current values of the objects they reference, but are more efficient than functions because they do not reevaluate their definitions until at least one referenced object has changed.


Utilities and toolkits can be included in applications without name conflicts, by using contexts, which allow utility packages and toolkits to have their own private sets of names. Outside a context, names within are referred to by qualifying them with the context name. System commands and system functions provide facilities for working with contexts, such as changing the current context and listing all contexts in the workspace.


Programmers are concerned with three things when writing A+ applications: data, analytics (i.e., computations), and the user interface. The data of interest either reside in files accessible to the application or are maintained by another process. The analytics are the computations run on the data, and the user interface is the means for presenting the data or various aspects of the analytics to users. A+ has been designed for efficient programming of all three aspects of application production, and for efficient execution as well.

Data in files are usually maintained in A+ as so-called mapped files (see "Files in A+"), which are simple (i.e., not enclosed, or nested) arrays. Once an A+ application has opened a mapped file, it deals with it much as it would an ordinary array of its own creation. Mapped files can be shared, although shared updates across the network are problematical, unless mediated by a single process. Text files can also be copied into and written out of A+ processes.

Real-time data, which is of the utmost importance to many A+ applications, is accessed through an interprocess communication toolkit called adap. This toolkit provides a small number of functions for establishing and maintaining communication between an A+ process and other processes, such as a set of real-time data managers that read and write A+ arrays.

As an array-oriented language with a set of primitive functions that apply directly to entire arrays, A+ provides very efficient processing of functions that apply to large collections of data, often with less code than more conventional programming languages. Less code generally means fewer chances for failure; moreover, the A+ language processor is interpretive, which makes debugging relatively easy. Unless you take advantage of array calculations, however, being in an interpretive environment is likely to hurt you in performance. Thinking in terms of array algorithms is both a requirement and an opportunity, and it differentiates development in APL-derived environments from development in most other environments.

Application user interfaces are built with the A+ screen management system, a toolkit that relies on a small number of functions to create and interact with a variety of screen objects, such as buttons, tables, and layouts. See the chapters on screen management, display classes, and display attributes.

Script Files

Applications are maintained in text files called scripts. Scripts contain function and data definitions and executable expressions. A+ has specific facilities for loading scripts. Loading a script has much the same effect as entering the lines of the script one at a time in desk calculator mode, starting at the top. Scripts can contain the A+ expressions for loading other scripts. Consequently application scripts do not have to contain copies of utilities and toolkits, and A+ applications tend to be very modular.

Back to Home page© Copyright 1995–2001 Morgan Stanley Dean Witter & Co. All rights reserved.

© British APL Association 2001
Please send any comments to Adrian Smith via - thank you.