Namespace

A namespace is an encapsulation mechanism for names used within a program. Namespaces were added to APL2 in 1987, and to Dyalog APL in 1994. They are also present in J, where they may be used for object-oriented programming. As they are now common across many programming languages, more recent array languages such as Rowan may include namespace designs inspired by other languages (in this case R). Because code can be evaluated within a particular namespace, namespaces serve as a way to combine the context for a set of functions or other operations without interfering with other parts of a program that do not need this context.

Depending on dialect namespaces may be accessible by one or more of the following two methods: indirectly by name (or, in J, number), or directly by a value known as a namespace reference. Unlike traditional APL arrays, which are immutable, a namespace is mutable: the values in it can be changed even while it remains the "same" namespace (constructs such as indexed assignment allow an APLer to create a new array by modifying an existing one, but it is not considered the same array, and other references to it do not reflect any change). This means that namespace references, if they are used, are semantically different from older APL types. Nonetheless, it is possible to place namespace references into arrays or manipulate them as ordinary data.

History
The concept of namespaces in APL was proposed as early as 1981 by Ron Murray, based on encapsulation concepts called "modules" or "packages" developed in the 1970s. Murray credits Jim Ryan for the use of the term "Namespace". In 1987, IBM introduced namespaces to APL2 as a form of name scope (IBM used the term "namescope" for a workspace or function scope) that could be manipulated directly by the programmer. Unlike the later Dyalog APL namespaces, IBM's are independent of any workspace, and stored separately. Dyalog's namespaces were added in version 7.0, released in 1994, largely to make it easier to handle Dyalog's Windows GUI environment. In Dyalog APL 9.0, namespace references were added, allowing these namespaces to be manipulated as values. Dyalog's namespaces would later become the basis of its object-oriented programming system implementation, although namespaces, classes, and objects are different kinds of values within the language.

Tutorials

 * APL Cultivation

Documentation

 * Dyalog