Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Vienna Development Method
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Basic types: numeric, character, token and quote types=== VDM-SL includes basic types modelling numbers and characters as follows: {| border="1" class="wikitable" |+ style="background:#ffdead;" | Basic Types |- | <code>bool</code> || [[Boolean data type|Booleans]] || {{mono|false, true}} |- | <code>nat</code> || [[natural number]]s (including zero) || {{mono|0, 1, 2, 3, 4, 5 ...}} |- | <code>nat1</code> || natural numbers (excluding zero) || {{mono|1, 2, 3, 4, 5, ...}} |- | <code>int</code> || [[integer]]s || {{mono|..., −3, −2, −1, 0, 1, 2, 3, ...}} |- | <code>rat</code> || [[rational number]]s || {{mono|a/b}}, where {{mono|a}} and {{mono|b}} are integers, {{mono|b}} is not {{mono|0}} |- | <code>real</code> || [[real number]]s || {{mono|...}} |- | <code>char</code> || characters || {{mono|A, B, C, ...}} |- | <code>token</code> || structureless tokens || {{mono|...}} |- | <code><A></code> || the quote type containing the value <code><A></code> || {{mono|...}} |} 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: <syntaxhighlight lang="text"> types UserId = nat </syntaxhighlight> For 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 <code><=</code> is the "less than or equal to" Boolean operator on natural numbers): <syntaxhighlight lang="text"> UserId = nat inv uid == uid <= 9999 </syntaxhighlight> 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: <syntaxhighlight lang="bnf"> <Red>, <Amber>, <FlashingAmber>, <Green> </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Vienna Development Method
(section)
Add topic