Translation Scope

The translation scope defines the context for evaluating a template, by determining the object to which the template is applied. The scope can change during the translation of a template, but only one object is active at any given time.

The initial scope is always the metaclass on which the template is defined. All metamodel attributes and collections defined on the active object metaclass and its parents are visible, as well as the corresponding extended attributes and templates.

You can change scope using the '.' (dot) character, which behaves like the Java indirection operator, with the right-hand side corresponding to a member of the object referred to by the left-hand side.

The following types of scope are available:

New scopes may be created during evaluation of a template that forces the active object to change. For example, foreach_item macro (see .foreach_item macro) that allows for iteration on collections defines a new scope, and the foreach_line macro (see .foreach_line macro). The outer scope is restored when leaving the block.

Nested scopes form a hierarchy that can be viewed as a tree, the top level scope being the root.

The following example shows the scope mechanism using a Class template: