[Next] [Up] [Previous] [Contents]
Next: Complex conditionals - switch Up: Conditionals Previous: Simple conditionals

Defaults

The ``default'' construct provides a way of automatically filling in the cases where a signal is undefined with a default value. The syntax is:

        default
          <stmt1>
        in
          <stmt2>

The effect of this statement is to use the assignments in <stmt1> in any cases in <stmt2> where the given signal is unassigned. For example,

        default
          x := foo;
        in
        {
          if(c)
          {
            x := bar;
            next(y) := y + 1;
          }
          else
            next(y) := y + 2;
        }
is equivalent to

        next(y) := c ? y + 1 : y + 2;
        x := c ? bar : foo;

An assignment to next(x) may also appear in the default statement. The effect is again to insert the default assignment in any cases where next(x) is not defined. Default statements may be nested inside conditionals, and vice-versa, and groups of statements may appear in both the ``default'' part and the ``in'' part.



Ken McMillan
Sat Jun 6 21:41:59 PDT 1998