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.

Chapter 8<br />

Bindings<br />

Syntax: bind = set bind | type bind ;<br />

set bind = pattern, ‘in set’, expression ;<br />

type bind = pattern, ‘:’, type ;<br />

bind list = multiple bind, { ‘,’, multiple bind } ;<br />

multiple bind = multiple set bind<br />

| multiple type bind ;<br />

multiple set bind = pattern list, ‘in set’, expression ;<br />

multiple type bind = pattern list, ‘:’, type ;<br />

Semantics: A bind matches a pattern to a value. In a set bind the value is chosen from the set<br />

defined by the set expression of the bind. In a type bind the value is chosen from the type<br />

defined by the type expression. Multiple bind is the same as bind except that several patterns<br />

are bound to the same set or type. Notice that type binds cannot be executed by the interpreter.<br />

This would require the interpreter to search through infinite domains like the natural<br />

numbers.<br />

Examples: Bindings are mainly used in quantified expressions and comprehensions which can be<br />

seen from these examples:<br />

✞<br />

forall i, j in set inds list & i < j => list(i) 2 }<br />

{ y | y: nat & y > 3 }<br />

79

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

Saved successfully!

Ooh no, something went wrong!