Changeset 31f4837 for doc/theses/jiada_liang_MMath/CFAenum.tex
- Timestamp:
- May 13, 2024, 10:26:59 AM (6 months ago)
- Branches:
- master
- Children:
- e6f1a4b
- Parents:
- acb33f15 (diff), ca4f2b2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/CFAenum.tex
racb33f15 r31f4837 11 11 12 12 C already provides @const@-style aliasing using the unnamed enumerator \see{\VRef{s:TypeName}}, even if the name @enum@ is misleading (@const@ would be better). 13 Given the existence of this form, it is straightforward to extend it with types other than integers.13 Given the existence of this form, it is straightforward to extend it with types other than @int@. 14 14 \begin{cfa} 15 15 enum E { Size = 20u, PI = 3.14159L, Jack = L"John" }; … … 21 21 22 22 23 \section{Enumerator Unscoping}24 \label{s:Enumerator Unscoping}25 26 In C, unscoped enumerators present sa \newterm{naming problem} when multiple enumeration types appear in the same scope with duplicate enumerator names.23 \section{Enumerator Visibility} 24 \label{s:EnumeratorVisibility} 25 26 In C, unscoped enumerators present a \newterm{naming problem} when multiple enumeration types appear in the same scope with duplicate enumerator names. 27 27 There is no mechanism in C to resolve these naming conflicts other than renaming one of the duplicates, which may be impossible. 28 28 … … 33 33 enum E1 { First, Second, Third, Fourth }; 34 34 enum E2 { @Fourth@, @Third@, @Second@, @First@ }; $\C{// same enumerator names}$ 35 E1 p() { return Third; } $\C{// correctly resolved duplicate names}$35 E1 p() { return Third; } $\C{// return}$ 36 36 E2 p() { return Fourth; } 37 37 void foo() { … … 54 54 enum RGB @!@ { Red, Green, Blue }; 55 55 \end{cfa} 56 Now the enumerators \emph{must} be qualified with the associated enumeration .56 Now the enumerators \emph{must} be qualified with the associated enumeration type. 57 57 \begin{cfa} 58 58 Week week = @Week.@Mon; … … 68 68 } 69 69 \end{cfa} 70 As in Section~\ref{s:Enumerator Unscoping}, opening multiple scoped enumerations in a @with@ can result in duplicate enumeration names, but \CFA implicit type resolution and explicit qualification/casting handlesambiguities.70 As in Section~\ref{s:EnumeratorVisibility}, opening multiple scoped enumerations in a @with@ can result in duplicate enumeration names, but \CFA implicit type resolution and explicit qualification/casting handle ambiguities. 71 71 72 72 \section{Enumeration Trait} … … 344 344 \end{cfa} 345 345 which make @Third == First@ and @Fourth == Second@, causing a compilation error because of duplicase @case@ clauses. 346 To better match with programmer intuition, \CFA toggles between value and position semantics dep neding on the language context.346 To better match with programmer intuition, \CFA toggles between value and position semantics depending on the language context. 347 347 For conditional clauses and switch statments, \CFA uses the robust position implementation. 348 348 \begin{cfa}
Note: See TracChangeset
for help on using the changeset viewer.