Ignore:
Timestamp:
Jul 24, 2024, 11:21:10 AM (5 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
10a99d87
Parents:
ead3858
Message:

small wording change to enumeration introduction

File:
1 edited

Legend:

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

    read3858 r46651fb  
    44Constants can be overloaded among types, \eg @0@ is a null pointer for all pointer types, and the value zero for integer and floating-point types.
    55(In \CFA, the constants @0@ and @1@ can be overloaded for any type.)
    6 A constant's symbolic name is dictated by language syntax related to types.
     6A constant's symbolic name is dictated by language syntax related to types, \eg @5.@ (double), @5.0f@ (float), @5l@ (long double).
    77In general, the representation of a constant's value is \newterm{opaque}, so the internal representation can be chosen arbitrarily.
    88In theory, there are an infinite set of constant names per type representing an infinite set of values.
     
    1313
    1414Many programming languages capture this important software-engineering capability through a mechanism called \newterm{constant} or \newterm{literal} naming, where a new constant is aliased to an existing constant.
    15 Its purpose is for readability, replacing a constant name that directly represents a value with a name that is more symbolic and meaningful in the context of the program.
     15Its purpose is for readability: replacing a constant name that directly represents a value with a name that is more symbolic and meaningful in the context of the program.
    1616Thereafter, changing the aliasing of the new constant to another constant automatically distributes the rebinding, preventing errors.
    1717% and only equality operations are available, \eg @O_RDONLY@, @O_WRONLY@, @O_CREAT@, @O_TRUNC@, @O_APPEND@.
     
    6767\label{s:Terminology}
    6868
    69 The term \newterm{enumeration} defines a type with a set of new constants, and the term \newterm{enumerator} represents an arbitrary alias name \see{\VRef{s:CEnumeration} for the name derivation}.
    70 As well, an enumerated type can have three fundamental properties, \newterm{label}, \newterm{order}, and \newterm{value}.
     69The term \newterm{enumeration} defines a type with a set of new constants, and the term \newterm{enumerator} represents an arbitrary alias name \see{\VRef{s:CEnumeration} for the name derivations}.
     70An enumerated type can have three fundamental properties, \newterm{label} (name), \newterm{order} (position), and \newterm{value} (payload).
    7171\begin{cquote}
    7272\sf\setlength{\tabcolsep}{3pt}
     
    111111\end{cfa}
    112112The alias name is logically replaced in the program text by its matching constant.
    113 It is possible to compare aliases, if the constants allow it, \eg @Size < Pi@;
    114 whereas \eg @Pi < Name@ might be disallowed depending on the language.
     113It is possible to compare aliases, if the constants allow it, \eg @Size < Pi@, whereas @Pi < Name@ might be disallowed depending on the language.
    115114
    116115Aliasing is not macro substitution, \eg @#define Size 20@, where a name is replaced by its value \emph{before} compilation, so the name is invisible to the programming language.
     
    133132Any reordering of the enumerators requires manual renumbering.
    134133\begin{cfa}
    135 const Sun = 1, Mon = 2, Tue = 3, Wed = 4, Thu = 5, Fri = 6, Sat = 7;
     134const @Sun = 1@, Mon = 2, Tue = 3, Wed = 4, Thu = 5, Fri = 6, Sat = 7;
    136135\end{cfa}
    137136For these reasons, aliasing is sometimes called an enumeration.
Note: See TracChangeset for help on using the changeset viewer.