5.2.3. Creating contexts
One of the design goals for Perspectives is that all context- and role instances must be reachable. This can be attained by direct indexing (e.g. a role is directly linked to its context), by deploying an indexed name, or by a database query that retrieves instances of a particular type. Such a query has to be the expression by which we define a Calculated Role. To differentiate such database-query-based Calculated Roles from those that are defined by a path query, we call them Database Query Roles.
An indexed name has a different extension (reference value) for each end user, e.g. My System.
They must be external roles, possibly filtered. Database Query Roles must be context roles.
The assignment statements for roles preserve this quality. In order to do the same for freshly constructed contexts, we have to bind them directly to a context role in another context, or we must ensure that they are available through a Calculated Role somewhere that performs a database query.
Notice there is no operator to remove a context. Contexts are deleted if they are no longer bound, or, in the case of a context that was never bound but added directly to some Database Query Role, as soon as they are removed from such a role (a role based on the same type).
5.2.3.1. Create context
With create context, we create a context of the given type and bind it to a new instance of the given Enumerated Role type in the current context:
create context ContextType bound to RoleType
In order to bind it in another context, we add a clause:
create context ContextType bound to RoleType in <contextExpression>
It goes without saying that actually the external role of the fresh context is bound to the new role instance.
If RoleType is a Calculated Role that qualifies as a Database Query Role, no role instance is created to bind the new context. However, we require ContextType to be equal to or a specialisation of the result type of the Database Query Role.
5.2.3.2. Create context_
Like with bind_, we may be in the situation that we already have a role instance that acts as binder. For that case, create context_ creates a context instance of the given type and binds it to the role instances selected with <roleExpression>.
create context_ ContextType bound to <roleExpression>