APL Workspace and Object Storage
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.
This is a proof-of-concept idea. Image save and retrieval is used in lieu of native file I/O.
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.
Revised 14 May 2020