Ignore:
Timestamp:
Aug 8, 2024, 11:19:51 PM (12 hours ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
f125e96
Parents:
7568e5c
Message:

rephrase enum initialization

Location:
doc/theses/jiada_liang_MMath
Files:
2 edited

Legend:

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

    r7568e5c racab1bd  
    179179
    180180\section{Auto Initialization}
    181 \CFA implements auto-initialization for both C enumerations and \CFA enumerations. For the first category, the semantics is consistent with C:
    182 % A partially implemented feature is auto-initialization, which works for the C integral type with constant expressions.
    183 \begin{cfa}
    184 enum Week { Mon, Tue, Wed, Thu@ = 10@, Fri, Sat, Sun }; // 0-2, 10-13
    185 \end{cfa}
    186 % The complexity of the constant expression depends on the level of computation the compiler implements, \eg \CC \lstinline[language={[GNU]C++}]{constexpr} provides complex compile-time computation across multiple types, which blurs the compilation/runtime boundary.
    187 
    188 % If \CFA had powerful compilation expression evaluation, auto initialization would be implemented as follows.
     181\CFA extends C's auto-initialization scheme to \CFA enumeration. For an enumeration type with base type T, the initialization scheme is the following:
     182\begin{enumerate}
     183\item the first enumerator is initialized with @T@'s @zero_t@.
     184\item Every other enumerator is initialized with its previous enumerator's value "+1", where "+1" is defined in terms of overloaded operator @?+?(T, one_t)@.
     185\end{enumerate}
    189186
    190187\begin{cfa}
     
    194191enum(S) E { A, B, C, D };
    195192\end{cfa}
    196 For \CFA enumeration, the semantics is the following:
    197 \begin{enumerate}
    198 \item the first enumerator, @A@, is initialized with @T@'s @zero_t@.
    199 \item otherwise, the next enumerator is initialized with the previous enumerator's value using the operator @?+?(T, one_t)@, which can be overloaded for any type @T@.
    200 \end{enumerate}
    201 
    202 % Unfortunately, constant expressions in C are not powerful and \CFA is only a transpiler, relying on generated C code to perform the detail work.
    203 % It is currently beyond the scope of the \CFA project to implement a complex runtime interpreter in the transpiler to evaluate complex expressions across multiple builtin and user-defined type.
    204 % Nevertheless, the necessary language concepts exist to support this feature.
    205 
    206193
    207194\section{Subset}
  • doc/theses/jiada_liang_MMath/conclusion.tex

    r7568e5c racab1bd  
    3131It should be possible to have this file included implicitly by updating the \CFA prelude.
    3232\item
    33 There are multiple \CFA features being developed i parallel with enumerations.
     33There are multiple \CFA features being developed in parallel with enumerations.
    3434Two closely related features are iterator and namespace.
    3535Enumerations may have to be modified to dovetail with these features.
     
    5050enum( wchar_t * ) { Jack = L"John" };
    5151\end{cfa}
    52 There are several new features have been proposed or are developing in parallel with enumerations.
    53 Two closely related features are iterator and namespace.
    54 
    55 Enumerating features, and range loops in particular, are currently implemented as loops unique to \CFA enumeration and do not align with the
    56 general iterator pattern. They can be adapted to the iterator interface when it comes to maturity.
    57 
    58 Currently, \CFA implements a namespace feature for enumerated types only. There is recently a proposal by Andrew to
    59 generalize the concept of namespace to other types. The enumeration scope will be revisited to follow the same semantics
    60 as other types. Also to improve the granularity of scope control, we propose the following extension:
     52\item
     53Currently enumeration scoping is all or nothing. In some cases, it might be useful to
     54increase the scoping granularity to individual enumerators.
    6155\begin{cfa}
    6256enum E1 { @!@A, @^@B, C };
Note: See TracChangeset for help on using the changeset viewer.