January 2020
Intermediate to advanced
532 pages
13h 31m
English
Perhaps the reason why we use abstract types in the fields in the first place is to support different types of data in the field. Taking the Point type in the previous section, we can see that the type can be useful in the context of computer games, where the coordinates are identified by integer pixel positions on the screen. On the other hand, we also think that the same type may be useful for storing coordinates of shapes in architectural diagrams, in which case, we would want floating-point values.
If we want to be flexible, we would want to support Point fields with any subtype of the Real type. Conceptually, we want something like this:
struct Point x::Real y::Realend
However, since ...
Read now
Unlock full access