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!
===State-based modelling=== In VDM-SL, functions do not have side-effects such as changing the state of a persistent global variable. This is a useful ability in many programming languages, so a similar concept exists; instead of functions, ''operations'' are used to change '''state variables''' (also known as ''globals''). For example, if we have a state consisting of a single variable <code>someStateRegister : nat</code>, we could define this in VDM-SL as: <syntaxhighlight lang="rsl"> state Register of someStateRegister : nat end </syntaxhighlight> In VDM++ this would instead be defined as: <syntaxhighlight lang="rsl"> instance variables someStateRegister : nat </syntaxhighlight> An operation to load a value into this variable might be specified as: <syntaxhighlight lang="rsl"> LOAD(i:nat) ext wr someStateRegister:nat post someStateRegister = i </syntaxhighlight> The ''externals'' clause (<code>ext</code>) specifies which parts of the state can be accessed by the operation; <code>rd</code> indicating read-only access and <code>wr</code> being read/write access. Sometimes it is important to refer to the value of a state before it was modified; for example, an operation to add a value to the variable may be specified as: <syntaxhighlight lang="rsl"> ADD(i:nat) ext wr someStateRegister : nat post someStateRegister = someStateRegister~ + i </syntaxhighlight> Where the <code>~</code> symbol on the state variable in the postcondition indicates the value of the state variable before execution of the operation.
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