When developing a program, having to come up with a unique name every time one is required becomes impractical. Hence namespaces are provided as a necessary convenience. Namespaces also help to introduce categories so there is a simple way to refer to related things in the design domain, for example "personal.contacts" and "business.contacts" for two distinct types of contacts.
eXPL has a simple 2-level namespace scheme which as a consequence means names have never more than 3 parts, each part being an identifier.
Identifers
Identifiers in eXPL follow the Java naming syntax: identifiers begin with an alpha character which is followed by any number of alpha or numeric
characters or "_" underscore. You see in all the eXPL examples a naming convention different from Java's camelCase. The convention is intended to
make eXPL look different from Java and uses all lower-case names, with underscore character used to separate words eg. surface_area_increase.
Identifiers are assembled to form names that include the namespace coordinates of artifacts. A ".
dot character is used to separate these identifiers. In most cases, just two identifiers are combined to form what is referred to as a "2-part name"
eg. europe.megacities. For some artifacts, the namespace scheme requires a 3-part name to fully qualify an artifact's location.
Namespace Scheme
The eXPL namespace can be segmented into scopes, with every template in a scope creating it's own namespace. So for example, two templates can have the same name as long as they are in different scopes and two variables can have the same name as long as they are in different templates. There is also a global namespace in which artifacts can be placed that are intended to be visible from all other namespaces.
Scope
The highest level in the namespace scheme is called a "scope". A scope is named using an identifier and this forms the first part of an name when addressing an external scope. For example, a template named "megacities" in a scope named "europe" is referenced in a query belonging to a different scope as "europe.megacities".
There is a global scope created at the start of a program and all artifacts not included in a declared scope are automatically located in the
global scope. You will find that the global scope is used almost exclusively in this reference. The section on Scopes is obviously an exception.
Application EuropeanScopeMegaCities of tutorial2 gives a quick look at creating a scope named "europe" to
illustrate using 2-part name europe.megacities in a global scope query. Here is how the europe scope is declared along with the query that references it:
{
query<axiom> euro_megacities (mega_city : europe.megacities);
Note that the program declares a second scope named "asia" which has a "megacities" template identical in name to the european template.
