A value declaration binds a value to an identifier (which then works as a constant).

Declaration Syntax

val id = exp;

where id is an identifier and exp is a CPN ML expression, including multiset expressions. The expression represents the value to be associated with the identifier.

Declaration Examples

Value declarations expressions may use any value representation that is syntactically unique, without a prior color 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 color sets.

val lastPacket = DATA(“####”);

The declaration of lastPacket would result in an error if a color set similar to the Packet color 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;

Reserved identifiers

You must be logged in to post a comment.