Changeset 94643698
- Timestamp:
- Aug 5, 2024, 9:30:13 AM (4 months ago)
- Branches:
- master
- Children:
- c588acb
- Parents:
- 2514d3d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/CEnum.tex
r2514d3d7 r94643698 1 1 \chapter{C Enumeration in \CFA} 2 2 3 \CFA supports legacy C enumeration using the same syntax for backwards compatibility. 3 \CFA supports legacy C enumeration using the same syntax for backwards compatibility. 4 4 A C-style enumeration in \CFA is called a \newterm{C Enum}. 5 5 The semantics of the C Enum is mostly consistent with C with some restrictions. 6 The following sections detail all of my new contributions to C Enums.6 The following sections detail all of my new contributions to enumerations in C. 7 7 8 8 … … 56 56 rgb = @RGB.@Blue; 57 57 \end{cfa} 58 % feature unimplemented58 % with feature unimplemented 59 59 It is possible to toggle back to unscoped using the \CFA @with@ auto-qualification clause/statement (see also \CC \lstinline[language=c++]{using enum} in Section~\ref{s:C++RelatedWork}). 60 60 \begin{cfa} … … 65 65 \end{cfa} 66 66 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 this localized scenario. 67 68 A partially implemented extension to enumerator scoping is providing a combination of scoped and unscoped enumerators, using individual denotations, where @'^'@ means unscoped. 69 \begin{cfa} 70 enum E1 { @!@A, @^@B, C }; 71 enum E2 @!@ { @!@A, @^@B, C }; 72 \end{cfa} 73 For @E1@, @A@ is scoped; @B@ and @C@ are unscoped. 74 For @E2@, @A@ and @C@ are scoped; @B@ is unscoped. 75 Finding a use case is important to justify completing this extension. 67 76 68 77 … … 76 85 enum Fish { Shark, Salmon, Whale }; 77 86 78 int i = Robin; $\C{// allow, implicitly converts to 1}$ 79 enum Bird @bird = 1;@ $\C{// disallow }$ 80 enum Bird @bird = Shark;@ $\C{// disallow }$ 87 int i = Robin; $\C{// allow, implicitly converts to 1}$ 88 enum Bird @bird = 1;@ $\C{// disallow }$ 89 enum Bird @bird = Shark;@ $\C{// disallow }$ 81 90 \end{cfa} 82 91 It is now up to the programmer to insert an explicit cast to force the assignment. 83 92 \begin{cfa} 84 93 enum Bird bird = @(Bird)@1; 85 enum Bird bird = @(Bird)@Shark 94 enum Bird bird = @(Bird)@Shark 86 95 \end{cfa} 87 96
Note: See TracChangeset
for help on using the changeset viewer.