3.1.1. Types and scopes
With this text we explain how to understand a Perspective model source text. We do not give grammar definitions here, but focus on the meaning of the various expressions instead.
First of all, indentation matters. A model text consists of blocks of lines with equal distance from the left margin. Such blocks can be nested arbitrarily deep. We will call such a block a lexical scope, or just scope.
Second, a model is a number of type definitions (at least one: the domain). A type definition consists of a type declaration line, followed by an indented block that gives the type’s details (we might call this block the body of the type definition text). A type declaration can be easily recognised because it must be preceded by a keyword:
-
a context keyword: domain, case, party, activity;
-
a role keyword: user, thing, context, external;
-
or one of the keywords property, view or state.
Any point in a model text (a lexical position) will, of necessity, be enclosed in some scope (except for the domain type declaration line). As scopes can be nested, any given point might be inside an arbitrary number of scopes, each enclosing the other until we arrive at the domain’s body. Some, but not all, of these scopes will be type definition bodies. Now we will say that all these definitions are visible from that lexical position. The first visible context definition that we encounter on ‘moving upward’, is the current context.