Changeset c4aca65 for doc/theses


Ignore:
Timestamp:
Aug 8, 2024, 5:25:41 PM (4 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
11cced6
Parents:
ab11ab1
Message:

Move partial scope to future work

Location:
doc/theses/jiada_liang_MMath
Files:
2 edited

Legend:

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

    rab11ab1 rc4aca65  
    11\chapter{C Enumeration in \texorpdfstring{\CFA}{Cforall}}
    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 backward 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.
     
    1515enum E2 { @Fourth@, @Third@, @Second@, @First@ }; $\C{// same enumerator names}$
    1616\end{cfa}
    17 There is no mechanism in C to resolve these naming conflicts other than renaming one of the duplicates, which may be impossible if the conflict comes from system include files.
     17There is no mechanism in C to resolve these naming conflicts other than renaming one of the duplicates, which may be impossible if the conflict comes from system-include files.
    1818
    1919The \CFA type-system allows extensive overloading, including enumerators.
    2020Hence, most ambiguities among C enumerators are implicitly resolved by the \CFA type system, possibly without any programmer knowledge of the conflict.
    21 In addition, C Enum qualification is added, exactly like aggregate field-qualification, to disambiguate.
     21In addition, C Enum qualification is added, exactly like aggregate field qualification, to disambiguate.
    2222\VRef[Figure]{f:EnumeratorVisibility} shows how resolution, qualification, and casting are used to disambiguate situations for enumerations @E1@ and @E2@.
    2323
     
    6666As in Section~\ref{s:CVisibility}, 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.
    6767
    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.
    76 
    7768
    7869\section{Type Safety}
     
    8071As in Section~\ref{s:Usage}, C's implicit bidirectional conversion between enumeration and integral type raises a safety concern.
    8172In \CFA, the conversion is changed to unidirectional: an enumeration can be implicitly converted into an integral type, with an associated @safe@ conversion cost.
    82 But an integral type cannot be implicitly converted into a C enumeration because the conversion cost is set to @infinity@.
     73However, an integral type cannot be implicitly converted into a C enumeration because the conversion cost is set to @infinity@.
    8374\begin{cfa}
    8475enum Bird { Penguin, Robin, Eagle };
  • doc/theses/jiada_liang_MMath/conclusion.tex

    rab11ab1 rc4aca65  
    22\label{c:conclusion}
    33
    4 The goal of this work is to extend the simple and unsafe enumeration type in the C programming-language into a complex and safe enumeration type in the \CFA programming-language, while maintaining backwards compatibility with C.
     4The goal of this work is to extend the simple and unsafe enumeration type in the C programming language into a complex and safe enumeration type in the \CFA programming language while maintaining backward compatibility with C.
    55Within this goal, the new \CFA enumeration should align with the analogous enumeration features in other languages to match modern programming expectations.
    66Hence, the \CFA enumeration features are borrowed from a number of programming languages, but engineered to work and play with \CFA's type system and feature set.
    77
    8 Additional safety is provided by strong type-checking of enumeration initialization and assignment, ensuring an enumeration only contains its enumerators.
     8Strong type-checking of enumeration initialization and assignment provides additional safety, ensuring an enumeration only contains its enumerators.
    99Overloading and scoping of enumerators significantly reduces the naming problem, providing a better software-engineering environment, with fewer name clashes and the ability to disambiguate those that cannot be implicitly resolved.
    1010Typed enumerations solve the data-harmonization problem increasing safety through better software engineering.
    11 As well, integrating enumerations with existing control structures provides a consistent upgrade for programmers, and a succinct and secure mechanism to enumerate with the new loop-range feature.
     11Moreover, integrating enumerations with existing control structures provides a consistent upgrade for programmers and a succinct and secure mechanism to enumerate with the new loop-range feature.
    1212Generalization and reuse are supported by incorporating the new enumeration type using the \CFA trait system.
    1313Enumeration traits define the meaning of an enumeration, allowing functions to be written that work on any enumeration, such as the reading and printing an enumeration.
    1414Using advanced duck typing, existing C enumerations can be extended so they work with all of the enumeration features, providing for legacy C code to be moved forward into the modern \CFA programming domain.
    15 Finally, I expanded the \CFA project's test-suite with multiple enumeration features tests, with respect to implicit conversions, control structures, inheritance, interaction with the polymorphic types, and the features built on top of enumeration traits.
    16 These tests ensure future \CFA work does not accidently break the new enumeration system.
     15Finally, I expanded the \CFA project's test suite with multiple enumeration features tests with respect to implicit conversions, control structures, inheritance, interaction with the polymorphic types, and the features built on top of enumeration traits.
     16These tests ensure future \CFA work does not accidentally break the new enumeration system.
    1717
    18 The conclusion is that the new \CFA enumeration mechanisms achieves the initial goals, providing C programmers with an intuitive enumeration mechanism for handling modern programming requirements.
     18The conclusion is that the new \CFA enumeration mechanisms achieve the initial goals, providing C programmers with an intuitive enumeration mechanism for handling modern programming requirements.
    1919
    2020
     
    2222
    2323There are still corner cases being found in the current \CFA enumeration implementation.
    24 Fixing some of these corner cases, requires changes to the \CFA resolver or extensions to \CFA, like compile-time constant-expression evaluation.
     24Fixing some of these corner cases requires changes to the \CFA resolver or extensions to \CFA, like compile-time constant-expression evaluation.
    2525When these changes are made, it should be straightforward to update the \CFA enumeration implementation to work with them.
    2626
    27 Currently, some aspects of the enumeration trait system require explicitly including file @enum.hfa@, which easily leads to problems.
     27Currently, some aspects of the enumeration trait system require explicitly including the file @enum.hfa@, which can lead to problems.
    2828It should be possible to have this file included implicitly by updating the \CFA prelude.
    2929
     
    4242enum( wchar_t * ) { Jack = L"John" };
    4343\end{cfa}
    44 The enumerating feature was developed in parallel with the \CFA iterator. In the forseeable future when iterator come to matuity, \CFA enumeration can adapt iterator-related traits and
    45 be rewritten with iterator.
     44There are several new features have been proposed or are developing in parallel with enumerations.
     45Two closely related features are iterator and namespace.
     46
     47Enumerating features, and range loops in particular, are currently implemented as loops unique to \CFA enumeration and do not align with the
     48general iterator pattern. They can be adapted to the iterator interface when it comes to maturity.
     49
     50Currently, \CFA implements a namespace feature for enumerated types only. There is recently a proposal by Andrew to
     51generalize the concept of namespace to other types. The enumeration scope will be revisited to follow the semantics
     52with other types. Also to improve the granularity of scope control, we propose the following extension:
     53\begin{cfa}
     54enum E1 { @!@A, @^@B, C };
     55enum E2 @!@ { @!@A, @^@B, C };
     56\end{cfa}
     57which provides a combination of scoped and unscoped enumerators.
     58For @E1@, @A@ is scoped; @B@ and @C@ are unscoped.
     59For @E2@, @A@, and @C@ are scoped; @B@ is unscoped.
     60Finding a use case is important to justify completing this extension.
Note: See TracChangeset for help on using the changeset viewer.