Variables | CPN Tools help |
Description of CPN variables and reference variables | CPN ML |
Variables | A variable is an identifier whose value can be changed during the execution of the model. |
Binding | Binding is the association of a value with a variable. A binding has both scope and content. |
Scope | Scope is the locations in a model in which a particular binding can be referenced. |
Extent | Extent is the interval during which a particular binding is in effect. |
var
and the name of a previously declared colour set.
var id1, id2, ..., idn : cs_name;
where:
idi
must be an identifier.
:
is the syntactic separator between the identifier(s)
cs_name
is the name of a previously declared colour set.
var i,j,k : INT;
var intList : IntList;
Reference variables must never be used in any way that affects the enabling of transitions. To illustrate the problems that could arise if this rule were broken, consider the following example:
A reference variable, refvar
is used in the arc inscription of two different transitions, transition A and transition B. Both are enabled, and transition A fires. Transition A changes the value of refvar
in such a way that transition B is no longer actually enabled. However, the simulator has no way of knowing this, since enabled transitions are not rechecked before they are fired (to recheck each time a trasition is chosen for firing would degrade performance to the point of unusability). Attempting to fire transition B results in unpredictable system errors.
globref id = exp;
globref i = 10;
globref cur_date = (Mon, 5);
!r |
contents of the reference variable r |
r:=v |
assignment of the value v to the reference variable r |
ref v |
reference constructor |
inc r |
increment contents of integer reference variable r by one, i.e. add one to the contents of r |
dec r |
decrement contents of integer reference variable r by one, i.e. subtract one from the contents of r |