25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6. Expressions<br />

mu operator. The set of teams is then updated with the new scores replacing the original<br />

ones.<br />

✞<br />

✡✝<br />

win : Team * Team * set of Score -> set of Score<br />

win (wt,lt,gp) ==<br />

let wsc = iota sc in set gp & sc.team = wt,<br />

lsc = iota sc in set gp & sc.team = lt<br />

in<br />

let new_wsc = mu (wsc, won |-> wsc.won + 1,<br />

points |-> wsc.points + 3),<br />

new_lsc = mu (lsc, lost |-> lsc.lost + 1)<br />

in<br />

(gp \ {wsc,lsc}) union {new_wsc, new_lsc}<br />

pre forall sc1, sc2 in set gp &<br />

sc1 sc2 sc1.team sc2.team<br />

and {wt,lt} subset {sc.team | sc in set gp}<br />

✆<br />

6.12 Apply Expressions<br />

Syntax: expression = . . .<br />

| apply<br />

| field select<br />

| tuple select<br />

| function type instantiation<br />

| . . . ;<br />

apply = expression, ‘(’, [ expression list ], ‘)’ ;<br />

field select = expression, ‘.’, identifier ;<br />

tuple select = expression, ‘.#’, numeral ;<br />

function type instantiation = name, ‘[’, type, { ‘,’, type }, ‘]’ ;<br />

Semantics: The field select expression can be used for records and it has already been explained<br />

in section 3.2.5 so no further explanation will be given here.<br />

The apply is used for looking up in a map, indexing in a sequence, and finally for calling<br />

a function. In section 3.2.3 it has already been shown what it means to look up in a map.<br />

Similarly in section 3.2.2 it is illustrated how indexing in a sequence is performed.<br />

In the <strong>VDM</strong> languages an operation can also be called here. This is not allowed in standard<br />

<strong>VDM</strong>-SL and because this kind of operation call can modify the state such usage should<br />

57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!