APLGOL

From APL Wiki
Jump to navigation Jump to search

APLGOL is the shared name of a series of experimental languages developed in the 1970s that organize APL expressions using ALGOL control flow. These designs are not compatible with APL because they remove Branch and make syntax changes such as ignoring line breaks in favor of the statement separator ;. However, the shared semantics make it relatively easy to compile APLGOL to APL or a shared target. APLGOL was first implemented in 1972 in APL\360 as a compiler to APL. This design was incrementally improved, with APLGOL-2 announced in 1974. APL\3000, released in 1976, featured APLGOL with equal support to APL: each function in a workspace could be written in either language.

History

APLGOL was designed by IBM Palo Alto Scientific Center employees John Walters and Robert Kelley, motivated by a 1971 class at Stanford University that Walters taught and Kelley attended. Walters taught with APL and found that the students, who were more used to ALGOL-W, disliked APL's Branch-based control flow.[1] Another influence came from Phil Abrams:[2] in his Stanford Ph.D. dissertation, "An APL Machine", Abrams uses "an informal dialect of APL" featuring ALGOL-like control structures IF, CASE, and REPEAT.[3] Kelley implemented the first compiler in 1972, and continued to make improvements with Walters at Palo Alto, including adding a reverse compiler to undo the APLGOL to APL compilation. By 1974 the pair had begun working at Hewlett-Packard, where they announced the APLGOL-2 system.[4] At HP, both would work on APL\3000—with Walters as development lead—joining with Phil Abrams for compiler development. APL\3000 provided equal implementation support for the two languages by compiling both APL and APLGOL functions to a shared "S-code" representation.[5]

Syntax

While the purpose of APLGOL was to support control structures and remove Branch, it also featured other changes to make the syntax more like ALGOL.

  • Defined function begin with PROCEDURE preceding the header, and end with END PROCEDURE.
  • Statements are separated with ;, while line breaks can be freely placed like spaces.
  • Comments are written with a starting and ending rather than starting only.

The specific control structures added and their syntax changed with different iterations of APLGOL. In most versions, each control word began with an underlined character, but this was not the case in the APL\3000 implementation.

Implementation and usage

In all implementations, APLGOL was interoperable with APL: a given function had to be written either entirely in APL or entirely in APLGOL, but the two types of functions could freely call each other. Some versions had an APLGOL-specific editor to support creating APLGOL functions.

In APL\360, functions were compiled from APLGOL to APL using a compiler implemented initially in APL, and later in APLGOL as well.[2] In order to store the APL code only, avoiding the need to re-compile APLGOL source or store two copies, a back-compiler was implemented that could convert APL output by the compiler—not APL source in general—to an APLGOL input that would produce the same code.

In APL\3000, either APL or APLGOL could be converted to "S-code", a branch-based intermediate representation suitable for further compilation. While the target hardware's branches were more like APL's Branch than control structures, compiled APL required the argument to Branch to be range-checked to have the correct semantics, while branches produced by APLGOL didn't need this check and thus evaluated more quickly.

APLGOL compilers also translated the code to a "canonical form" with one statement per line and indentation for control structures, much like modern auto-formatting. This formatting is introduced by the back-compiler as a side effect of storing the compiled (as APL or S-code) representation rather than the source code. This process was also able to correct some minor errors in the input source.[4]

References

  1. Harwood G. Kolsky. APLGOL a structured programming language for APL. Programming Methodology. IBM, 1974.
  2. 2.0 2.1 R. A. Kelley. APLGOL, an experimental structured programming language. IBM Journal of Research and Development, Volume 17, Issue 1. 1973-01.
  3. Phil Abrams. An APL Machine. SLAC. 1970-02. Appendix B, p. 143.
  4. 4.0 4.1 Robert A. Kelley and John R. Walters. "APLGOL-2 a structured programming language system for APL" at APL74.
  5. Ronald L. Johnston. "APLGOL: Structured Programming Facilities for APL". Hewlett-Packard Journal, July 1977, pp. 11–13.
APL dialects [edit]
Maintained APL+WinAPL2APL64APL\ivApletteAprilCo-dfnsDyalog APLDyalog APL Visiondzaima/APLGNU APLKapNARS2000PometoTinyAPL
Historical A Programming LanguageA+ (A) ∙ APL#APL2CAPL\360APL/700APL\1130APL\3000APL.68000APL*PLUSAPL.jlAPL.SVAPLGOLAPLXExtended Dyalog APLIverson notationIVSYS/7090NARSngn/aplopenAPLOperators and FunctionsPATRowanSAXSHARP APLRationalized APLVisualAPL (APLNext) ∙ VS APLYork APL
Derivatives AHPLBQNCoSyELIGleeIIvyJJellyK (Goal, Klong, Q) ∙ KamilaLispLang5LilNialRADUiua
Overviews Comparison of APL dialectsTimeline of array languagesTimeline of influential array languagesFamily tree of array languages