Changeset 0c51c8b4 for doc/theses/jiada_liang_MMath/CFAenum.tex
- Timestamp:
- Aug 6, 2024, 9:49:56 AM (3 months ago)
- Branches:
- master
- Children:
- efd055c
- Parents:
- c03af31
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/CFAenum.tex
rc03af31 r0c51c8b4 6 6 7 7 8 \section{ EnumerationSyntax}9 10 \CFA extends the C enumeration declaration \see{\VRef{s:CEnumeration}} by parameterizing with a type (like a generic type), and adding Plan-9 inheritance \see{\VRef{s: EnumerationInheritance}} using an @inline@ to another enumeration type.8 \section{Syntax} 9 10 \CFA extends the C enumeration declaration \see{\VRef{s:CEnumeration}} by parameterizing with a type (like a generic type), and adding Plan-9 inheritance \see{\VRef{s:CFAInheritance}} using an @inline@ to another enumeration type. 11 11 \begin{cfa}[identifierstyle=\linespread{0.9}\it] 12 12 $\it enum$-specifier: … … 24 24 25 25 26 \section{ EnumerationOperations}26 \section{Operations} 27 27 28 28 \CFA enumerations have access to the three enumerations properties \see{\VRef{s:Terminology}}: label, order (position), and value via three overloaded functions @label@, @posn@, and @value@ \see{\VRef{c:trait} for details}. … … 43 43 A A @0@ 3 44 44 \end{cfa} 45 Finally, there is an additional enumeration routine @countof@ (like @sizeof@, @typeof@) that returns the number of enumerators in an enumeration. 46 \begin{cfa} 47 enum(int) E { A, B, C, D }; 48 countof( E ); // 4 49 \end{cfa} 50 This auto-generated function replaces the C idiom for automatically computing the number of enumerators \see{\VRef{s:Usage}}. 45 Finally, there is an additional enumeration pseudo-function @countof@ (like @sizeof@, @typeof@) that returns the number of enumerators in an enumeration. 46 \begin{cfa} 47 enum(int) E { A, B, C, D } e; 48 countof( E ); // 4, type argument 49 countof( e ); // 4, variable argument 50 \end{cfa} 51 This buildin function replaces the C idiom for automatically computing the number of enumerators \see{\VRef{s:Usage}}. 51 52 \begin{cfa} 52 53 enum E { A, B, C, D, @N@ }; // N == 4 … … 197 198 198 199 199 \section{Enumeration Inheritance} 200 \label{s:EnumerationInheritance} 200 \section{Subset} 201 202 An enumeration's type can be another enumeration. 203 \begin{cfa} 204 enum( char ) Letter { A = 'A', ... }; 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 210 211 \section{Inheritance} 212 \label{s:CFAInheritance} 201 213 202 214 \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). 203 215 Containment is nominative: an enumeration inherits all enumerators from another enumeration by declaring an @inline statement@ in its enumerator lists. 204 216 \begin{cfa} 205 enum( char * ) Names { /* $\see{\VRef[Figure]{ s:EnumerationInheritance}}$ */ };217 enum( char * ) Names { /* $\see{\VRef[Figure]{f:EumeratorTyping}}$ */ }; 206 218 enum( char * ) Names2 { @inline Names@, Jack = "JACK", Jill = "JILL" }; 207 219 enum( char * ) Names3 { @inline Names2@, Sue = "SUE", Tom = "TOM" }; … … 302 314 303 315 304 \section{ EnumeratorControl Structures}316 \section{Control Structures} 305 317 306 318 Enumerators can be used in multiple contexts. … … 392 404 393 405 394 \section{ EnumerationDimension}406 \section{Dimension} 395 407 396 408 \VRef{s:EnumeratorTyping} introduces the harmonizing problem between an enumeration and secondary information. … … 420 432 421 433 422 \section{ EnumerationI/O}434 \section{I/O} 423 435 424 436 As seen in multiple examples, enumerations can be printed and the default property printed is the enumerator's label, which is similar in other programming languages. … … 473 485 \label{f:EnumerationI/O} 474 486 \end{figure} 475 476 487 477 488
Note: See TracChangeset
for help on using the changeset viewer.