Table of Contents
Queries are used in rules and query expressions (Section 16.4, “Query Expressions”) to specify a pattern. At run-time, occurences of this pattern in the current relational data source (to be more precise, in its extent, Section 3.2, “Run-Time Model”) are searched. The query syntax provides versatile means for specifying patterns, including a rich set of built-in predicates, user-defined predicates, and transitive closures.
A query consists of a set of predicates and query variables. The sequential evaluation of a query binds values to query variables in order to fulfil the conditions imposed by the predicates. If a complete binding has been found which matches all predicates, this match is yielded as one of the results of the query. The current binding of query variables is part of the query state.
In the sequel, the predicates of the XL programming language are described. Each predicate is specified by the following properties:
A predicate may have a set of parameters, among them in- and out-parameters. It has either no in- and out-parameters, or it has both an in- and an out-parameter. Parameters of predicates have a compile-time type. The in-parameter may coincide with the out-parameter, in this case the parameter is called the predicate's in-out-parameter. In- and out-parameters are used when neighbouring predicates of a connected predicate are to be connected.
In- and out-parameters are either open or closed. This information is used for connecting predicates, too.
A predicate is fulfilled, given a binding for its query variables, only if a specific condition is fulfilled.
Query variables are a special kind of local
variables. They are implicitly
final in the sense of
the Java programming language. It is illegal to assign values
to query variables, even in their declaration.
Instead of this, values are bound
to query variables as part of the sequential evaluation of a query;
this evaluation is performed by the run-time system of the XL
Query variables are declared explicitly by compound predicates and some other predicates, or implicitly by a compiler for the XL programming language where this is needed. The identifiers of the latter have to be generated such that they are distinct from any other identifier.
An explicitly declared query variable
is a label
for a place (Section 17.3.1, “Places”).
If the place is a node place
and a wrapper is needed for the type of
(Section 3.1, “Compile-Time Model”) in order to represent its values
v is wrapped
by another query variable which is called the
wrapper variable (Section 17.3.1, “Places”).
of the wrapper variable is the identifier of
with the single character
Query variables are
represented by instances of
their values are stored on the stack of the extended state
of the virtual machine (Chapter 4, Extended State of the Virtual Machine). Otherwise,
the run-time system of the XL programming language would not be able
to bind values to these variables.