source: doc/theses/jiada_liang_MMath/intro.tex @ 022bce0

Last change on this file since 022bce0 was 022bce0, checked in by Peter A. Buhr <pabuhr@…>, 5 months ago

more proofreading on enumeration thesis

  • Property mode set to 100644
File size: 2.6 KB
Line 
1\chapter{Introduction}
2
3Naming values is a common practice in mathematics and engineering, \eg $\pi$, $\tau$ (2$\pi$), $\phi$ (golden ratio), MHz (1E6), etc.
4Naming 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).
5Many programming languages capture this important software engineering capability through a mechanism called an \Newterm{enumeration}.
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 its set.
7Note, all enumeration names must be unique but different names can represent the same value (eight note, quaver), which are synonyms.
8
9Specifically, an enumerated type restricts its values to a fixed set of named constants.
10While all types are restricted to a fixed set of values because of the underlying von Neumann architecture, and hence, to a corresponding set of constants, \eg @3@, @3.5@, @3.5+2.1i@, @'c'@, @"abc"@, etc., these values are not named, other than the programming-language supplied constant names.
11
12Fundamentally, all enumeration systems have an \Newterm{enumeration} type with an associated set of \Newterm{enumerator} names.
13An 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.
14\begin{cquote}
15\small\sf\setlength{\tabcolsep}{3pt}
16\begin{tabular}{rccccccccccc}
17\it\color{red}enumeration & \multicolumn{7}{c}{\it\color{red}enumerators}       \\
18$\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
23\end{tabular}
24\end{cquote}
25Here, the \Newterm{enumeration} @Weekday@ defines the ordered \Newterm{enumerator}s @Monday@, @Tuesday@, @Wednesday@, @Thursday@, @Friday@, @Saturday@ and @Sunday@.
26By convention, the successor of @Tuesday@ is @Monday@ and the predecessor of @Tuesday@ is @Wednesday@, independent of the associated enumerator constant values.
27Because 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{
28The term rvalue defines an expression that can only appear on the right-hand side of an assignment.}.
29
30\section{Contributions}
Note: See TracBrowser for help on using the repository browser.