Changeset e561551 for doc/theses/jiada_liang_MMath/implementation.tex
- Timestamp:
- Jul 24, 2024, 1:49:16 PM (4 months ago)
- Branches:
- master
- Children:
- a03ed29
- Parents:
- 18d7aaf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/implementation.tex
r18d7aaf re561551 1 1 \chapter{Enumeration Implementation} 2 3 4 \section{Enumeration Variable}5 6 Although \CFA enumeration captures three different attributes, an enumeration instance does not store all this information.7 The @sizeof@ a \CFA enumeration instance is always 4 bytes, the same size as a C enumeration instance (@sizeof( int )@).8 It comes from the fact that:9 \begin{enumerate}10 \item11 a \CFA enumeration is always statically typed;12 \item13 it is always resolved as one of its attributes regarding real usage.14 \end{enumerate}15 When creating an enumeration instance @colour@ and assigning it with the enumerator @Color.Green@, the compiler allocates an integer variable and stores the position 1.16 The invocations of $positions()$, $value()$, and $label()$ turn into calls to special functions defined in the prelude:17 \begin{cfa}18 position( green );19 >>> position( Colour, 1 ) -> int20 value( green );21 >>> value( Colour, 1 ) -> T22 label( green );23 >>> label( Colour, 1) -> char *24 \end{cfa}25 @T@ represents the type declared in the \CFA enumeration defined and @char *@ in the example.26 These generated functions are $Companion Functions$, they take an $companion$ object and the position as parameters.27 28 2 29 3 \section{Enumeration Data}
Note: See TracChangeset
for help on using the changeset viewer.