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

Data Type Definitions<br />

As in traditional programming languages it is possible to define data types in the <strong>VDM</strong> languages<br />

and give them appropriate names. Such an equation might look like:<br />

✞<br />

types<br />

✡✝<br />

Amount = nat<br />

✆<br />

Here we have defined a data type with the name “Amount” and stated that the values which<br />

belong to this type are natural numbers (nat is one of the basic types described below). One<br />

general point about the type system of the <strong>VDM</strong> languages which is worth mentioning at this point<br />

is that equality and inequality can be used between any value. In programming languages it is<br />

often required that the operands have the same type. Because of a construct called a union type<br />

(described below) this is not the case for the <strong>VDM</strong> languages.<br />

In this section we will present the syntax of data type definitions. In addition, we will show how<br />

values belonging to a type can be constructed and manipulated (by means of built-in operators).<br />

We will present the basic data types first and then we will proceed with the compound types.<br />

3.1 Basic Data Types<br />

In the following a number of basic types will be presented. Each of them will contain:<br />

• Name of the construct.<br />

• Symbol for the construct.<br />

• Special values belonging to the data type.<br />

• Built-in operators for values belonging to the type.<br />

• Semantics of the built-in operators.<br />

5

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

Saved successfully!

Ooh no, something went wrong!