VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 13. Statements<br />
where expression e is the return value of the operation.<br />
Examples: In the following example OpCall is an operation call whereas FunCall is a function<br />
call. As the if statement only accepts statements in the two branches FunCall is<br />
“converted” to a statement by using the return statement.<br />
✞<br />
✡✝<br />
if test<br />
then OpCall()<br />
else return FunCall()<br />
For instance in <strong>VDM</strong>++, we can extend the stack class from the previous section with an<br />
operation which examines the top of the stack:<br />
✞<br />
✡✝<br />
public Top : () ==> Elem<br />
Top() ==<br />
return (hd stack);<br />
✆<br />
✆<br />
13.11 Exception Handling Statements<br />
Syntax: statement = . . .<br />
| always statement<br />
| trap statement<br />
| recursive trap statement<br />
| exit statement<br />
| . . . ;<br />
always statement = ‘always’, statement, ‘in’, statement ;<br />
trap statement = ‘trap’, pattern bind, ‘with’, statement, ‘in’,<br />
statement ;<br />
recursive trap statement = ‘tixe’, traps, ‘in’, statement ;<br />
traps = ‘{’, pattern bind, ‘|->’, statement,<br />
{ ‘,’, pattern bind, ‘|->’, statement }, ‘}’ ;<br />
exit statement = ‘exit’, [ expression ] ;<br />
Semantics: The exception handling statements are used to control exception errors in a specification.<br />
This means that we have to be able to signal an exception within a specification. This<br />
can be done with the exit statement, and has the form:<br />
115