What the ANSI-1996 Standard Adds to the TRL-2 Standard
by Howard Fosdick (C) 2022
Rexx was originally defined by its inventor Michael Cowlishaw in his book The Rexx Language (commonly abbreviated as TRL). The 2nd edition of this book is considered definitive, and is referred to as the TRL-2 standard.
Rexx Gets an ANSI Standard
As Rexx evolved into a widely popular, cross-platform scripting language, users clammored for an ANSI standard. ANSI is the main organization for the standardization of programming languages. It confered the prestige and imprimatur of an international standard upon Rexx. The Rexx ANSI standard was formulated in 1996 and is commonly referred to as the ANSI-1996 standard for Rexx.
In the following sections, I'll describe the exact differences between the TRL-2 and ANSI-1996 standards. Generally speaking, the two standards are quite close. There are only very minor differences between them, though the few features that ANSI-1996 adds are very useful. Keep in mind that the ANSI-1996 standard is a true superset of TRL-2. So any TRL-2 script conforms to the ANSI-1996 standard.
A Few New Features
ANSI-1996 adds a few language features where they are nondisruptive to existing scripts and earlier standards. These include, for example, the new built-in string manipulation functions CHANGESTR and COUNTSTR, and the new trap condition LOSTDIGITS. The DATE and TIME functions are enhanced to perform conversions in addition to just reporting the date and time. A few more special variables are added (.RC, .RS, .RESULT, .MN, .SIGL).
Data Left to Read
The CHARS and LINES functions previously returned the number of characters or lines left to read on the input stream. Determining these values could consume much time for large files. ANSI-1996 allows the returning of 1, meaning “some undetermined number of characters or lines are left to read.” The LINES function has two options: C, which returns the number of lines left to read in the file, and N, which allows a return of 1 for one or more lines left to read and 0 if there are no lines left to read. For backward compatibility, N is the default.
ANSI-1996 more accurately defines how input is sent to commands and how command output and errors are captured. These are reflected in enhancements to the ADDRESS instruction and ADDRESS function. The ADDRESS instruction now includes keywords INPUT, OUTPUT, and ERROR to manage communication to/from the operating system or other external command execution environment. The ADDRESS function can return the setting of these three new keywords.
More Precise Language Definition
ANSI-1996 provides a more precise definition of Rexx beyond that provided by TRL-2. TRL-2 defines Rexx in book form, readable by the typical software developer or IT programmer. The ANSI-1996 standard is written in a format designed for those who need the precise definition necessary to create a Rexx interpreter or assess whether a specific interpreter meets international standards. The ANSI-1996 standard is more rigorous than TRL-2 but less readable for the average developer.
Adapted from the Rexx Programmer’s Reference, chapter 13 “Writing Portable Rexx,” pg. 194 © 2005/6--