I am new to Eiffel and I am trying to understand how the "primitive" types (e.g, INTEGER_32, REAL_64, etc.) are implemented. I am confused by what appears to be a circular dependency in the EIFFEL libary class source files.
Primitive types are implemented as "expanded" versions of a non-expanded parent class. For example, INTEGER_32 is an expanded child of INTEGER_REF_32. (Note that "expanded" does not mean "an instance of". An expanded class is a class, not an object.)
An INTEGER_REF_32 contains an instance of an expanded INTEGER_32 within it. It makes sense that there must be an expanded integer somewhere within an INTEGER_REF_32 object, but here that means that the parent contains an instance of its child.
It gets more confusing when you look at the definitions of the features:
Within INTEGER_32, the feature/method named "as_integer_64" is redefined simply as "Result := Precurser", where Precurser means to use the parent's feature. In the parent, which is INTEGER_REF_32, "as_integer_64" is defined as "Result := item.as_integer_64", where "item" is the expanded INTEGER_32! In other words, the child calls its parent's feature, and the parent calls the child's feature. I am also puzzled why the expanded version explicitly redefines "as_integer_64" with what would appear to be an equivalent definition.
I expected to see implementation details for primitive types terminate with some indication that certain features are internally defined. Instead I found these circular definitions. Obviously the compiler knows more about the primitive types than what appears in the source text files. Does the compiler ignore the source text when it sees a primitive type it knows about, or does Precurser take on a different meaning in this context? Is the redefinition some sort of hint to the compiler, or something to keep the parser happy?