VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 13. Statements<br />
✡✝<br />
def t = GroupWinner(gp)<br />
in let sct = iota sc in set gps(gp) & sc.team = t<br />
in<br />
let sc in set gps(gp) \ {sct} be st<br />
forall sc’ in set gps(gp) \ {sc,sct} &<br />
(sc.points > sc’.points) or<br />
(sc.points = sc’.points and sc.won > sc’.won)<br />
in<br />
return sc.team<br />
✆<br />
Note the use of the def statement (section 13.2) here; this is used rather than a let statement<br />
since the right-hand side is an operation call, and therefore is not an expression.<br />
13.2 The Define Statement<br />
Syntax: statement = . . .<br />
| def statement<br />
| . . . ;<br />
def statement = ‘def’, equals definition,<br />
{ ‘;’, equals definition },[ ‘;’ ], ‘in’,<br />
statement ;<br />
equals definition = pattern bind, ‘=’, expression ;<br />
Semantics: A define statement has the form:<br />
✞<br />
✡✝<br />
def pb1 = e1;<br />
...<br />
pbn = en<br />
in<br />
s<br />
✆<br />
The define statement corresponds to a define expression except that it is also allowed to use<br />
operation calls on the right-hand sides. Thus, operations that change the state can also be<br />
used here, and if there are more than one definition they are evaluated in the order in which<br />
they are presented. It denotes the evaluation of the statement s in the context in which<br />
the patterns (or binds) pb1, ..., pbn are matched against the values returned by the<br />
corresponding expressions or operation calls e1, ..., en 2 .<br />
2 If binds are used it simply means that the values which can match the pattern are further constrained by the type or set<br />
expression as it is explained in section 7.<br />
99