Expressions¶
Expressions can be used to compute delay, period, local tempo, breakpoints in specification, and arguments of internal commands and external messages sent to the environment. Expressions are evaluated into values and this evaluation is supposed to take no time.
In this chapter

we compare actions and expressions and we present the three kind of expressions that exist in Antescofo;

we introduce the general notion of a value (each specific kind of value will be discussed at length in the following chapters);

we detail the notion of a variable;

we explain the use of variables to define a dynamic tempo (a tempo that evolves in time);

we present the conditional expressions;

and finally we explain how to get the exe value associated to each running compound action.
Expressions versus Actions¶
Actions and expressions belongs to two clearly separated worlds in Antescofo:

Expressions appear as parameters of actions and the evaluation of expressions is subordinated to the execution of actions.

The evaluation of an expression does not last over time, thus the evaluation process can be more efficient than the execution of actions^{1}.
This separation may appear sometimes somewhat artificial. For example, the assignment of a variable is an action (because it can trigger activities or alter synchronization or tempo information) but some variables are only introduced to store intermediate values in the computation of a complex expression. The Loop construct is an action but it is useful to implement iterative expressions. A process definition is a value (of type proc) and a handle to the current execution of a compound action is also a value (an exec). Etc.
To make the boundary between the two worlds more permeable, and to take into account the usual syntax of Max or PD message (they have no delimeters between arguments and the end of line is used as terminator), the Antescofo syntax distinguishes between three kinds of expressions. This distinction is only useful for syntactic reasons: they are not allowed to appear anywhere to make the parsing nonambiguous but expressions ‟have the same rights” and are managed in the same way, irrespectively of their kind.
Three Kinds of Expressions¶
Expressions are categorized in three kinds of increasing generality, each including the previous one:

Closed expressions^{2} are best called autodelimited expressions. These expressions are allowed in the specification of a delay, a breakpoint in a curve, the value of an attribute, etc. See section autodelimited expressions below.

Simple expressions are the usual expressions allowed anywhere else, for example in the right hand side of an assignment, as the argument of a function or process call, etc.

Extended expressions are the expressions allowed in the body of a function. They enrich simple expressions with local variables, assignments, messages and instantaneous iterations.
We stress again that these three categories exist only to make the parsing of an augmented score nonambiguous. Expressions have the same status and are managed in the same way, irrespective of their category. So it is possible to turn an expression of a more general category into an equivalent expression of a less general one:

an extended expression can be used in place of a simple expression, simply by calling a function whose body is specified by the extended expression (a function call is a simple expression).

a simple expression can be used where a closed expression is expected, simply by putting it between parentheses.
AutoDelimited Expressions¶
Closed expressions, also called autodelimited expressions, are expressions that are allowed in specific locations:

the specification of a delay,

the arguments of a message,

the arguments of an internal command,

the list of breakpoints in a curve,

the specification of an attribute value,
If a simple or an extended expression is provided where an autodelimited expression is required, a syntax error is declared.
Numeric constants and strings are closed expressions, as well as map
definitions. Tab definitions are closed expressions but the keyword
TAB
is mandatory. A variable is a closed expression too.
Notice that every expression between parentheses is an autodelimited expression. So, a rule of thumb is to put the expressions in the contexts listed above between braces when the expression is more complex than a scalar constant or a variable.
The section syntax of autodelimited expressions gives the full syntax of closed expressions and explains the motivations of these syntactic constraints.
Simple Expressions¶
Simple expressions include:

closed and arithmetic expressions

variables and constant values

data structure definitions (tab, map, nim)

function applications and process calls

variable manipulation
and a combination thereof. A simple expression between parentheses is a closed expression (and a simple expression).
The grammar of simple expressions is defined in simple expression grammar.
Extended Expressions¶
Writing large expressions can be cumbersome and may involve the repetition of common subexpressions. Functions can be used to avoid the repeated evaluations of common subexpressions. In addition, the body of a function is an extended expression, which is a sequence of simple expressions enriched with local variables, messages, assignments and loops.
Extended expressions enable a more concise and more readable specification of expressions. They are described in the chapter Functions.
Next, we introduce the general notion of value.
You may also go directly to:

For instance, the implementation of a Group implies a state to maintain an environment accessible by the group's childs, it requires a scheduler to manage the delay, additional computation for the management of synchronization and the translation of relative delays into physical time, etc. Even if a compound action performs instantaneously, its execution is a little more costly than its corresponding expression. ↩

The term closed expression usually refers to an expression that contains no free variables. This is not the meaning used here. A closed expressions refer here to expressions that can be put in sequence without ambiguity. See paragraph autodelimited expressions. ↩