Values | CPN Tools help |
Declaring constants | CPN ML |
val id = exp;
where id
is an identifier and exp
is a CPN ML expression, including multi-set expressions. The expression represents the value to be associated with the identifier.
Value declarations expressions may use any value representation that is syntactically unique, without a prior colour set declaration. These include: unit, bool, int, real, string, tuple, list, record.
val buffer_size = 10;
val string_val = "A string constant";
val listVal = [1, 2, 5];
val tupleVal = (1, true, "abcd");
Value declarations may use expressions of previously declared colour sets.
val lastPacket = DATA("####")
;
The declaration of lastPacket
would result in an error if a colour set similar to the Packet colour set had not been declared before lastPacket
.
Multi-set and function expressions may be used as value specifiers.
val intMS = 1`2++2`8;
val add3 = fn x => x+3;