A Survey of ⎕NC
Vector 7:1, page 127
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 127
Abstract¶
Originally the user of APL could only identify the types of the objects in his workspace with the system commands )VARS, )FNS, and - if groups are supported - the system command )GRPS. In addition, in most implementations the listing displayed cannot be trapped in the form of an explicit result. To overcome these deficiencies, the system functions Name Class ⎕NC and Name List ⎕NL have been incorporated. A survey is given of the related name class implementations for about forty APL dialects. Remarks concerning the standardization of this name classification are stated.
Name Classifications in APL¶
APL does not need explicit data typing. Variables are introduced by the user through assignment and their type and structure may be changed dynamically. User-defined functions and - if supported - user-defined operators are introduced either with the editor or in some implementations through direct definition. If supported, variables and user-defined functions/operators may be collected to groups. As such, the user is building up a set of reserved words - the names of the objects in his workspace. Eventually, the user may discard members of this set by erasing or expunging.
Originally the user could only identify the types of the objects in his workspace with the inquiry commands )VARS for a variables listing, )FNS for a defined function listing, and eventually )GRPS for a group listing. More recently, the system command )OPS has been added for - if supported - the defined operator listing and the command )NMS for the listing of the total set of object names. Each of these commands displays the names of the objects in alphabetical order, eventually restricted to an alphabetical subset as specified by the parameter(s) of the command. In most implementations however, the listing displayed cannot be trapped in the form of an explicit result.
To overcome the deficiencies of this approach, the system functions Name Class ⎕NC and Name List ⎕NL were incorporated. ⎕NC returns as explicit result a vector of name class integers giving the local usage of the identifier in the corresponding row of the right argument matrix. ⎕NL returns as explicit result an array containing the name list of the local identifiers specified by the right argument scalar/vector of name classes. In its dyadic form, the name list is restricted to those identifiers whose initial character is the same as one of the characters occurring in the left argument character scalar/vector. Whether the names are listed in alphabetical order or not, depends on the implementation. In most implementations the names are alphabetically ordered, but in some implementations the names are listed in fortuitous order or in the order as they first appeared in the workspace.
Note: For those implementations which support the system command )NMS, the names listed by this command are followed by a dot and their name class. The name classes are the same as those produced by the system function ⎕NC.
Name Class Implementations¶
Descriptions of name class implementations for about forty dialects are given at the end of this paper. For purposes of comparison the list starts with the standardizations proposed A.D. Falkoff and D.L. Orth at APL79 (1979) [1] and by the ISO Draft International Standard DIS 8485 (1986) [2].
The descriptions give the name classes returned by ⎕NC. Any deviations of those used by ⎕NL and additional information if significant are reported in the form of a note. In most implementations ⎕NC returns name class 0 for names available without active referent, name class 1 for line labels, name class 2 for user-defined variables, and name class 3 for user-defined functions.
In many implementations ⎕NC returns name class 4 for names not available: invalid names, distinguished names, and - if supported - group names. In some implementations however, name class 4 is reserved for groups only and in all implementations which support user-defined operators name class 4 is reserved for such operators. Invalid names in those implementations return an individual name class such as ¯1 or cause an error report such as "domain error" or "name error". Names of system variables and system functions in those implementations return an individual name class such as 5 and 6 respectively or are treated as common objects by ⎕NC but are not listed by ⎕NL. In VAX APL Versions 2 and 3, a distinct name class is associated to niladic and non-niladic system functions. Maybe this is done because niladic system functions are in fact system variables, shared between the workspace and the processor, but which are reset by the processor before they are used.
⎕NC returns the name classes for the local usage of the identifiers and ⎕NL lists the local identifiers of the type(s) selected. In some implementations additional facilities are provided for identifying global usage or/and for listing the global identifiers:
- In Xerox APL (Atkins), classification codes returned by
⎕NCand used by⎕NLare different. Name classes 2/3 list the active variables and functions, while name classes 5/6 list the global variables and functions.3 ⎕WM 'type'corresponds to⎕NL,6 ⎕WM 'namelist'corresponds to⎕NC, but7 ⎕WM 'namelist'identifies the global use instead of the local use of the names listed. - In APL 2.0 and NOS/VE APL (CDC), the system variable
⎕ENVcontrols whether⎕NCand⎕NLrefer to the global or the current environment. When 0, the global environment is used. When 1, the current environment is used. The default is 1. When the state indicator is empty, the global and current environment are the same and⎕ENVhas no effect. - In OS4000 APL (GEC),
⎕NLmay list global objects: name classes 2/3/4 are used to list local variables/functions/groups, while name classes 5/6/7 are used to list global variables/functions/groups. - In 2900 APL (ICL),
⎕NCmay be used dyadically. If the left argument is 0, global classifications are reported. If 1, current classifications are reported. The default is 1. If the left argument of⎕NLis 0 instead of a character scalar/vector global objects are listed. If 1, current objects are listed. The default value is 1. - In SHARP APL (IPSA),
1 ⎕WSversus⎕NLand5 ⎕WSversus⎕NCprovide similar information but classification codes are different. In addition,5 ⎕WSreports the name class at each level of the state indicator, the global definitions included. - In APL*PLUS (STSC),
⎕IDLISTversus⎕NLand⎕IDLOCversus⎕NCprovide similar capabilities, but classification codes are different. In addition,⎕IDLOCreports the name class at each level of the state indicator, the global definitions included.
Note: Some implementations reserve separate name classes for non-standard objects, such as intrinsic functions in Xerox APL (Atkins), special functions in NOS/VE APL (CDC), APLGOL functions in APL/3000 (HP), and special data types in MCM/APL (MCM). More details may be found in the descriptions given below.
Name Class Standardizations¶
In the standard proposed by A.D. Falkoff and D.L. Orth at APL79 (1979) [1], unavailable names return name class 4. In ISO DIS 8485 (1986) [2] however, such unavailable names cause a "domain error". This permits the implementor to add name classes as consistent extensions.
In the meantime, ISO-IEC/JTC1/SC22/WG3 is preparing a new standard for Extended APL. As this new standard will probably support user-defined operators, it is obvious to associate name class 4 with those user-defined operators. At the same time it would be opportune to introduce extra name classes for system variables and system functions, for instance name classes 5 and 6 respectively. This would give the user the opportunity to list the system variables and system functions available in his processor. the complete set of name classes would become:
| 0 | for identifiers available without current referent |
| 1 | for labels |
| 2 | for variables or shared variables |
| 3 | for user-defined functions |
| 4 | for user-defined operators |
| 5 | for system variables |
| 6 | for system functions |
Finally, a mechanism should be standardized to give the user the possibility to choose whether ⎕NC and ⎕NL refer to global or local objects. The most handsome method seems to be to make available a system variable which controls this choice, such as is done in APL 2.0 and NOS/VE APL (CDC) with the implementation of the system variable ⎕ENV.
References¶
[1] A.D. Falkoff and D.L. Orth; Development of an APL Standard; APL79 Conference Proceedings, Rochester, New York, 30 May - 1 June 1979; Edited by A.L. Anger; APL Quote Quad, Vol. 9, No.4, June 1979, pp.409-453.
[2] Draft International Standard DIS 8485 - Programming Language APL; Document ISO/TC97/SC22/WG3/N55; Edited by L.A. Morrow; AFNOR, Secretariat ISO /TC97/SC22/WG3-APL, Paris, France, May 1986.
F & O APL (A.D. Falkoff and D.L.Orth - 1979)¶
| 0 | name available without active referent |
| 1 | label |
| 2 | variable or name offered for sharing |
| 3 | defined function |
| 4 | other (distinguished name, group name, not a name) |
ISO APL (ISO-IEC/JTC1/SC22/WG3 -DIS 8485)¶
| 0 | identifier available without current referent |
| 1 | label |
| 2 | variable or shared variable |
| 3 | defined function |
Note: Invalid names and distinguished names cause a "domain error". Groups are not supported.
APLSV and VSAPL (International Business Machines IBM)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable or shared variable |
| 3 | function |
| 4 | other (group name, distinguished name, not a valid name) |
5100/10/20 APL and APL/PC (International Business Machines IBM)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable or shared variable |
| 3 | function |
| 4 | not available (distinguished name or not a valid name) |
Note: Groups are not supported.
APL2 and APL2/PC (International Business Machines IBM)¶
| ¯1 | invalid name or unused distinguished name |
| 0 | unused but valid name |
| 1 | label |
| 2 | variable or shared variable |
| 3 | function |
| 4 | operator |
Note: Distinguished names are treated as common objects by ⎕NC. Distinguished names however are not listed by ⎕NL. Groups are not supported.
Xerox APL (Atkins Computing Services Limited)¶
| 0 | no current referent |
| 1 | logical variable |
| 2 | character variable |
| 3 | integer variable or label |
| 4 | real variable |
| 5 | index sequence |
| 6 | list |
| 7 | internal processor use only |
| 8 | user-defined function, niladic, no result |
| 9 | user-defined function, niladic, with result |
| 10 | user-defined function, monadic, no result |
| 11 | user-defined function, monadic, with result |
| 12 | user-defined function, dyadic, no result |
| 13 | user-defined function, dyadic, with result |
| 14 | intrinsic function, dyadic |
| 15 | intrinsic function, monadic |
| 16 | intrinsic function, niladic |
| 17 | group |
Note: Intrinsic functions are analogous to locked functions in that they cannot be displayed. ⎕NC and ⎕NL classification codes are different. Type specification codes are: 1 labels; 2 active variables; 3 active functions; 4 groups; 5 global variables; 6 global functions. ⎕NL in its dyadic form is not supported. 3 ⎕WM 'type' corresponds to ⎕NL. 6 ⎕WM 'namelist' corresponds to ⎕NC. 7 ⎕WM 'namelist' identifies the global use instead of the local use of the names listed. ⎕WM is implemented as a duplicate of the intrinsic function ∆WM.
MAINSTREAM-APL (Boeing Computer Services BCS)¶
| 0 | name not defined (not in use) |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | name not available (e.g. a group) |
APL/700 (Burroughs - Unisys)¶
| 0 | no associated meaning |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | other (group) |
APLB (Burroughs - Unisys)¶
| 0 | undefined |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | operator |
Note: Distinguished names are treated as common objects by ⎕NC. Distinguished names however are not listed by ⎕NL. Invalid names in the argument of the ⎕NC cause a "name error". Groups are not supported.
APL-64 (Cii Honeywell Bull)¶
| 0 | available for any use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | not available (group name, distinguished name or not a valid name) |
APL 2.0 (Control Data Corporation CDC)¶
| 0 | available (not in use) |
| 1 | locked variable (label or group) |
| 2 | unlocked variable |
| 3 | function |
| 4 | other (e.g. a defined distinguished name) |
Note: User-defined variables may be locked and as such they cannot be reset using specification. Invalid names in the argument cause a "domain error". ⎕NL 4 provides a list of distinguished names. ⎕ENV controls whether ⎕NC and ⎕NL refer to the global or to the current environment. When 0, the global environment is used. When 1, the current environment is used. The default value is 1. When the state indicator is empty, the global and the current environment are the same and ⎕ENV has no effect.
NOS/VE APL (Control Data Corporation CDC)¶
| 0 | no object associated or not a distinguished name |
| 1 | locked variable (label or group) |
| 2 | unlocked variable |
| 3 | user-defined function |
| 4 | distinguished name or special function |
Note: User-defined variables may be locked and as such they cannot be reset using specification. A special function is a function supplied by the system to provide capability or efficiency not available by other means. Special functions behave the same as user-defined functions. Invalid names in the argument cause a "domain error". ⎕NL 4 provides a list of distinguished names and special functions. ⎕ENV controls whether ⎕NC and ⎕NL refer to the global or to the current environment. When 0, the global environment is used. When 1, the current environment is used. The default is 1. When the state indicator is empty, the global and the current environment are the same and ⎕ENV has no effect.
AOS/VS APL (Data General Corporation DG)¶
| 0 | available for use |
| 1 | label |
| 2 | user variable |
| 3 | defined function |
| 4 | other |
Note: Groups are not supported.
APL-11 (Digital Equipment Corporation DEC - DECUS)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | not a valid name or group name |
APL-Basic and APLSF (Digital Equipment Corporation DEC)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | not available (not a valid name or group name) |
VAX APL Version 1 (Digital Equipment Corporation DEC)¶
| 0 | name not in use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | group |
| 5 | system variable |
| 6 | system function |
Note: Invalid names in the argument cause a "domain error".
VAX APL Version 2 (Digital Equipment Corporation DEC)¶
| ¯5 | niladic system function |
| ¯4 | group |
| ¯3 | monadic, dyadic, or ambivalent system function |
| ¯2 | system variable |
| ¯1 | ill-formed identifier |
| 0 | name not in use |
| 1 | label |
| 2 | variable |
| 3 | user-defined function |
VAX APL Version 3 (Digital Equipment Corporation DEC)¶
| ¯20 | derived function |
| ¯5 | niladic system function |
| ¯4 | group |
| ¯3 | monadic, dyadic, or ambivalent system function |
| ¯2 | system variable |
| ¯1 | ill-formed identifier |
| 0 | name not in use |
| 1 | label |
| 2 | variable |
| 3 | user-defined function |
| 4 | user-defined operator |
Dyalog APL Version 1 (Dyadic Systems Limited)¶
| ¯1 | invalid name |
| 0 | unused name |
| 1 | label |
| 2 | variable |
| 3 | function |
Note: Distinguished names are classified as invalid names. The name class of an external variable is 2 as soon as it is associated by ⎕XT. Groups are not supported.
Dyalog APL Version 5 (Dyadic Systems Limited)¶
| ¯1 | invalid name |
| 0 | unused name |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | operator |
Note: Distinguished names are classified as invalid names. The name class of an external variable is 2 as soon as it is associated by ⎕XT. Groups are not supported.
OS4000 APL (GEC Computers Limited)¶
| 0 | undefined or expunged |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | group |
Note: ⎕NL may list global objects (code 5 for global variables, 6 for global functions, and 7 for global groups).
Harris APL (Harris Computer Systems)¶
| 0 | unused name |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | improperly formed name, distinguished name, or group name |
APL/3000 (Hewlett-Packard HP)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable |
| 3 | APL function |
| 4 | APLGOL function |
| 5 | not valid (distinguished name or incorrectly formed name) |
Note: The user has the opportunity of defining functions in either APL or APLGOL. A workspace may contain any mixture of APL and APLGOL functions, who can be used in any combination. Groups are not supported.
I-APL (I-APL Limited)¶
| 0 | available for use |
| 1 | visible line label |
| 2 | visible variable name |
| 3 | visible function name |
Note: Groups are not supported.
2900 APL (International Computers Limited ICL)¶
| 0 | name undefined |
| 1 | label or locked variable |
| 2 | variable |
| 3 | user-defined function |
| 4 | unacceptable name (including distinguished names) |
Note: User-defined variables and user-defined functions may be locked (⎕LOCK). ⎕NC may be used dyadically. If the left argument is 0, global classifications are reported. If 1, current classifications are reported. The default is 1. If the left argument of ⎕NL is 0, global objects are listed. If 1, current objects are listed. The default is 1. Groups are not supported.
MCM/APL (MCM Computers Limited)¶
| 0 | no value |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | invalid name |
| 5 | special type data |
Note: Special Type Data are somewhat analogous to locked functions, except that they can only be created by MCM. Groups are not supported.
APL.68000 (The Computer Company - MicroAPL Limited)¶
| 0 | name not in use |
| 1 | line label |
| 2 | variable |
| 3 | function |
| 4 | invalid name |
| 5 | group |
APL/LW and APL/LWSF (MIPS Software Development)¶
| 0 | name available for use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | not available (invalid name, distinguished name, or name of a group) |
APL*MYRIADE (OOM Incorporated)¶
| 0 | name available for use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | not available (invalid name, distinguished name, or name of a group) |
PortaAPL (Portable Software)¶
| 0 | undefined |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | group |
APL/PRIME (Prime Computer)¶
| 0 | name not in the symbol table (including illegal names) |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | group |
| 5 | name in the symbol table but currently having no value |
APL/16 (SEMS)¶
| 0 | undefined object |
| 1 | system function |
| 2 | label or variable |
| 3 | defined function |
| 4 | invalid identifier |
Note: Groups are not supported.
SHARP APL (I.P. Sharp Associates IPSA)¶
| 0 | well formed name with no visible use |
| 1 | visible use as a label |
| 2 | visible use as the name of a variable |
| 3 | visible use as the name of a function |
| 4 | other (group names, distinguished names, invalid names |
Note: ⎕NC and 5 ⎕WS provide similar information. ⎕NC reports only visible use, while 5 ⎕WS reports the class at each level of the state indicator, the global definition included. ⎕NC and 5 ⎕WS return different classification codes. Classification codes returned by 5 ⎕WS are: ¯1 not localized at this level; 0 localized with no assigned value at this level or globally undefined; 1 function; 2 variable; 4 group; 8 label. ⎕NL and 1 ⎕WS both return the names of the visible objects, but the classification codes used are different: ⎕NL uses an encoding consistent with ⎕NC and 1 ⎕WS uses an encoding consistent with 5 ⎕WS. The right argument of 1 ⎕WS must be the sum of the codes of the classes of the objects whose names are to be reported. When the argument is negative or greater than 15, its 16 residue is used.
VIZ::APL (Sigma Software Unit - Inner Product Limited)¶
| 0 | name free for use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | invalid name |
| 5 | system variable |
| 6 | system function |
Note: Groups are not supported.
APL-NET (SLIGOS - BARTS)¶
| 0 | name available for any use |
| 1 | label |
| 2 | variable |
| 3 | function |
| 4 | ill-formed |
APL 1100 (Sperry Univac - Unisys)¶
| 0 | name available for use |
| 1 | label |
| 2 | variable |
| 3 | user-defined function |
| 4 | not available for use (group name, distinguished name, or invalid) |
APL*PLUS (Scientific Time Sharing Corporation - STSC)¶
| 0 | not defined |
| 1 | label |
| 2 | variable |
| 3 | defined or primitive function |
| 4 | other (group name, distinguished name, not a valid name) |
Note: ⎕NC and ⎕IDLOC provide similar capabilities, ⎕NC accepts ill-formed identifiers, while ⎕IDLOC produces a "domain error". ⎕NC merely returns the locally active classification, while ⎕IDLOC returns the classification at each level of the state indicator, the global definition included. ⎕NC and ⎕IDLOC return different classification codes. Classification codes returned by ⎕IDLOC are: ¯1 not localized at this level; 0 localized with no assigned value at this level or globally undefined; 1 user-defined function or system function; 2 user-defined variable or system variable; 4 group; 8 label. ⎕NL and ⎕IDLIST both return the names of the visible objects but the classification codes used are different: ⎕NL uses an encoding consistent with ⎕NC, while ⎕IDLIST uses an encoding consistent with ⎕IDLOC. The right argument of ⎕IDLIST must be the sum of the codes of the classes of the objects whose names are to be reported. When the argument is negative or greater than 15, its 16 residue is used. ⎕IDLIST and ⎕IDLOC correspond to the primitive functions 1 ∆WS and 5 ∆WS respectively, the difference being that ⎕IDLIST with its dyadic form allows the result to be restricted to names with specified first letters, while 1 ∆WS does not.
APL 90 (Ecole des Mines de Saint-Etienne - SYNC)¶
| 1 | invalid name |
| 0 | unused but valid name |
| 1 | label |
| 2 | variable |
| 3 | defined function |
| 4 | defined operator |
Note: Distinguished names are treated as common objects by ⎕NC. Distinguished names however are not listed by ⎕NL. Groups are not supported.
TIS-APL (Telecompute Integrated Systems TIS)¶
| 0 | name available for use |
| 1 | line label |
| 2 | variable |
| 3 | function |
| 4 | illegal name |
Note: ⎕NL in its dyadic form is not supported. Groups are not supported.
Waterloo microAPL (Waterloo Computing Systems Limited)¶
| 0 | name available for usage |
| 1 | label |
| 2 | variable |
| 3 | defined function |
| 4 | not a name |
| 5 | system variable |
| 6 | system function |
Note: Groups are not supported.
WATCOM APL (WATCOM Products Incorporated)¶
| 0 | name available for usage |
| 1 | label |
| 2 | variable |
| 3 | defined function |
| 4 | not a name |
| 5 | system variable |
| 6 | system function |
Note: Groups are not supported.
APL/Z80 and APL/V80 (Vanguard Systems Corporation)¶
| 1 | label |
| 2 | variable |
| 3 | function |
Note: ⎕NC is not supported. ⎕NL in its dyadic form is not supported. Groups are not supported.
Paper prepared for the APL Workgroup ISO-IEC/JTC1/SC22/WG3 (August 1990). Copyright 1990: The Belgian APL-CAM Users Society BACUS.
Joseph L.F. De Kerf
Agfa-Gevaert NV/SA - 5900
Research Laboratories
Septestraat 27
B-2510 Mortsel
Belgium