Previous Article
Return to Newsletter
Next Article

Adding a pinch of SALT


Version 11.0 introduces classes to APL.

Classes typically contain several functions, and one of the things that is different about classes is that the entire source for the class can be extracted as a single "script", using the new system function ⎕SRC. For example:

In version 11.0, namespaces only have the script form if they were created using the editor or using the ⎕FIX function. Namespaces created using ⎕NS do not have a script.

Modern operating systems and development tools have good support for files containing Unicode text, which means they can contain APL symbols as well as all "human scripts" in current use, plus "extinct" languages like Hieroglyphs, Tolkiens Tengwar scripts, and Klingon (very few fonts exist which contain all of these languages, but they are on the way). Windows allows you to select so-called Input Mode Editors (IMEs) which define keyboards for subsets of Unicode, and Dyalog provides an IME which reads your standard input translate table and provides an APL keyboard for use with text editors and other non-APL applications. All of the above combined make it attractive to look at storing classes and namespace scripts in text files and using standard tools to manipulate them.

Enter SALT

SALT is the Simple APL Library Toolkit, a tool for storing class and namespace scripts in text files, providing an alternative to the workspaces or component files as repositories of APL source code. In a nutshell, SALT allows you to save to, load from and list files containing classes' source. The source code can be edited in APL, or files with source in them can be edited with an editor that supports Unicode files (UTF-8 or UCS-2 file formats, to be precise).

When SALT saves a class' definition (source) onto a file it uses the extension 'dyalog'.

The Dyalog version 11.0 installer sets up an association which instructs Windows to open these files with Notepad, a very simple text editor included with windows – which supports Unicode. Therefore, double-clicking on a file with the .dyalog extension will open it with Notepad automatically.

When enabled through the registry entry SoftwareDyalogDyalog APL/W 11.0SALTAddSALT, SALT is loaded into the session object (⎕SE) so that it does not interfere with application code.

Saving and Loading classes

By default, SALT stores script files in a folder called Classes, below the main Dyalog program folder (but you can change that).

To save class C in file you simply enter

      ⎕SE.SALT.Save 'C myclass'    ⍝(the .dyalog extension is implied)

To load the class in file you type

      ⎕SE.SALT.Load 'minemc'

When the editor fixes a class or namespace which was loaded by SALT, SALT will offer to write the modified source back to the file. This allows you to keep source code in script files without changing the way you work.

Listing script files

To find all the script files in a given folder use the List function:

      ⎕SE.SALT.List 'Dyalog'
Type Name Version Size Last Update
ComponentFile 5888 2006/09/21 14:26:20
UnicodeFile 48975 2006/11/30 20:52:58
DIR Interfaces 2007/03/21 13:08:53

SALT function arguments can include modifiers preceded by a hyphen. For example, you could list the contents of all the subfolders below the Dyalog folder using:

      ⎕SE.SALT.List 'Dyalog -recursive'

All SALT functions display a brief summary of applicable switches if you call them with an argument of '?':

      ⎕SE.SALT.List '?'
List pathname
Modifiers accepted:
-Full[=1 or 2] 1 Show full pathnames below first folder found;
2 returns "rooted" names.
-Recursive What you would expect
-Versions List versions
-Folders Only list folders
-Raw Return unformatted date and version numbers

Versions and Comparisons

Saving a class or namespace using the -version modifier switches on simple versioning. Once a file is versioned, each subsequent save creates a new file rather than overwriting the existing one.

You can compare two versions using Compare. For example, to compare the last 2 versions of utils enter

      ⎕SE.SALT.Compare 'MineMyNS'

SALT will either display the differences in the session or use a 3rd party tool (which has to support UTF-8):

SALT contains simple tools for managing versions. For example, you can delete all versions below number 100 using:

      ⎕SE.SALT.RemoveVersions 'MineMyNS -version=<100'

Multi-developer projects will probably benefit from the use of SubVersion or other source code management tools rather than SALT versioning. Many "industry standard" management tools support UTF-8, and are therefore well suited to managing Dyalog Source code.

Summary

SALT provides simple tools for storing source code in Unicode text files. This allows the use of external tools to manage and deploy applications. It also allows us to organise the source in a number of new ways. We will explore these possibilities further in future articles!

 

Previous Article
Return to Newsletter
Next Article