Expression Rendering

A rendering determines how an object is displayed on the screen. The process of converting the content of an expression into what's actually displayed on the screen is referred to as "rendering" the expression. By switching a module to a different notation, same objects can be displayed in more that one way. The rendering of an object is determined by the object definition and by the notation currently selected.

As an example, the expression

x = y + 1

would be displayed as

Equal[x, Add[y, 1]]

in the default rendering. It's shown as x = y + 1 in the Standard notation because the Equal and Add objects both have renderings in the Standard notation that show these expressions as we expect them to be. Renderings are one of the components of an object definition. They are usually created using the Rendering Editor or in some cases by a function.

There can be more than one rendering defined for an object. Which rendering is used is determined by the Notation assigned to the module. Notations are assigned to Document Modules, Blackboard Modules, Unit Test Modules and Object Modules and are used to determine how expressions are rendered in each of these modules.

For example, the And, Or and Not objects in the Logic namespace are commonly rendered as:

We have also created a Computer notation that displays these same objects in a way that is more similar to what is seen in computer programming languages:

We can switch between these notations by selecting either Computer or Standard in the notation drop down at the top of the module. The selected notation determines how objects are rendered.

In addition to changing the way objects are displayed by changing the notation, a specific instance of an object can be rendered differently from its normal rendering in the selected notation. For example, division can be rendered horizontally:

This is done by attaching the RenderingName property to the object. Typically, you would use the Rendering Optionscommand (Alt + R) to switch a specific expression to another rendering.

Multiple renderings can be defined in a single object definition. You can also create an extension to an existing object definition that contains nothing but additional renderings. This allows creating new libraries that contain additional renderings for objects that are originally defined, for example, in one of the base libraries like Core.eql or Math.eql.

The process of rendering expressions involve several steps. In addition to looking up the notation for the current document section or module and finding the appropriate rendering, there are also steps that can execute a rendering function and execute a function to get the styles for a term. See Rendering Expressions for more details.