Always Statement

The "always" statemernt is a for the user to specify that a set of statements should be re-executed whenever the value of an expression changes or, as in a spreadsheet, that the value of a variable should re-calculated whenever any of the arguments to a calculation involving other variable changes.

There are three forms of the always statement. The simplest has only an assignment statement. The assignment is re-executed whenever its resulting value would change if re-calculated.

Another form also includes a block of statements to also be executed whever the assignment is re-executed.

Finally the third form is similar but instead of an assignment, only the expression portion of the assignment is used, and the block of statements is mandatory.

Formats:

always [variable reference] = [expression]
always [variable reference] = [expression] { [statements] }
always [expression] { [statements] }

Examples

always beta = alpha + 2
always gamma = alpha + 3 {
    alert("gamma changed because alpha changed")
}
always alpha {
   time_of_alpha_change = now()
}