Basic Types: Numeric, Character, Token and Quote Types
VDM-SL includes basic types modelling numbers and characters as follows:
Data types are defined to represent the main data of the modelled system. Each type definition introduces a new type name and gives a representation in terms of the basic types or in terms of types already introduced. For example, a type modelling user identifiers for a log-in management system might be defined as follows:
types UserId = natFor manipulating values belonging to data types, operators are defined on the values. Thus, natural number addition, subtraction etc. are provided, as are Boolean operators such as equality and inequality. The language does not fix a maximum or minimum representable number or a precision for real numbers. Such constraints are defined where they are required in each model by means of data type invariants—Boolean expressions denoting conditions that must be respected by all elements of the defined type. For example a requirement that user identifiers must be no greater than 9999 would be expressed as follows (where <=
is the “less than or equal to” Boolean operator on natural numbers):
Since invariants can be arbitrarily complex logical expressions, and membership of a defined type is limited to only those values satisfying the invariant, type correctness in VDM-SL is not automatically decidable in all situations.
The other basic types include char for characters. In some cases, the representation of a type is not relevant to the model’s purpose and would only add complexity. In such cases, the members of the type may be represented as structureless tokens. Values of token types can only be compared for equality – no other operators are defined on them. Where specific named values are required, these are introduced as quote types. Each quote type consists of one named value of the same name as the type itself. Values of quote types (known as quote literals) may only be compared for equality.
For example, in modelling a traffic signal controller, it may be convenient to define values to represent the colours of the traffic signal as quote types:
Read more about this topic: Vienna Development Method, VDM Features
Famous quotes containing the words basic, token, quote and/or types:
“Insecurity, commonly regarded as a weakness in normal people, is the basic tool of the actors trade.”
—Miranda Richardson (b. 1958)
“It doesnt make any difference how much money a father earns, his name is always Dad-Can-I.... Like all other children, my five have one great talent: they are gifted beggars. Not one of them ever ran into the room, looked up at me, and said, Im really happy that youre my father, and as a tangible token of my appreciation, heres a dollar.”
—Bill Cosby (20th century)
“Ah, yes, I wrote the Purple Cow
Im sorry, now, I wrote it!
But I can tell you, anyhow,
Ill kill you if you quote it.”
—Gelett Burgess (18661951)
“The rank and file have let their servants become their masters and dictators.... Provision should be made in all union constitutions for the recall of leaders. Big salaries should not be paid. Career hunters should be driven out, as well as leaders who use labor for political ends. These types are menaces to the advancement of labor.”
—Mother Jones (18301930)