Changeset f3abce9 for doc/theses/jiada_liang_MMath/CFAenum.tex
- Timestamp:
- Aug 7, 2024, 12:53:27 AM (3 months ago)
- Branches:
- master
- Children:
- 1d8a349
- Parents:
- 59fb462
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/CFAenum.tex
r59fb462 rf3abce9 204 204 enum( char ) Letter { A = 'A', ... }; 205 205 enum( @Letter@ ) Greek { Alph = A, Beta = B, ... }; // alphabet intersection 206 \end{cfa} 207 Enumeration @Greek@ may have more or less enums than @Letter@, but the enum values \emph{must} be from @Letter@. 208 Therefore, @Greek@ enums are a subset of type @Letter@ and are type compatible with enumeration @Letter@, but @Letter@ enums are not type compatible with enumeration @Greek@. 209 206 207 void foo(Letter l); 208 foo(Beta); $\C{// foo(value(Beta))}$ 209 \end{cfa} 210 Enumeration @Greek@ may have more or less enumerators than @Letter@, but the enum values \emph{must} be of a member of @Letter@. 211 Therefore, the set of @Greek@ enum value in a subset of the value set of type @Letter@. 212 @Letter@ is type compatible with enumeration @Letter@ thanks to \CFA inserts value conversion whenever @Letter@ be used 213 in place of @Greek@. On the other hand, @Letter@ enums are not type compatible with enumeration @Greek@. 214 As a result, @Greek@ becomes a logical subtype of @Letter@. 215 216 Subset defines an implicit subtyping relationship between two \CFA enumerations. \CFA also has 217 containment inheritance for \CFA enumerations to explicit structure subtyping. 210 218 211 219 \section{Inheritance} … … 238 246 enum() E1 { B }; $\C{// B}$ 239 247 enum() E2 { C, D }; $\C{// C D}$ 240 enum() E3 { inline E1, inline E2, E }; $\C{// {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C ,D {\color{red}]} E}$241 enum() E4 { A, inline E3, F}; $\C{// A {\color{blue}[\(_{E3}\)} {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C ,D {\color{red}]} E {\color{blue}]} F }$248 enum() E3 { inline E1, inline E2, E }; $\C{// {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E}$ 249 enum() E4 { A, inline E3, F}; $\C{// A {\color{blue}[\(_{E3}\)} {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E {\color{blue}]} F }$ 242 250 \end{cfa} 243 251 In the example above, @B@ has the position 0 in @E1@ and @E3@, but it at the position 1 in @E4@ as @A@ taking the 0 in @E4@.
Note: See TracChangeset
for help on using the changeset viewer.