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.
<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />
In another module/class we can access this function by in <strong>VDM</strong>-SL first importing the module<br />
CGRel then by using the following call<br />
✞<br />
✡✝<br />
CGRel‘build_rel({mk_(, )})<br />
Note that in <strong>VDM</strong>++ and <strong>VDM</strong>-RT build rel function must have an access modifier<br />
allowing access to it outside the defining class.<br />
✆<br />
6.25 The Undefined Expression<br />
Syntax: expression = . . .<br />
| undefined expression ;<br />
undefined expression = ‘undefined’ ;<br />
Semantics: The undefined expression is used to state explicitly that the result of an expression<br />
is undefined. This could for instance be used if it has not been decided what the result of<br />
evaluating the else-branch of an if-then-else expression should be. When an undefined expression<br />
is evaluated the interpreter will terminate the execution and report that an undefined<br />
expression was evaluated.<br />
Pragmatically use of undefined expressions differs from pre-conditions: use of a pre-condition<br />
means it is the caller’s responsibility to ensure that the pre-condition is satisfied when the<br />
function is called; if an undefined expression is used it is the called function’s responsibility<br />
to deal with error handling.<br />
Examples: We can check that the type invariant holds before building Score values:<br />
✞<br />
✡✝<br />
build_score : Team * nat * nat * nat * nat -> Score<br />
build_score (t,w,d,l,p) ==<br />
if 3 * w + d = p<br />
then mk_Score(t,w,d,l,p)<br />
else undefined<br />
✆<br />
6.26 The Precondition Expression<br />
Syntax: expression = . . .<br />
| precondition expression ;<br />
precondition expression = ‘pre ’, ‘(’, expression,<br />
[ { ‘,’, expression } ], ‘)’ ;<br />
70