Developing Apama Applications > Apama EPL Reference > Expressions > Introduction to expressions
Introduction to expressions
EPL has several kinds of expressions:
*Primary and bitwise expressions are used for computations.
*A stream query definition creates a derived stream from an existing stream.
*A stream source template creates a new stream from an event template.
Event expressions are used in on statements for event pattern matching and sequence detection. Event expressions are not ordinary EPL expressions. See Event expressions.
Expression
Primary and Bitwise Expression Notes
When a primary or bitwise expression (called expression for the remainder of this section) is evaluated (that is, it is executed), it will produce a result value if the expression is a variable, a literal, or a combination of values and operators. If the expression is an action or inbuilt method call, then evaluating the expression produces a result value when the action or inbuilt method returns a value, but if the action or inbuilt method does not return a value, then the expression does not produce a result. Note that when an expression includes action or method calls, then evaluating the expression might produce side effects. A side effect is a change in the state of the execution environment. For example, a called action might change the value of a global variable or generate a derived event. If evaluating an expression produces a result, then in addition to a value, the expression result has a type. This is the expression type. An expression’s type is always known at compile time.
The elements of an expression are evaluated roughly from left to right, taking into account parentheses and operator precedence. Binary operators have a left operand and a right operand. If an operator is left-associative, its left operand is evaluated first, followed by the right, and then the operation is performed. If an operator is right-associative, its right operand is evaluated first, followed by the left, then the operation is performed. In action calls, the actual parameter list expressions are evaluated from left to right. Many of the operators used in primary or bitwise expressions are polymorphic and can operate on operands of several types. For example, the addition operator performs floating point addition when its operands are of type decimal or float and performs integer addition when its operands are of type integer. Here are some examples of expressions:
i := (a.size() + b[3]) / (n -1);
i := "foo" + s + " " + b.toString() + f.formatFixed(8);
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.