APL Workspace and Object Storage

Here is a proposed method for saving APL objects (functions, entire workspaces) in a JavaScript running environment.

I was toying with writing an APL interpreter again. A requirement for a useful APL implementation is the ability to be able to read (import) and write (export) workspaces or selected APL functions and variables by name.

In addition the APL character set needs to be embedded in the saved data each time so that it's so-called future-proof - i.e. be recognizable in any versions of the APL interpreter. Vendors of APL products have used several methods to address this as there is no standard for APL character coding. Different implementations use different look up tables and mappings. Cross-platform compatibility was always an issue.

I like to stick with "vanilla" or pure JavaScript for now. No browser plug-ins or libraries such as Node.js, jQuery, etc.

JavaScript was deliberately designed without file read/write capability to ensure security and stability. However, one thing it does allow is to "Save Image As" an image that's been rendered on the screen.

This is a proof-of-concept idea. Image save and retrieval is used in lieu of native file I/O.

What I propose is to embed in an image - using the image data domain only as opposed to metadata or manipulating file headers or chunks (PNG specification lingo). Ultimately this should really be the method used as  those areas of the PNG file are designed to contain arbitrary textural information. It may be possible to manipulate image data in JavaScript.

The method of data embedding in an image can be used with file formats: PNG, GIF, BMP, and TIFF

Normal view of an APL function as might be seen on a screen.


Saveable version. Line numbers are absent but all other aspects of the source code are preserved. Any blanks (spaces) for example are maintained.


In addition to being human-readable this image is machine-readable.

This above image would contain imperceptible pixels to encode the visible text. The data pixels are coloured near white so that they are visually imperceptible. Possible colour values are #fefefe for binary '1' and #fcfcfc for binary 0.
Note: Here they have been darkened on purpose to show where they are located and how to interpret them.

Magnified View of APL workspace object listing


Each APL character has a set of eight (8) grey coloured pixels beneath it. These represent a number from 0 to 255. For example in the first line, the seventh letter is a space and has the value 32 (binary 00100000) which corresponds to its ASCII index.

Characters that reside in non-extended ASCII from 0 to 127 are coded this way.

APL characters, or 'atoms' which are not part of normal ASCII

For all APL characters that aren't in non-extended ASCII have numeric values from 128 to 255. They require a mapping table so that they can be interpreted properly. This table is located at bottom of the image.


The character's value as used in the APL listing is referenced here as the first character in each line. Following that is a description using standard uppercase alphabet. There is a placeholder value underneath the 'A' in 'APL' - this always has value 0. It is used by a reader program to locate the beginning of the map table (reading from the bottom of the image upwards). It is guaranteed to exist.

The very bottom edge has its first data bits guaranteed to contain both "zero' and 'one" colour. This byte can never be 0 or 255. It is used to establish the colour-to-binary bit correspondence. All three channels R,G,B always match.

Here is the complete table of 'atom' names. These must be recognized by any reader program. Hopefully, by being English words whether abbreviated or not, it is self evident which APL characters they represent. A list of these atom names must exist in the reading program to form its translation table.

The APL font shown here is based on APL385 Unicode (monospaced code font) rendered with inline images so that it displays correctly without needing to have the font installed. Hover mouse over images to see Unicode code point.

⍶   ALPHA_
∧   AND
↓   ARRD
←   ARRL
→   ARRR
↑   ARRU
⍪   CATF
¢   CENT
○   CIRC
⍜   CIRC_
∇   DEL
⍙   DELTA_
÷   DIV
⍢   FROG
≥   GE
⍳   IOTA
⍸   IOTA_
∘   JOT
⍛   JOT_
⍝   LAMP
≤   LE
⍟   LOG
⌈   MAX
⌊   MIN
×   MUL
⍲   NAND
≠   NE
¯   NEG
⍱   NOR
⍹   OMEGA_
∨   OR
∵   PAW
⋆   POW
⎕   QUAD
⍴   RHO
⊆   SHOEL_

Revised 14 May 2020