Namespace Objects

The full name of every object consists of a namespace and an object name. Including a namespace in the object name makes it less likely that creating a new object definition in a new library will result in a name collision with another object definition.

Namespaces in Sym are also objects. Users can create new namespaces just by creating an appropriate object definition.

Creating a namespace

Creating a namespace is the same as creating any other object definition except that there are a few additional requirements in order for the new object to be understood to be a namespace. The requirements are:
  1. The object definition must be placed inside of the NamespaceObjects namespace.
  2. The type definition must be Type :: Namespace

See Creating an Object Definition for additional information.

If we open a new Object Module and create a new namespace called MyNamespace in it, we would then have:

Now we can create another namespace, either in the same Object Module or in another Object Module and create a new object in MyNamespace:

The Data namespace

The Data namespace is used when we want a clause to manipulate or return an expression that would normally be executable. For example, in the Convert command there is a clause that converts and Assert object to an AssertList (or vice versa). The Assert or AssertList object on the right-hand side of these clauses in the Convert function would normally be executed.

To avoid having these terms be executed, we move any terms that are executable into the Data namespace at the beginning of a command, then apply the command, then move the expression back to the namespace it started in.

Objects in the Data namespace have the same type definition and renderings as the original object, except for the coloring used to distinguish objects that are in the Data namespace. This is possible because the Data namespace is a one-parameter object that takes a namespace as the parameter.

The original namespace becomes the parameter of the Data namespace in the ToData function. This allows the FromData function to put the expression back in its original namespace and it allows us to find the appropriate type definition and rendering of the object when it's in the Data namespace.

Built in namespaces

There are a number of namespaces that are predefined by Sym:

Namespace Description
Build Objects and functions used in the build process are defined in this namespace.
Code The namespace used for objects that are part of the Sym programming language.
Colors All of the predefined colors are defined in the Colors namespace.
Commands Command objects are defined in the Commands namespace. The command objects are used, for example, to tie a keystroke to a particular function.
Core Objects that are commonly used but aren't necessarily mathematical objects are defined in this namespace. The At and EmptyBox objects are two examples.
Data Objects that are normally executable can be moved to the Data namespace so that they can be manipulated like other expressions rather than being executed. When complete, the expression is moved back to the original namespace. To make this easier to do, the Data namespace is a one-parameter object. The parameter is the namespace the object was in before being moved.
ExecutionDetails The namespace used for defining the objects that appear in the execution details
Internal The namespace used for built in functions
Keys Objects for keystrokes are defined in the Keys namespace.
Local The namespace assigned by default when variables like "x" or "y" are created by typing into an empty box in a document section.
Logic The namespace used the Boolean objects
Math The Math namespace is used for all of the normal math objects that are defined in the Math.eql library
ModifierKeys The objects for Ctrl, Shift and Alt are defined in the ModifierKeys namespace.
NamespaceObjects The namespace for objects that define namespaces
Notations Objects that define Notations are created in the Notations namespace. See Notations and Rendering for more information.
Render Objects that are normally only used for rendering are defined in this namespace.
RenderingDefinitions Objects used in rendering expressions are defined in this namespace.
Sym Objects and functions that are need to be built at the beginning of the build process are defined in this namespace. You normally don't want to add anything in this namespace.
Types The namespace used for object types like Object, Real, etc.
Variables The namespace for variables that are used in code in the Sym language. By default, when you type "x" or "y" into an empty box in a clause in an Object Module, the term will be assigned to the Variables namespace.