Namespaces

Namespace is a (class 9) object in Dyalog APL. Namespaces are analogous to nested workspaces.

'Flat' APL Workspace      Workspace with Namespaces
.OLD-------------------.   .NEW-------------------.
|                      |   | FOO MAT VEC          |
| DISPLAY              |   | .Util----------.     |
|                      |   | |DISPLAY       |     |
|   FOO MAT VEC        |   | |...           |     |
|                      |   | '--------------'     |
|   WsDoc_Init         |   | .WsDoc-------------. |
|   WsDoc_Xref         |   | |Init .prt-..fmt--.| |
|   WsDoc_Tree         |   | |     |Init||line || |
|   WsDoc_prt_init     |   | |Tree |    ||     || |
|   WsDoc_current_page |   | |Xref |page||     || |
|   ...                |   | |     '----''-----'| |
|                      |   | '------------------' |
'----------------------'   '----------------------'
	

They provide the same sort of facility for workspaces as directories do for filesystems. The analogy, based on DOS, might prove helpful:

Operation Windows Namespace
Create mkdir )NS or ⎕NS
Change cd )CS or ⎕CS
Relative name dir1\dir\file NS1.NS2.OBJ
Absolute name \file\file #.NS.OBJ
Name separator \ .
Top (root) object \ #
Parent object .. ##
Namespaces bring a number of major benefits:

They provide lexical (as opposed to dynamic) local names. This means that a defined function can use local variables and functions which persist when it exits and which are available next time it is called.

Just as with the provision of directories in a filing system, namespaces allow us to organise the workspace in a tidy fashion. This helps to promote an object oriented programming style.

APL's traditional name-clash problem is ameliorated in several ways:
The programming of GUI objects is considerably simplified.

This means that the object need use only a single name in its namespace.