The language supports the usual complement of operators: and,
or,
not,
+,
‑,
/,
*,
%,
<,
>,
==,
!=,
<=,
>=,
(,
). Note that the
< character must be escaped as
< in order to comply with XML syntax restrictions.
Literal values can be specified for integer, floating point, boolean, and string. The expression language supports the same syntax for literal values as that of Slice (see
Section 4.9.5), with one exception: string literals must be enclosed in single quotes.
Certain descriptors introduce symbols that can be used in expressions. These symbols must comply with the naming rules for Slice identifiers (i.e., a leading letter followed by zero or more alphanumeric characters). Data members are accessed using dotted notation, such as
value.memberA.memberB.
Expressions can refer to Slice constants and enumerators using scoped names. In a
transformdb descriptor, there are two sets of Slice definitions, therefore the expression must indicate which set of definitions it is accessing by prefixing the scoped name with
::Old or
::New. For example, the expression
old.fruitMember == ::Old::Pear evaluates to
true if the data member
fruitMember has the enumerated value
Pear. In
dumpdb, only one set of Slice definitions is present and therefore the constant or enumerator can be identified without any special prefix.
The keyword nil represents a nil value of type
Object. This keyword can be used in expressions to test for a nil object value, and can also be used to set an object value to nil.
Dictionary and sequence elements are accessed using array notation, such as userMap['joe'] or
stringSeq[5]. An error occurs if an expression attempts to access a dictionary or sequence element that does not exist. For dictionaries, the recommended practice is to check for the presence of a key before accessing it:
See Section 40.8.8 for more information on the
containsKey function.
The expression language supports two forms of function invocation: member functions and global functions. A member function is invoked on a particular data value, whereas global functions are not bound to a data value. For instance, here is an expression that invokes the
find member function of a
string value:
The string data type supports the following member functions:
The dictionary data type supports the following member function:
Returns true if the dictionary contains an element with the given key, or
false otherwise. The
key argument must have a value that is compatible with the dictionary’s key type.
Returns true if the object implements the given interface type, or
false otherwise. This function cannot be invoked on a nil object.