You can use the Alf editor to create an Alf body for a new default value for a Property (e.g., the attribute of a Class) or to edit the existing Alf body of a Property. The Alf expression for a default value is stored as the the body of an Opaque Expression with the language Alf. Compiling this Alf code results in the creation of an executable Activity that returns the value of the Alf expression. This Activity is linked to the Opaque Expression as its the Behavior property. (See also the discussion on the Alf compiler)


To create a new default value for a Property using Alf


  1. Open the Specification window for the Property (from either the Model Browser or its representation on a Class diagram).
  2. Click on the Default Value field, press the Show Shortcut Menu button (see the figure below) and select Value Specification > Opaque Expression.



  3. Close the Specification window.
  4. Select the Property (either in the Model Browser or as it appears on a Class diagram) and open the Alf editor window (select Windows > Alf), if it isn't already open.
  5. Enter an Alf expression and click on the Save button to compile and save the code.

    Note that the text entered must be for an expression, not a statement. Therefore, it must not have a semicolon at the end.

    If the Property already has a non-Alf default value, then, to enter an Alf default value, open its Specification window and proceed as above to create a new default value with an Alf body, replacing the previous default value.


To edit an existing Alf body for the default value of a Property


  • Select the Property in the Model Browser or on a Class Diagram and open the Alf editor window (select Windows > Alf), if it isn't already open. The existing Alf expression will be displayed in the window.

The Alf code for a default value can also be entered or edited directly in the Body and Language property in the Specification window for the Opaque Expression. If you open the Edit Body and Language window, then the Alf code may be edited just as in the Alf editor window. However, instead of Save and Revert buttons, this window has OK and Cancel buttons, either of which will close it. If you press OK, then the Alf text is saved, and, if it has no errors, compiled. If you press Cancel, the Alf text is not saved.

Editing Alf code for a default value in an Opaque Expression body

To be recognized as Alf code, the Body of an Opaque Expression must have the Language Alf. If your project was created using the Alf project template, then Alf will be the default language. Otherwise, select Alf from the Language menu (you may have to scroll upwards in the menu to find the selection for Alf).

To make Alf the default language for Opaque Expressions


  1. Select Options > Project.
  2. On the left, under Default model properties, select Opaque Expression.
  3. Click on the Language field and then on the small + button on the right.
  4. Enter Alf (spelled and capitalized in exactly that way) and click on OK.
  5. Click on OK to close the options window.

.