Page tree

Alf Plugin 19.0 LTR SP4 Documentation

Like Java and JavaScript, Alf uses the keyword this to denote the current instance of the context Class in which the this expression occurs. Unlike Java and JavaScript, however, the Alf specification requires that this be used explicitly in order to access features (Properties, Operations and Receptions) of the context Class. For example, this is used extensively in the activity diagram shown below to access context Properties and to invoke the getCurrentTemp Operation.

Accessing context features using this

The Alf Plugin implements an extension to the Alf language that allows context features to be accessed by name without explicitly using a this prefix. This is similar to what is allowed in Java and JavaScript. For example, the meaning of the Alf code in the above example remains the same if all the this expressions are dropped, as shown below.

Accessing context features without using this

Unlike Java and JavaScript, Alf allows new local names to be defined without an explicit declaration. This can result in the masking of errors if the name of a context attribute is misspelled on the left-hand side of an assignment statement. For instance, if the assignment in the action on the lower left in the activity above were changed to Fcntrol = Fmin; (with "Fcontrol" misspelled to "Fcntrol"), this would not be reported as an error. Rather, the assignment would simply define a new local name Fcntrol within the Opaque Action, which would be assigned Fmin as its initial value, with no effect on Fcontrol.


  • No labels