[18ebc28] | 1 | \chapter{Conclusion} |
---|
[fcf3493] | 2 | \label{c:conclusion} |
---|
[18ebc28] | 3 | |
---|
[7cb14c9] | 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. |
---|
| 5 | Within this goal, the new \CFA enumeration should align with the analogous enumeration features in other languages to match modern programming expectations. |
---|
[a8f44c8] | 6 | Hence, 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. |
---|
[fcf3493] | 7 | |
---|
[7cb14c9] | 8 | Additional safety is provided by strong type-checking of enumeration initialization and assignment, ensuring an enumeration only contains its enumerators. |
---|
| 9 | Overloading 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. |
---|
| 10 | Typed 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. |
---|
| 12 | Generalization and reuse are supported by incorporating the new enumeration type using the \CFA trait system. |
---|
| 13 | Enumeration 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. |
---|
| 14 | Using 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. |
---|
[fcf3493] | 17 | |
---|
[7cb14c9] | 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. |
---|
[fcf3493] | 19 | |
---|
| 20 | |
---|
[7cb14c9] | 21 | \section{Future Work} |
---|
[18ebc28] | 22 | |
---|
[7cb14c9] | 23 | There 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. |
---|
| 25 | When these changes are made, it should be straightforward to update the \CFA enumeration implementation to work with them. |
---|
| 26 | |
---|
| 27 | Currently, some aspects of the enumeration trait system require explicitly including file @enum.hfa@, which easily leads to problems. |
---|
| 28 | It should be possible to have this file included implicitly by updating the \CFA prelude. |
---|
| 29 | |
---|
| 30 | C already provides @const@-style aliasing using the \emph{unnamed} enumerator \see{\VRef{s:TypeName}}, even if the name @enum@ is misleading (@const@ would be better). |
---|
| 31 | Given the existence of this form, it is conceivable to extend it with types other than @int@. |
---|
| 32 | \begin{cfa} |
---|
| 33 | enum { Size = 20u, PI = 3.14159L, Jack = L"John" }; |
---|
| 34 | \end{cfa} |
---|
| 35 | which matches with @const@ aliasing in other programming languages. |
---|
| 36 | Here, the type of the enumerator is the type of the initialization constant, \eg @typeof( 20u )@ for @Size@ implies @unsigned int@. |
---|
| 37 | Auto-initialization is restricted to the case where all constants are @int@, matching with C. |
---|
| 38 | As seen in \VRef{s:EnumeratorTyping}, this feature is just a shorthand for multiple typed-enumeration declarations. |
---|
| 39 | \begin{cfa} |
---|
| 40 | enum( unsigned int ) { Size = 20u }; |
---|
| 41 | enum( long double ) { PI = 3.14159L }; |
---|
| 42 | enum( wchar_t * ) { Jack = L"John" }; |
---|
| 43 | \end{cfa} |
---|
[a8f44c8] | 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. |
---|