@@ -24,12 +24,26 @@ A *value* is one of the following:
2424
2525* A struct value
2626
27- Every value belongs to exactly one type.
27+ Every value _v_ belongs to exactly one <<Types_Canonical-Types,canonical type>>
28+ _T_ , except as follows:
29+
30+ * Every string value belongs to the type `string` and to
31+ all types `string` _n_ , for any _n_ .
32+
33+ * Every value that belongs to type _T_ also belongs to every
34+ <<Types_Alias-Types,alias type>> whose
35+ <<Types_Underlying-Types,underlying type>> is _T_ .
36+
37+ When a value _v_ belongs to a type _T_ , we say that _v_ is a value
38+ *of type _T_* .
39+
40+ In the following subsections, we describe each kind of value and
41+ its associated canonical types.
2842
2943=== Primitive Integer Values
3044
3145A *primitive integer value* is an ordinary (mathematical) integer value
32- together with a
46+ together with its canonical type, which is a
3347<<Types_Primitive-Integer-Types,primitive integer type>>. Formally, the set of
3448primitive integer values
3549is the disjoint union over the integer types of the values
@@ -43,14 +57,15 @@ stem:[[0, 255\]].
4357stem:[[-2^(w-1), 2^(w-1)-1\]]. For example, `I8` represents the integers
4458stem:[[-128, 127\]].
4559
46- We represent a primitive integer value as an expression followed by a colon and a type.
60+ We represent a primitive integer value as an expression followed by a colon and
61+ a primitive integer type.
4762For example, we write the value 1 at type `U32` as `1: U32`. The value `1:
4863U32` is distinct from the value `1: U8`.
4964
5065=== Integer Values
5166
5267An *integer value* is an ordinary (mathematical) integer value.
53- It has type _Integer_.
68+ Its canonical type is _Integer_.
5469We represent an integer value as an integer number, with no explicit type.
5570For example, `1` is an integer value.
5671
@@ -66,25 +81,34 @@ over the types `F32` and `F64` of the values represented by each type:
6681
6782We write a floating-point values analogously to primitive integer values. For
6883example, we write the value 1.0 at type `F32` as `1.0: F32`.
84+ The canonical type of a floating-point value is `F32` or `F64`.
6985
7086=== Boolean Values
7187
7288A *Boolean value* is one of the values `true` and `false`.
73- Its type is `bool`.
89+ Its canonical type is `bool`.
7490
7591=== String Values
7692
7793A *string value* is a sequence of characters that can be
7894represented as a <<Expressions_String-Literals,string literal expression>>.
7995It is written in the same way as a string literal expression,
8096e.g., `"abc"`.
81- Its type is `string`.
97+ A string value belongs to the following canonical types:
98+
99+ * `string`
100+
101+ * `string` _n_ for any _n_
82102
83103=== Abstract Type Values
84104
85105An *abstract type value* is a value associated with an abstract
86106type.
87- There is one value associated with each abstract type stem:[T].
107+ For each abstract type stem:[T], there is one
108+ value with canonical type stem:[T].
109+ This value is not represented explicitly in the model, but it
110+ may be represented in the generated code, e.g., as an object
111+ with default initialization.
88112We write the value `value of type` stem:[T].
89113
90114=== Anonymous Array Values
@@ -93,10 +117,17 @@ An *anonymous array value* is a value associated with an anonymous
93117array type.
94118We write an anonymous array value similarly to an
95119<<Expressions_Array-Expressions,array expression>>:
96- an anonymous array value has the form `[` stem:[v_1] `,` stem:[...] `,`
120+ an anonymous array value stem:[v] has the form `[` stem:[v_1] `,` stem:[...]
121+ `,`
97122stem:[v_n] `]`, where for each stem:[i in [1,n]], stem:[v_i] is a value of type
98- stem:[T] for some stem:[T].
99- The type of the value is _[_ stem:[n] _]_ stem:[T].
123+ stem:[T] for some <<Types_Canonical-Types,canonical type>> stem:[T].
124+ The canonical type of stem:[v] is _[_ stem:[n] _]_ stem:[T].
125+
126+ Note that for an anonymous array value stem:[v] to be well-formed, the member
127+ values must have identical types.
128+ If an array expression appearing in the source syntax has
129+ member values with non-identical types, then one or more members must be
130+ converted to a different type before forming stem:[v].
100131
101132=== Array Values
102133
@@ -116,16 +147,20 @@ that refers to a
116147with member type stem:[T].
117148
118149. For each stem:[i in [1,n]], stem:[v_i] is a value of type stem:[T].
150+ Note that stem:[T] need not be a canonical type.
151+ For example, it is permissible for stem:[T] to be `T`, for
152+ `T` to be an alias of `U32`, and for stem:[v] to be the value `[ 1: U32, 2: U32 ]`.
153+ In this case `1: U32` and `2: U32` are values of type `T`, as required.
119154
120- The type of the value is stem:[Q].
155+ The canonical type of the value is stem:[Q].
121156
122157=== Enumeration Values
123158
124159An *enumeration value* is a value associated with an
125160<<Definitions_Enumerated-Constant-Definitions,enumerated constant definition>>.
126161It is a pair consisting of the name and the integer value
127162specified in the enumerated constant definition.
128- Its type is the type associated with the
163+ Its canonical type is the type associated with the
129164<<Definitions_Enum-Definitions,enum definition>> in which
130165the enumerated constant definition appears.
131166
@@ -139,8 +174,9 @@ We write an anonymous struct value stem:[v] similarly to a
139174a struct value has the form `{` stem:[m_1] `=` stem:[v_1] `,` stem:[...] `,`
140175stem:[m_n] `=` stem:[v_n] `}`,
141176where for each stem:[i in [1,n]], stem:[v_i] is a value of type stem:[T_i].
142- The type of stem:[v] is _{_ stem:[m_1] _:_ stem:[T_1] _,_ stem:[...] _,_
143- stem:[m_n] _:_ stem:[T_n] _}_.
177+ Each type stem:[T_i] must be a <<Types_Canonical-Types,canonical type>>.
178+ The canonical type of the value is _{_ stem:[m_1] _:_ stem:[T_1] _,_ stem:[...]
179+ _,_ stem:[m_n] _:_ stem:[T_n] _}_.
144180
145181=== Struct Values
146182
@@ -161,8 +197,13 @@ that refers to a
161197. The members of stem:[Q] are stem:[m_i] `:` stem:[T_i] for stem:[i in [1,n\]].
162198
163199. For each stem:[i in [1,n]], stem:[v_i] is a value of type stem:[T_i].
200+ Note that stem:[T_i] need not be a canonical type.
201+ For example, it is permissible for stem:[T_1] to be `T`, for
202+ `T` to be an alias of `U32`, and for stem:[v_1] to be the value `1: U32`.
203+ In this case `1: U32` is a value of type `T`, as required.
164204
165- All the members must be explicitly assigned values.
205+ Each member of the struct value must have an explicit value.
206+ The canonical type of the struct value is stem:[Q].
166207
167208=== Serialized Sizes
168209
@@ -200,3 +241,7 @@ the sum of the serialized sizes of the members of _v_
200241* If _T_ is an
201242<<Types_Abstract-Types,abstract type>>, then _s_ is not specified in FPP. It
202243is up to the implementer of _T_ to provide the serialized size.
244+
245+ * If _T_ is a
246+ <<Types_Alias-Types,alias type>>, then apply these rules to its
247+ <<Types_Underlying-Types,underlying type>>.
0 commit comments