VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />
✞<br />
✡✝<br />
let p1 = e1, ..., pn = en in s<br />
✆<br />
where p1, ..., pn are patterns, e1, ..., en are expressions which match the corresponding<br />
patterns pi, and s is a statement, of any type, involving the pattern identifiers<br />
of p1, ..., pn. It denotes the evaluation of the statement s in the context in which the<br />
patterns p1, ..., pn are matched against the corresponding expressions e1, ...,<br />
en.<br />
More advanced let statements can also be made by using local function definitions. The<br />
semantics of doing that is simply that the scope of such locally defined functions is restricted<br />
to the body of the let statement.<br />
A let-be-such-that statement has the form<br />
✞<br />
✡✝<br />
let b be st e in s<br />
where b is a binding of a pattern to a set value (or a type), e is a boolean expression, and<br />
s is a statement, involving the pattern identifiers of the pattern in b. The be st e part is<br />
optional. The expression denotes the evaluation of the statement s in the context where the<br />
pattern from b has been matched against an element in the set (or type) from b 1 . If the be<br />
st expression e is present, only such bindings where e evaluates to true in the matching<br />
context are used.<br />
Examples: An example of a let be st statement is provided in the operation GroupWinner<br />
from the class GroupPhase which returns the winning team in a given group:<br />
✞<br />
✡✝<br />
GroupWinner : GroupName ==> Team<br />
GroupWinner (gp) ==<br />
let sc in set gps(gp) be st<br />
forall sc’ in set} gps(gp) \ {sc} &<br />
(sc.points > sc’.points) or<br />
(sc.points = sc’.points and sc.won > sc’.won)<br />
in<br />
return sc.team<br />
The companion operation GroupRunnerUp gives an example of a simple let statement as<br />
well:<br />
✞<br />
GroupRunnerUp_expl : GroupName ==> Team<br />
GroupRunnerUp_expl (gp) ==<br />
1 Remember that only the set bindings can be executed by means of the interpreter.<br />
✆<br />
✆<br />
98