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.

<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />

Examples: Given the following sequences:<br />

✞<br />

✡✝<br />

secondRoundWinners = [,,,,,,,];<br />

secondRoundRunnersUp = [,,,,,,,]<br />

✆<br />

The operation SecondRound, in <strong>VDM</strong>++ from class GroupPhase returns the sequence<br />

of pairs representing the second round games gives an example of a def statement:<br />

✞<br />

SecondRound : () ==> seq of (Team * Team)<br />

SecondRound () ==<br />

def winners = { gp |-> GroupWinner(gp)<br />

| gp in set dom gps };<br />

runners_up = { gp |-> GroupRunnerUp(gp)<br />

| gp in set dom gps}<br />

in<br />

return ([mk_(winners(secondRoundWinners(i)),<br />

runners_up(secondRoundRunnersUp(i)))<br />

| i in set {1,...,8}])<br />

✡✝<br />

✆<br />

13.3 The Block Statement<br />

Syntax: statement = . . .<br />

| block statement<br />

| . . . ;<br />

block statement = ‘(’, { dcl statement },<br />

statement, { ‘;’, statement }, [ ‘;’ ], ‘)’ ;<br />

dcl statement = ‘dcl’, assignment definition,<br />

{ ‘,’, assignment definition }, ‘;’ ;<br />

assignment definition = identifier, ‘:’, type, [ ‘:=’, expression ] ;<br />

Semantics: The block statement corresponds to block statements from traditional high-level programming<br />

languages. It enables the use of locally defined variables (by means of the declare<br />

statement) which can be modified inside the body of the block statement. It simply denotes<br />

the ordered execution of what the individual statements prescribe. The first statement in the<br />

sequence that returns a value causes the evaluation of the sequence statement to terminate.<br />

This value is returned as the value of the block statement. If none of the statements in the<br />

<strong>10</strong>0

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

Saved successfully!

Ooh no, something went wrong!