Changeset 94643698 for doc


Ignore:
Timestamp:
Aug 5, 2024, 9:30:13 AM (3 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
c588acb
Parents:
2514d3d7
Message:

add discussion about partially implemented individual scoping mechanism

File:
1 edited

Legend:

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

    r2514d3d7 r94643698  
    11\chapter{C Enumeration in \CFA}
    22
    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.
    44A C-style enumeration in \CFA is called a \newterm{C Enum}.
    55The 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.
     6The following sections detail all of my new contributions to enumerations in C.
    77
    88
     
    5656rgb = @RGB.@Blue;
    5757\end{cfa}
    58 % feature unimplemented
     58% with feature unimplemented
    5959It 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}).
    6060\begin{cfa}
     
    6565\end{cfa}
    6666As 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
     68A partially implemented extension to enumerator scoping is providing a combination of scoped and unscoped enumerators, using individual denotations, where @'^'@ means unscoped.
     69\begin{cfa}
     70enum E1 { @!@A, @^@B, C };
     71enum E2 @!@ { @!@A, @^@B, C };
     72\end{cfa}
     73For @E1@, @A@ is scoped; @B@ and @C@ are unscoped.
     74For @E2@, @A@ and @C@ are scoped; @B@ is unscoped.
     75Finding a use case is important to justify completing this extension.
    6776
    6877
     
    7685enum Fish { Shark, Salmon, Whale };
    7786
    78 int i = Robin;                                                  $\C{// allow, implicitly converts to 1}$ 
    79 enum Bird @bird = 1;@                                   $\C{// disallow }$ 
    80 enum Bird @bird = Shark;@                               $\C{// disallow }$ 
     87int i = Robin;                                                  $\C{// allow, implicitly converts to 1}$
     88enum Bird @bird = 1;@                                   $\C{// disallow }$
     89enum Bird @bird = Shark;@                               $\C{// disallow }$
    8190\end{cfa}
    8291It is now up to the programmer to insert an explicit cast to force the assignment.
    8392\begin{cfa}
    8493enum Bird bird = @(Bird)@1;
    85 enum Bird bird = @(Bird)@Shark 
     94enum Bird bird = @(Bird)@Shark
    8695\end{cfa}
    8796
Note: See TracChangeset for help on using the changeset viewer.