Skip to content

A New Development Environment in Dyalog APL

Vector 6:4, page 101

implementations user interfaces

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 101

The following is a reprint with minor revisions, of an article which appeared first in APL-CAM the journal of the Belgian APL Users Society and is reproduced here by kind permission of Joseph De Kerf.

Abstract

Much of APL’s productivity comes from its development environment. The ability to stop and review the state of execution at any point is a considerable help when producing code. However the procedure available on many APL systems is twenty-five years old and was designed for hard-copy devices. The new Dyalog development environment makes use of memory-mapped screens to give the APL developer a modern ‘visible computing’ interface.

Introduction

APL is renowned for the speed with which you can produce programs. This speed is due partly to the language itself and partly to the power of APL’s development environment.

Much of the power of the language, comes from its ability to let us think at a more abstract level. This means that the language itself frees us from worrying about the more mundane low level tasks present in other programming systems. Tasks such as space allocation and the scalar processing of arrays. However, perhaps not quite so apparent but equally important, is APL’s provision of a powerful development environment.

Much of the time spent in producing software is in the refinment of programs. This means in reviewing defined functions; in testing and changing both individual lines of APL and in moving groups of lines inside and between functions.

When APL first appeared in the mid-sixties, no other popular programming system provided development tools nearly as powerful. It gave us:

  • Visual fidelity or what is now called WYSIWYG input, albeit only for the current input line.
  • The ability to stop the execution at any line of code and examine and change local variables.
  • An editor with which we could examine and correct the currently stopped function.
  • The ability to restart the function and continue processing.

However, that was a quarter of a century ago and many of the constraints placed on its design have long since been lifted. The original APL ran on a 14.7 cps (~150 baud) hard-copy typewriter. Now we have, in general use, colour screens where the whole screen can be updated ‘instantaneously’, that is, between successive refreshes.

Dyalog has been able to use this technology to produce a much more powerful development tool. We have not changed the language in any way in doing this and in fact, you may write your code without using the new facilities, although they are always close at hand if you do choose to.

The New Environment

The environment consists of three main parts:

  • The SESSION where lines of APL are entered, evaluated and results displayed.
  • An EDITOR in which lines are gathered to form functions and operators.
  • A TRACER, used to monitor the detailed execution of statements.

An important property is that wherever possible, the environment is ‘seamless’. This means that we can move freely among the various parts of the environment without having to change the syntax that we use to manipulate code lines.

An example is the <EXIT> key which is used to close both TRACER and EDIT windows. Another example is with string searching. The search works identically throughout the system so you can search for a string in a function and then tab to the session and continue the search there.

This scheme has a major impact on productivity as it allows you to concentrate on the task at hand without worrying about the superficial problems of which ‘mode’ you are in.

We must all have suffered for instance, at one time or another, the distraction of wanting just to exit from the current environment and having to lose our train of thought in order to experiment with: quit, bye, x, Control-C, )OFF, exit, Esc …

Here is a brief overview of the parts of the development environment.

The EDITOR is window-based:

)ED FN1 FN2 ...

… opens a window for each function. The default windows occupy the top right hand quarter of the screen and overlap with just enough displacement to reveal the name of the function underneath. You can move and resize the windows at will and the <ZOOM> key toggles between this and full-screen mode where each function occupies the whole screen. <TAB> moves between the windows and to the session.

The editor itself is modeless in the sense that operations on the text of the function, such as moving and copying blocks of lines, use special keys away from the main "QWERTY" part of the keyboard. Typing "QWERTY" keys always results in text appearing in the function.

When editing a function, we can, using the <TAG> key, identify a block of lines of code. The tagged block may then be deleted, or moved or copied elsewhere. To copy the block to another function, we <TAB> to the function, cursor to the required line and <COPY> the block. If we <COPY> a block of lines to the session, the lines are executed sequentially. Similarly, a block of lines in the session may be <TAG>’d and copied into a function. An edit window may also be opened for a function by cursoring to its name anywhere on the screen and typing the <EDIT> key. This feature called "point and edit", is a great time saver.

An unusual feature of the editor is that it maintains a complete history of changes. This means that you can undo not just the last change made to the function, but using the <BACK> and <FWD> keys undo and reapply each change made since entry to the editor.

The SESSION allows you to enter lines of APL for immediate execution in the normal way. It maintains a history so that previous lines may be changed and resubmitted. When you type over a line in the session, the line is highlighted and we say it is MARKED. You can mark any number of lines in the session and when you type <ENTER> each marked line is copied to the input line (restoring the session line to its original state) and executed.

The TRACER lets you examine the execution of a line of code. If you terminate a session input line with <TRACE> instead of <ENTER>, each defined function (or operator) in the line is displayed in a window as it is entered. The function is suspended on the first line, and you can choose either to execute the line by typing <ENTER> or trace it by typing <TRACE>. In this way, you can step through each line of the execution of an APL statement. At any point in the trace, you can of course, tab back to the session and execute other lines of code. The overlapping windows during a trace represent the state indicator.

Responding to the trace with the <EDIT> key, changes the current trace window into an edit window. This allows extremely easy access to the top suspended function allowing you to change the function "on the fly" and <EXIT> the edit to resume tracing.

Within the tracer, you can use the <BACK> key to repeat and <FWD> key to skip lines in the function.

The <EXIT> key from within the tracer, removes the top window from the stack and suspends the calling line. In effect, it cuts the state indicator back just one level. This effect, which seems completely natural in this environment, and which is comparatively clumsy in other APL systems, is a powerful example of the correctness of the seamless approach.

The TRACER may also be started retrospectively. That is, if the interpreter encounters an error during execution of your program it suspends execution in the normal way. You can then hit <TRACE> and have the system recreate the trace stack as if you had traced your way to the point of suspension. You can then continue tracing from that point. Typing ]Llc in the session during a trace resumes normal non-traced execution of the program.

Conclusion

Trying to give a flavour in words, of a piece of software which owes much of its power to the way it behaves visually is difficult. If you would like to see the development environment in action, you can obtain a free demonstration disk from Dyadic Systems or any Dyalog APL distributor.

Dyadic Systems Ltd,
Park House,
The High St.
Alton, Hants GU34 1EN
Tel 0420 87024
Fax 0420 89886