Skip to content

ASCII Representation of APL Characters

Vector 11:4, page 131

language design APL in perspective

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

Introduction

Because of the problems in printing non-standard characters and of transmitting them on computer networks, there is a continuing concern with problems posed by the APL character set.

The situation at the time of designing the character set is described in the following passage from [1]:

Spelling

In natural languages the many words used are commonly represented (or spelled) in an alphabet of a small number of characters. In programming languages the words or primitives of the languages (such as sin and =:) are commonly represented by an expanded alphabet that includes a number of graphic characters such as + and =.

When we came to implement APL, the alphabet then widely available on computers was extremely limited, and we decided to exploit a feature of our company’s newly-developed Selectric* typewriter, whose changeable typing element allowed us to design our own alphabet of 88 characters. By limiting the English alphabet to one case (majuscules), and by using the backspace key to produce composite characters, we were able to design a spelling scheme that used only one-character words for primitives.

Because the characters of the underlying alphabet were distinct from the composite characters, both could be used to represent primitives. However, the restriction to one-character words had a cramping effect, leading to the divergence of different systems as each chose to use different new composites, and finally to the adoption of a "quad" prefix that led to a flood of multi-character words for miscellaneous facilities.

This is analogous to the situation in Chinese, where new single-character words are seldom adopted, but where a radical may be appended to a word to denote a new meaning, introducing, in effect, a multi-character spelling of words.

Continuing the passage from [1]:

Moreover, the spelling scheme was quite mnemonic in an international sense, relying on the appearance of the symbols rather than on names of functions in any national language. Thus the phrase k↑x takes k elements from x, and ↓ denotes drop.

The endurance of the character set through the many changes in the computing environment in the past thirty years is probably due primarily to the attraction of the mnemonic properties remarked above. Again continuing from [1]:

Because the use of the APL alphabet was relatively limited, it was not included in the standard ASCII alphabet now widely adopted. As a consequence, it was not available on most printers, and the printing and publication of APL material became onerous. Nevertheless, in spite of some experiments with "reserved words" in the manner of other programming languages, the original APL alphabet has remained the standard for APL systems.

The set of graphics in ASCII is much richer than the meagre set available when the APL alphabet was designed, and it can be used in spelling schemes for APL primitives that still avoid the adoption of reserved words. Such a scheme using variable-length words was presented in Reference 6 [Reference 2 in the present paper], and received limited use for communicating APL programs using standard printers, but was never adopted in any commercial implementation. A much simpler scheme using words of one or two letters was adopted in J, in a manner that largely retains, and sometimes enhances, the mnemonic character of the APL words.

Names of Variables and of Primitives

The discussion thus far has concerned only names for primitives, that is, names whose referents cannot be changed by the programmer. A programmer also needs a class of so-called variable names whose referents may be changed at will.

By using only letters from a native alphabet for variable names, and only names that include special graphic symbols for primitives, APL provides a clear distinction between primitive and variable names, and avoids the blurring of the classes produced by declaring certain variable names to be reserved for primitives.

This distinction carries through to national languages other than English, provided only that all characters of the national alphabet (including accented characters) be included in the underlying system and be permitted in variable names. Unfortunately, the use of some letters from the Greek alphabet for APL primitives prohibits their use in variable names.

Representations for APL Primitives

The universal adoption of the ASCII character set on computer systems makes it possible to choose a clearly-defined class of names for APL primitives that do not conflict with national names for variables: denote each primitive by an ASCII graphic or by one or more ASCII graphics appended to a (possibly empty) list of national letters.

For example, the ASCII double-quote might be used as follows:

i"     for APL iota
av"    for quadAV (the underlying alphabet)
/"     for slash-bar
r"     for rho (shape)

It would also be possible to introduce a second termination symbol, or to use two occurrences of the same symbol. For example:

/% or /""     for grade-up
\% or \""     for grade-down

Although the accent grave is a National Use symbol in ASCII, it might well be used in some languages as a less obtrusive terminal character. For example:

/`     for slash-bar
/``    for grade-up
\`     for backslash-bar
\``    for grade-down

This scheme will be further illustrated for the special characters in the list on pages 327-9 of Gilman and Rose [3]. It should be noted that * is not used alone in ASCII because * is used (for power) in APL:

≤     <`          ≥     >`
≠     =`
∨     +`          ⍱     +``
∧     *`          ⍲     *``
÷     %           ×     *`          [?! Ed]
∊     e`          ⍴     r`
↑     take`       ↓     drop`
⍳     i`
∘     o`          ○     O`
⌽     r0`         ⊖     r1`
⍉     tr`         ⍟     lg`
⌈     max`        ⌊     min`
⍋     /``         ⍒     \``
⊥     #`          ⊤     #``
⍎     exe`        ⍕     fmt`
⌹     mi`
⌿     /`          ⍀     \`
←     is`         →     goto`
∇     del`        ⍫     del``
∆     delta`
⎕     quad`       ⍞     qq`
⍝     `           ⋄     ``
S∆    stop`       T∆    trace`

References

[1] K.E. Iverson, "A Personal View of APL", IBM Systems Journal, Vol. 30 no. 4, 1991

[2] K.E. Iverson, "A Dictionary of APL", APL Quote-Quad 18 no. 1, 202-211, ACM, New York, 1990.

[3] L. Gilman and A.J. Rose, APL, An Interactive Approach, Second Edition, Wiley, 1974.