Ignore:
Timestamp:
Mar 21, 2024, 9:34:28 PM (2 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6394ac6
Parents:
0139351
Message:

more proofreading for enumerations

File:
1 edited

Legend:

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

    r0139351 r7d9a805b  
    44Naming is also commonly used to represent many other numerical phenomenon, such as days of the week, months of a year, floors of a building (basement), specific times (noon, New Years).
    55Many programming languages capture this important software engineering capability through a mechanism called an \Newterm{enumeration}.
    6 An enumeration is similar to other programming-language types by providing a set of constrained values, but adds the ability to name \emph{all} the values in its set.
     6An enumeration is similar to other programming-language types by providing a set of constrained values, but adds the ability to name \emph{all} the values in the set.
    77Note, all enumeration names must be unique but different names can represent the same value (eight note, quaver), which are synonyms.
    88
     
    1111
    1212Fundamentally, all enumeration systems have an \Newterm{enumeration} type with an associated set of \Newterm{enumerator} names.
    13 An enumeration has three universal attributes, \Newterm{position}, \Newterm{label}, and \Newterm{value}, as shown by this representative enumeration, where position and value can be different.
     13An enumeration has three universal attributes, \Newterm{label}, \Newterm{position}, and \Newterm{value}, as shown by this representative enumeration, where position and value can be different.
    1414\begin{cquote}
    1515\small\sf\setlength{\tabcolsep}{3pt}
     
    1717\it\color{red}enumeration & \multicolumn{7}{c}{\it\color{red}enumerators}       \\
    1818$\downarrow$\hspace*{25pt} & \multicolumn{7}{c}{$\downarrow$}                           \\
    19 @enum@ Weekday \{                               & Monday,       & Tuesday,      & Wednesday,    & Thursday,& Friday,    & Saturday,     & Sunday \}; \\
    20 \it\color{red}position                  & 0                     & 1                     & 2                             & 3                             & 4                     & 5                     & 6                     \\
    21 \it\color{red}label                             & Monday        & Tuesday       & Wednesday             & Thursday              & Friday        & Saturday      & Sunday        \\
    22 \it\color{red}value                             & 0                     & 1                     & 2                             & 3                             & 4                     & 5             & 6
     19@enum@ Weekday \{                               & Mon,  & Tue,  & Wed,  & Thu,  & Fri,  & Sat,  & Sun \};       \\
     20\it\color{red}label                             & Mon   & Tue   & Wed   & Thu   & Fri   & Sat   & Sun           \\
     21\it\color{red}position                  & 0             & 1             & 2             & 3             & 4             & 5             & 6                     \\
     22\it\color{red}value                             & 0             & 1             & 2             & 3             & 4             & 5             & 6
    2323\end{tabular}
    2424\end{cquote}
    25 Here, the \Newterm{enumeration} @Weekday@ defines the ordered \Newterm{enumerator}s @Monday@, @Tuesday@, @Wednesday@, @Thursday@, @Friday@, @Saturday@ and @Sunday@.
    26 By convention, the successor of @Tuesday@ is @Monday@ and the predecessor of @Tuesday@ is @Wednesday@, independent of the associated enumerator constant values.
    27 Because an enumerator is a constant, it cannot appear in a mutable context, \eg @Mon = Sun@ is meaningless, and an enumerator has no address, it is an \Newterm{rvalue}\footnote{
    28 The term rvalue defines an expression that can only appear on the right-hand side of an assignment.}.
     25Here, the \Newterm{enumeration} @Weekday@ defines the ordered \Newterm{enumerator}s @Mon@, @Tue@, @Wed@, @Thu@, @Fri@, @Sat@ and @Sun@.
     26By convention, the successor of @Tue@ is @Mon@ and the predecessor of @Tue@ is @Wed@, independent of the associated enumerator constant values, implying an ordering among the enumerators.
     27As well, the value can be explicitly set so it is different from the position.
     28Because an enumerator is a constant, it cannot appear in a mutable context, \eg @Mon = Sun@ is meaningless, and an enumerator has no address, \ie it is an \Newterm{rvalue}\footnote{
     29The term rvalue defines an expression that can only appear on the right-hand side of an assignment expression.}.
     30
     31On the surface, enumerations seem like a simple type.
     32However, when extended with features available in other language types, enumerations become a complex.
     33
     34The goal of this work is to to extend the simple and unsafe enumeration type in the C programming-language into a sophisticated and safe type in the \CFA programming-language, while maintain backwards compatibility with C.
    2935
    3036\section{Contributions}
     37
Note: See TracChangeset for help on using the changeset viewer.