Objects

An object is the basic building block of all of the symbolic content contained in a document - every term in every symbolic expression in Sym is an instance of an object. Many of the objects used in Sym have an object definition that specifies how the object looks and behaves, but it's also possible to create objects that don't have object definitions. All objects are identified by their name and object names are always defined in a specific namespace. All object definitions contain a type definition. Optionally, objects can also contain Properties, Clauses, Renderings, and a Description.

Consider a very simple example:

x + y

This expression contains instances of three objects - "x", "y" and "Add". The "x" and "y" objects don't have object definitions. The Add object has an object definition in the Math.eql library. That object definition specifies how the object is display through the renderings attached to the object definition. The type definition of the Add object specifies the number of parameters the object can have and the types that are allowed in those parameters.

For every object, the full object name is a combination of the object name and the assigned namespace. We will sometimes show the full name of an objects in the form: Namespace.ObjectName. For example, the full name of the Add object in the Math namespace is Math.Add. An Add object defined in a different namespace is a different object.

Object definitions are created by adding an object definition to an Object Module. The components of an object definition are:

Object component Require/Optional Description
Object name Required The full object name is a combination of the object name and the assigned namespace.
Type definition Required The type definition in an object definition specifies the number of parameters the object can have and the types that are allowed in those parameters.
Properties Optional Properties can be added to control certain aspects of the behavior of an object. For example, the Autocomplete: Ignore property will cause an object to not be included in the autocomplete popup. See Object Definition Properties for additional information.
Clauses Optional Adding clauses to an object makes the object into something that can be considered to be a "function" in the software sense of the word. An object with clauses can be used as term inside of other clauses and will normally be executable code when that's the case. See Clauses for additional information.
Renderings Optional

Renderings control how objects are displayed. Renderings are attached to object definitions and are created using The Rendering Editor

Description Optional Similar to a comment in other programming languages

All object definitions are located in Object Modules, which are accessible through the Document Explorer. You can get to the definition of an object by highlighting the object and selecting Go to definition (F12) from the context menu.

For objects that don't have object definitions in the document or any of the libraries, an inferred object definition is created when an instance of the object is created in an expression. The name of the object is the name entered by the user, for example "x" or "y" in the example above. The namespace defaults to the Local namespace and the type definition is U where U is a variable. This object definition allows the undefined term to take on any type and is visible in the Properties window when a term like "x" is highlighted in a module.

An object definition created in, for example, MyLibrary can be "extended" in libraries that reference MyLibrary. Two of the main reasons for extending an object definition are:
  1. To add additional renderings, typically in other notations.
  2. For object definitions that have clauses, extensions can add additional functionality.

See Extending Object Definitions for examples and more details about how this is done.