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 6. Expressions<br />

Examples: Assuming the classes Tree, BinarySearchTree, Queue, and identifiers t, b, q<br />

as in the previous example, we have:<br />

isofclass(Tree,t) ≡ true<br />

isofclass(Tree,b) ≡ true<br />

isofclass(Tree,q) ≡ false<br />

isofclass(Queue,q) ≡ true<br />

isofclass(BinarySearchTree,t) ≡ false<br />

isofclass(BinarySearchTree,b) ≡ true<br />

6.20 Same Base Class Membership (<strong>VDM</strong>++ and <strong>VDM</strong>-RT)<br />

Syntax: expression = . . .<br />

| samebaseclass expression<br />

| . . . ;<br />

samebaseclass expression =<br />

‘samebaseclass’,<br />

‘(’, expression, expression, ‘)’ ;<br />

Semantics: The function samebaseclass when applied to object references expression1<br />

and expression2 yields the boolean value true if and only if the objects denoted by<br />

expression1 and expression2 are instances of classes that can be derived from the<br />

same root superclass, and false otherwise.<br />

Examples: Assuming the classes Tree, BinarySearchTree, Queue, and identifiers t, b, q<br />

as in the previous example, suppose that AVLTree is another subclass of Tree, BalancedBST<br />

is a subclass of BinarySearchTree, a is an instance of AVLTree and bb is an instance<br />

of BalancedBST :<br />

samebaseclass(a,b) ≡ true<br />

samebaseclass(a,bb) ≡ true<br />

samebaseclass(b,bb) ≡ true<br />

samebaseclass(t,bb) ≡ false<br />

samebaseclass(q,a) ≡ false<br />

6.21 Same Class Membership (<strong>VDM</strong>++ and <strong>VDM</strong>-RT)<br />

Syntax: expression = . . .<br />

| sameclass expression<br />

| . . . ;<br />

sameclass expression = ‘sameclass’,<br />

‘(’, expression, expression, ‘)’ ;<br />

65

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

Saved successfully!

Ooh no, something went wrong!