Changeset 46651fb for doc/theses/jiada_liang_MMath
- Timestamp:
- Jul 24, 2024, 11:21:10 AM (5 months ago)
- Branches:
- master
- Children:
- 10a99d87
- Parents:
- ead3858
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/intro.tex
read3858 r46651fb 4 4 Constants 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. 5 5 (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 .6 A constant's symbolic name is dictated by language syntax related to types, \eg @5.@ (double), @5.0f@ (float), @5l@ (long double). 7 7 In general, the representation of a constant's value is \newterm{opaque}, so the internal representation can be chosen arbitrarily. 8 8 In theory, there are an infinite set of constant names per type representing an infinite set of values. … … 13 13 14 14 Many 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.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. 16 16 Thereafter, changing the aliasing of the new constant to another constant automatically distributes the rebinding, preventing errors. 17 17 % and only equality operations are available, \eg @O_RDONLY@, @O_WRONLY@, @O_CREAT@, @O_TRUNC@, @O_APPEND@. … … 67 67 \label{s:Terminology} 68 68 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 A s well, an enumerated type can have three fundamental properties, \newterm{label}, \newterm{order}, and \newterm{value}.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 derivations}. 70 An enumerated type can have three fundamental properties, \newterm{label} (name), \newterm{order} (position), and \newterm{value} (payload). 71 71 \begin{cquote} 72 72 \sf\setlength{\tabcolsep}{3pt} … … 111 111 \end{cfa} 112 112 The 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. 113 It is possible to compare aliases, if the constants allow it, \eg @Size < Pi@, whereas @Pi < Name@ might be disallowed depending on the language. 115 114 116 115 Aliasing 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. … … 133 132 Any reordering of the enumerators requires manual renumbering. 134 133 \begin{cfa} 135 const Sun = 1, Mon = 2, Tue = 3, Wed = 4, Thu = 5, Fri = 6, Sat = 7;134 const @Sun = 1@, Mon = 2, Tue = 3, Wed = 4, Thu = 5, Fri = 6, Sat = 7; 136 135 \end{cfa} 137 136 For these reasons, aliasing is sometimes called an enumeration.
Note: See TracChangeset
for help on using the changeset viewer.