25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13. Statements<br />

block returns a value, the evaluation of the block statement is terminated when the last statement<br />

in the block has been evaluated. When the block statement is left the values of the<br />

local variables are discharged. Thus, the scope of these variables is simply inside the block<br />

statement.<br />

Examples: In the context of a <strong>VDM</strong>-SL state definition<br />

✞<br />

✡✝<br />

state St of<br />

x: nat<br />

y: nat<br />

l: seq1 of nat<br />

end<br />

or in the context of a <strong>VDM</strong>++ instance variables<br />

✞<br />

✡✝<br />

instance variables<br />

x: nat;<br />

y: nat;<br />

l: seq1 of nat;<br />

the operation Swap uses a block statement to swap the values of variables x and y:<br />

✞<br />

✡✝<br />

Swap : () ==> ()<br />

Swap () ==<br />

(dcl temp: nat := x;<br />

x := y;<br />

y := temp<br />

)<br />

✆<br />

✆<br />

✆<br />

13.4 The Assignment Statement<br />

Syntax: statement = . . .<br />

| general assign statement<br />

| . . . ;<br />

general assign statement = assign statement<br />

| multiple assign statement ;<br />

assign statement = state designator, ‘:=’, expression ;<br />

<strong>10</strong>1

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

Saved successfully!

Ooh no, something went wrong!