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 />

(permutation is an auxiliary function taking two sequences which returns true iff one<br />

sequence is a permutation of the other.)<br />

13.16 The Duration Statement (<strong>VDM</strong>-RT)<br />

Syntax: statement = . . .<br />

| duration statement ;<br />

duration statement = ‘duration’, ‘(’, numeral, ‘)’,<br />

statement ;<br />

Semantics: The duration statement is a runtime directive to the Toolbox interpreter telling it that<br />

when incrementing the internal clock for the enclosed statement, the value (a natural number)<br />

given in the duration statement should be used instead of the increment which would<br />

normally be computed for that statement. Thus the duration statement provides a mechanism<br />

to override the Toolbox’s default execution time computation.<br />

Example: First a simple example:<br />

✞<br />

✡✝<br />

while n < <strong>10</strong> do<br />

duration(<strong>10</strong>) n := n + 1;<br />

✆<br />

In this example, assuming that this loop is not executed in the context of an enclosing duration<br />

statement, on each iteration of the loop the Toolbox will increment its internal clock by<br />

<strong>10</strong> time units, rather than computing the amount of time required to execute the statement n<br />

:= n + 1.<br />

If duration statements are nested, the outermost one takes precedence and the remainder are<br />

ignored. For instance<br />

✞<br />

✡✝<br />

duration(30)<br />

( n := 1;<br />

while n < <strong>10</strong> do<br />

duration(<strong>10</strong>) n := n + 1;<br />

)<br />

The outer duration statement takes precedence, so assuming this is not executed in the context<br />

of an enclosing duration statement, the interpreter would increment its internal clock by<br />

30 time units when executing this statement.<br />

Note that nesting can occur due to operation calls. Consider the following example:<br />

122<br />

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

Saved successfully!

Ooh no, something went wrong!