This is documented in the NModel package. Most users
will not need to do this kind of extension. Creating subclasses of CompoundValue is the easiest
way to add data types.
158 Modeling Systems with Structured State
Structural equality may be contrasted with reference equality where two objects
are equal if they occupy the same location of the computer??™s memory. In objectoriented
programming languages, reference equality is the default. However, structual
equality may be explicitly provided by an implementation. For example, the
string type in .NET languages provides structural equality.
Sometimes wewant to use data structures that go beyond the built-in value types.3
We can do this with custom data types. But in order to preserve the desirable property
of state comparison, we need to use custom data types with structural equality.
The C# language provides a keyword struct that may be used to declare data types
with structural equality. There are some technical limitations here ??“ for example, C#
structs must be of a fixed length in memory. The NModel framework uses classes
instead of structs for implementing structural data types.
In order for equality of states to be well defined, we use compound values.
Compound values are data types distinguished by their use of structural equality and
their ability to handle variable-length and tree-structured data in addition to records
of fixed size.
Pages:
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225