A guard is a named boolean condition that enables the execution of an action block. Standard guards are system defined and associated with specific actions. Custom guards are set and defined by the model developer. If a guard is set, the following action block can execute.

Guards serve two purposes in Scrall. First, they can replace if-then statements with more descriptive cases. Second, they specify essential sequencing when it isn’t obvious from the data dependencies in the actions. If, for example, some action must be performed before another and no data is shared you can use a guard to specify the sequence.

if-then usage

Here we are sending a signal to a selected instance. If the instance selection does not yield an instance, we want to trigger an error message in a user interface domain.

Without guards, you might do this:

the Plane .= Aircraft( Tail number: in.aircraft to land )
if (the Plane)
   Land( Runway: designated runway ) -> the Plane
   Unknown aircraft => UI

With guards it looks like this:

the Plane .= Aircraft( Tail number: in.aircraft to land )
   [exists] Land( Runway: designated runway ) -> the Plane
   [!exists] Unknown aircraft => UI

The .= assignment action automatically sets the guard exists. There is no many guard since that condition would be a non-recoverable error. The guards are optionally indented, but apply to the most recent action. You can put an ! in front of a guard to negate it.

If there are multiple actions to perform, you can put them in an action block using {} brackets.

Here is another example:

Land( Runway: designated runway ) -> Aircraft( Tail number: in.aircraft to land )
        [notarget] Unknown aircraft => UI


To set a guard, put it after an action and give it a name. Then, for some action that must occur afterward, precede it with your named guard.

aircraftX &R4 pilotY [pilot assigned]
// a few other actions
[pilot assigned] go to aircraft -> pilotY

In the above example, the event go to aircraft is always sent after the pilot has been linked to an aircraft.

If multiple actions must be completed before another action can execute, precede it by all of the named guards. Here we are just using numbers for the names:

action 1 [1]
action 2 [2]
[1][2] action 3

Inline shorthand

As a shorthand, you can use the ; symbol to put two actions on one line ensuring that they proceed in the stated order.

action 1; action 2; action 3

The actions above will be executed in the stated order.