VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
public LIMIT : Int = 100;
-- ˅
-- ˄
instance variables
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Apply to the operations that generate the partial functions or the total functions.
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
-- ˅
-- ˄
functions
public calc : () -> ()
calc() ==
-- ˅
is not yet specified
pre
post
-- ˄
;
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Write invariants, preconditions, and postconditions in the User Code Area - which is an area quoted with “˅” and “˄”.
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
public sum : nat;
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
public increment : () ==> ()
increment() ==
-- ˅
sum := sum + 1;
post sum = sum~ + 1;
-- ˄
;
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Using TaggedValue
Click an association element.
Select the TaggedValue tab.
Enter "collection_kind" in the Name, and set/sequence types in the Value. The following set/sequence types can be entered. If this TaggedValue is not set, it is the same as setting "set".
set
set1
seq
seq1
Select the Association End tab.
Enter “*” for the upper limit in the Multiplicity.
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
private bars : seq of Bar;
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Using Stereotype
Click an association element.
Select the Stereotype tab.
Enter "collection_kind=(set/sequence type)" in the Name. The following set/sequence types can be entered. If this Stereotype is not set, it is the same as setting "set".
set
set1
seq
seq1
Select the Association End tab.
Enter “*” for the upper limit in the Multiplicity.
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
private bars : seq of Bar;
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Using TaggedValue
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
private bars : inmap nat to Bar;
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo
Using Stereotype
VDM++ Example Code
class Foo
types
-- ˅
-- ˄
values
-- ˅
-- ˄
instance variables
private bars : inmap nat to Bar;
-- ˅
-- ˄
functions
-- ˅
-- ˄
operations
-- ˅
-- ˄
sync
-- ˅
-- ˄
thread
-- ˅
-- ˄
end Foo