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.
<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />
Examples: Using the map GroupG defined in the preceding example, we have:<br />
mk (2,1,0) in set rng GroupG<br />
mk ("Romania",2,1,0) not in set rng GroupG<br />
mk (,2,1,0) mk ("Romania",2,1,0)<br />
6.11 Record Expressions<br />
Syntax: expression = . . .<br />
| record constructor<br />
| record modifier<br />
| . . . ;<br />
record constructor = ‘mk ’, name, ‘(’, [ expression list ], ‘)’ ;<br />
≡ true<br />
≡ true<br />
≡ true<br />
record modifier = ‘mu’, ‘(’, expression, ‘,’, record modification,<br />
{ ‘,’, record modification } ‘)’ ;<br />
record modification = identifier, ‘|->’, expression ;<br />
Semantics: The record constructor has the form:<br />
✞<br />
mk_T(e1, e2, ..., en)<br />
✡✝<br />
✆<br />
where the type of the expressions (e1, e2, ..., en) matches the type of the corresponding<br />
entrances in the composite type T.<br />
The record modification has the form:<br />
✞<br />
✡✝<br />
mu (e, id1 |-> e1, id2 |-> e2, ..., idn |-> en)<br />
where the evaluation of the expression e returns the record value to be modified. All the<br />
identifiers idi must be distinct named entrances in the record type of e.<br />
✆<br />
Examples: If sc is the value mk Score(,3,0,0,9) then<br />
✞<br />
✡✝<br />
mu (sc, drawn |-> sc.drawn + 1, points |-> sc.points + 1)<br />
≡ mk_Score(,3,1,0,<strong>10</strong>)<br />
✆<br />
Further examples are demonstrated in the function win. This function takes two teams and<br />
a set of scores. From the set of scores it locates the scores corresponding to the given teams<br />
(wsc and lsc for the winning and losing team respectively), then updates these using the<br />
56