A+ is an array-oriented programming language that provides
In A+, the ordinary concept of arrays has been enhanced to provide
- a rich set of primitive functions that act efficiently on arrays
- general operators that control the ways functions are applied to arrays.
These features are realized in A+ by furnishing global variables with
- 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.
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.
- 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.
Other A+ features are
- conventional control structures
- contexts, or separate namespaces, in a single workspace
- dynamic linking of C functions, which can be called like ordinary A+ defined functions
- a Unix operating system environment
- an Emacs-based application development environment
- asynchronous communication between processes, based on A+ arrays.
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.
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
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.
- specifying only the leading axis index, and
- specifying it to be a single, scalar value
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 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.
Screens show views of arrays. 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.
A+ operates under various forms of Unix (Linux, Solaris, AIX, ...). A+ processes can be started from a shell or an Emacs or XEmacs session. Hereafter, "Emacs" is used here in a general sense, to mean Emacs or Xemacs. Emacs provides the application development environment for A+. It is possible to work in desk calculator mode in an A+ process started under Emacs. In this mode the user's view of the A+ process is an interactive session, where expressions can be entered for evaluation, and results are displayed. A session log is maintained, and can be referenced during the A+ session and saved at the end for future reference. Desk calculator mode is also the default for an A+ session started in a shell, but it is more common to use these A+ sessions for running applications with desk calculator mode turned off. In case an application fails, the appropriate entries to a log file can be written, or the A+ process can be permitted to return to desk calculator mode for debugging. An A+ process can communicate with other processes, A+ or not A+, through a communications interface called adap (see "Interprocess Communication: adap").
The A+ mode in Emacs provides programmers with very effective ways of testing and debugging applications. Programmers usually work with two visible buffers, one containing an A+ process and the other the source script of an application. Function keys provide the means to move either a single line from the script to the A+ process, where it is automatically executed, or an entire function definition. It is also possible to scroll back in the session log to bring expressions and function definitions forward for editing and reevaluation.
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. Unix 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.
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.
A+ uses the APL Union Keyboard. The special APL characters are entered by pressing a key while pressing either the Meta key, or both the Meta and Shift keys. The Meta keys (on Sun keyboards) are on either side of the space bar and are marked with diamonds. IBM keyboards have no Meta keys; use the Alt key, similarly situated, instead of Meta.
Note: Meta-Shift-m looks like Meta-m and Shift-\ but does not represent an A+ function.
An Interactive Keyboard Chart is also available, providing additional information about each of the A+ symbols and functions.
Click here for a keyboard diagram which will print more clearly on a black-and-white laser printer.
This figure is available as a printed Keyboard Reference Chart Tentcard, which is designed to stand up on your desktop beside your workstation. To request a copy, contact firstname.lastname@example.org.
email@example.com © Copyright 19952008 Morgan Stanley Dean Witter & Co. All rights reserved.