Ignore:
Timestamp:
Aug 4, 2024, 11:47:20 AM (42 hours ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
065de93
Parents:
b797fe36
Message:

merge local changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/jiada_liang_MMath/CFAenum.tex

    rb797fe36 r1697c40  
    202202
    203203\CFA Plan-9 inheritance may be used with \CFA enumerations, where Plan-9 inheritance is containment inheritance with implicit unscoping (like a nested unnamed @struct@/@union@ in C).
     204Containment is norminative: an enumeration inherits all enumerators from another enumeration by declaring an @inline statement@ in its enumerator lists.
     205\begin{cfa}
     206enum( char * ) Names { /* as above */ };
     207enum( char * ) Names2 { @inline Names@, Jack = "JACK", Jill = "JILL" };
     208enum( char * ) Names3 { @inline Names2@, Sue = "SUE", Tom = "TOM" };
     209\end{cfa}
     210In the preceding example, @Names2@ is defined with five enumerators, three of which are from @Name@ through containment, and two are self-declared.
     211@Names3@ inherits all five members from @Names2@ and declare two additional enumerators.
     212
     213Enumeration inheritance forms a subset relationship. Specifically, the inheritance relationship for the example above is:
     214\begin{cfa}
     215Names $\(\subset\)$ Names2 $\(\subset\)$ Names3 $\C{// enum type of Names}$
     216\end{cfa}
     217
    204218Inheritance can be nested, and a \CFA enumeration can inline enumerators from more than one \CFA enumeration, forming a tree-like hierarchy.
    205219However, the uniqueness of enumeration name applies to enumerators, including those from supertypes, meaning an enumeration cannot name enumerator with the same label as its subtype's members, or inherits
     
    207221common supertype (the diamond problem), since such would unavoidably introduce duplicate enumerator labels.
    208222
    209 \begin{cfa}
    210 enum( char * ) Names { /* as above */ };
    211 enum( char * ) Names2 { @inline Names@, Jack = "JACK", Jill = "JILL" };
    212 enum( char * ) Names3 { @inline Names2@, Sue = "SUE", Tom = "TOM" };
    213 \end{cfa}
    214223
    215224% Enumeration @Name2@ inherits all the enumerators and their values from enumeration @Names@ by containment, and a @Names@ enumeration is a @subtype@ of enumeration @Name2@.
    216225% Note, that enumerators must be unique in inheritance but enumerator values may be repeated.
    217226
    218 @Names2@ is defined with five enumerators, three of which are from @Name@ through containment, and two are self-declared.
    219 @Names3@ inherits all five members from @Names2@ and declare two additional enumerators.
     227
    220228
    221229% The enumeration type for the inheriting type must be the same as the inherited type;
    222230% hence the enumeration type may be omitted for the inheriting enumeration and it is inferred from the inherited enumeration, as for @Name3@.
    223231% When inheriting from integral types, automatic numbering may be used, so the inheritance placement left to right is important.
    224 Specifically, the inheritance relationship for @Names@ is:
    225 \begin{cfa}
    226 Names $\(\subset\)$ Names2 $\(\subset\)$ Names3 $\C{// enum type of Names}$
    227 \end{cfa}
     232
    228233
    229234% The enumeration base for the subtype must be the same as the super type.
Note: See TracChangeset for help on using the changeset viewer.