Major APLASCII enhancement 
Author Message
 Major APLASCII enhancement

Thanks to prodding by Bob Bernecky and{*filter*} Holt, I've now enhanced the
APLASCII workspace so it can be used as a general workspace exchange
facility.  The main change is that INSERTFNS and DEFINEFNS are now able
to insert and extract variables as well as functions.  (Yes, I know the
names are no longer appropriate, but I don't think it's worth changing
them.)  All arrays, including nested arrays and arrays containing
arbitrary characters, can be transferred.  The new workspaces are
available for testing in the directory:

              <ftp://thales.math.umass.edu/incoming/>

The installation instructions are the same as for the previous release.
They can be found in:

 <ftp://archive.uwaterloo.ca/languages/apl/workspaces/aplascii/readme>

   The following is an explanation of the rationale for the conventions
I adopted.  This is all very new stuff, and I'm open to suggestions.

1.  Characters that aren't part of the APL or printable ASCII character
sets are represented by keywords of the form "{U+xxxx}", where xxxx is
the hexadecimal Unicode index for the character.  (U+xxxx is the
standard notation for referring to Unicode characters.)  I've added
Unicode indices to the translate tables for APL*PLUS, APL2/PC, and
ISIAPL, but not yet for APL2/EBCDIC, Dyalog or APL.68000 (interpreters I
don't have).

   As a backup measure, I made the translate table generation program
automatically provide keywords for any characters that don't have
keywords specified in TTSCRIPT.  These generated keywords have the form
"{avN}", where N is the zero-origin #AV index.  This convention will
permit lossless exchange between identical APL systems, but it will not
work between different APL systems.  However, they will permit the
receiving party to ask the sender, "What is #AV[N] on your system?"

2.  The format for variable listings was designed, like the rest of
APLASCII, to be relatively obvious even to those who haven't seen it
before, to be simple enough that it can be created manually, and to be
completely reversible for all arrays.  Here's what I came up with:

a.)  A variable definition in a message is indicated by a line that has
{<-} (an assignment arrow) as the first nonblank character on the line.
This convention was adopted because it's relatively unambiguous and is
simple to implement.  In practice, {<-} will not usually occur as the
first character of a message, so it seems a suitable and suggestive
escape character.  The variable definition ends with a blank line, the
start of another definition, or the end of the message.

b.)  The definition is conceptually one long line, but it's wrapped with
the usual {+ +} convention used by WRAPLNS.  The line has the following
format:

              {<-} varname {<-} shape {rho} value
as in:
              {<-}FOO{<-}2 3{rho}1 2 3 4 5 6

Except for the initial {<-}, the line is nominally an APL statement that
defines the variable.  The "shape {rho}" part may be omitted if the
value is a scalar or a vector that is not a 1-element vector.
(Singleton vectors must include the phrase "1{rho}".)  Spaces may be
inserted freely between the terms.  For example:

              {<-}SCALAR{<-}42
              {<-} VEC {<-} 'Character value'
              {<-}SINGLETON{<-} 1{rho}12

c.)  The value portion of a nested, heterogeneous, or boxed array is
represented as a series of parenthesized items.  Items which are simple
are represented as "(shape {rho} value)", with "shape {rho}" being
optional as described above.  Items which are further nested are
represented as a list of parenthesized items within the outer
parentheses.  For example:

              {<-}NEST{<-} (1 2 3) ((4 5) ('six') (7))

This describes a two-item vector whose first item is 1 2 3 and whose
second item is a three-item vector containing the arrays 4 5, 'six',
and 7.

   The value portion of the expression is never an empty array.  If the
shape describes an empty array (e.g., 3 0 4), the value has a single
item, which is the prototype for the array.  For example:

        {<-}MTNEST{<-} 3 0 4 {rho} (3{rho}0 0 0)

The one exception to this rule is empty character vectors, which may
be represented as either '' or 0{rho}' '.

   APL2 users should note that, although this format is similar to
strand notation, it is not the same, and execution will not always
produce the correct array.  The A2A notation requires parentheses around
items that are scalars and character vectors, and extra parentheses
produce additional nesting.  Thus, "(1 2 3)" denotes a scalar containing
the array 1 2 3, and "((1 2 3))" denotes a scalar containing a scalar
containing 1 2 3.  (DEFINEFNS, of course, understands the notation and
produces the correct array.)  The value "(3)" is boxed scalar containing
3 in Sharp APL; in APL2, it's just the scalar 3.

3.  Two functions, DUMPWS and LOADWS, are provided to write an entire
workspace to a file and to read a file back into the workspace.  DUMPWS
has an optional left argument that specifies the objects to be written.

   Comments, suggestions, and bug reports would be greatly appreciated.

                                                Jim



Sat, 17 Jan 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Array Storage: row-major, column major, etc.

2. column-major and row-major

3. MAJOR MAJOR bug in TCL 8.4

4. Updated APLASCII workspaces

5. APLASCII Transliteration Summary

6. J. Weigang's APLASCII format..

7. Problem using APLASCII

8. APLASCII format of singleton nested arrays

9. APLASCII 1.3 released

10. APLASCII 1.4 released

11. APLASCII v1.3 update

12. APLASCII update

 

 
Powered by phpBB® Forum Software