The types you define allow you to specify how data values can be formatted, allowing you to declare variables that contain data in this new format. You can then read data back from your variables in expressions.
An expression can read the value of a struct’s field, a union’s field, and from an enumeration
Reading Structs In Expressions
A struct is a type that contains a number of fields. When using a struct value, you can read either an individual field from the struct, or read all the fields. In the illustration, you can access the struct via mouse, or you can access one of the fields (x for example) using the dot operator.
A field of a struct can be used, or the struct can be used in its entirety
Union Expressions
A Union has multiple fields that all give access to the same piece of memory. In effect, the union stores only one of the values from its available fields. This allows you to create a type that can be used to store one of a selection of available values.
A field of a union can be used, or the union can be used in its entirety
Enumeration Expression
The enumeration is the simplest of the custom types to make use of. It defines a list of available options for values of this type. This means that enumerations are just like standard values.
You interact with an enumeration just like other simple data types (Integers, and Doubles for example)
Expressions - Why, When, and How
Expressions have not changed. With structs and unions you now need the additional tools to access the fields within these as part of your expression. The dot operator (.) is used here as it was in the assignment statement to access the fields of a struct or union.
When accessing a value in a struct or union, you start with the variable that contains the data. Where this is a struct or union, you can follow the variable name with a dot (.) and you can then access the fields of the struct or union. When you access a field, the expression now has the same type as the field. So mouse in the illustration is a point_2d type, and mouse.x is an integer.