Ignore:
Timestamp:
Jul 15, 2024, 1:57:15 PM (11 days ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
1dd5fd1, 68ea8d2
Parents:
dc1c430
Message:

grammar fixed by a dsoftware

File:
1 edited

Legend:

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

    rdc1c430 r09dd830  
    130130\end{cfa}
    131131
    132 \CFA does not define attributes functions for C style enumeration. But it is possilbe for users to explicitly implement
     132\CFA does not define attribute functions for C style enumeration. But it is possilbe for users to explicitly implement
    133133enumeration traits for C enum and any other types.
    134134
     
    147147\end{cfa}
    148148
    149 A type that implement trait @CfaEnum@, \ie, a type has no @value@, is called an opaque enum.
     149A type that implements trait @CfaEnum@, \ie, a type has no @value@, is called an opaque enum.
    150150
    151151% \section{Enumerator Opaque Type}
     
    164164};
    165165\end{cfa}
    166 The function @first()@ and @last()@ of enumertated type E return the first and the last enumerator declared in E, respectively. \eg:
     166The function @first()@ and @last()@ of enumerated type E return the first and the last enumerator declared in E, respectively. \eg:
    167167\begin{cfa}
    168168Workday day = first();                                  $\C{// Mon}$
     
    292292
    293293Enumeration @Name2@ inherits all the enumerators and their values from enumeration @Names@ by containment, and a @Names@ enumeration is a subtype of enumeration @Name2@.
    294 Note, enumerators must be unique in inheritance but enumerator values may be repeated.
     294Note, that enumerators must be unique in inheritance but enumerator values may be repeated.
    295295
    296296% The enumeration type for the inheriting type must be the same as the inherited type;
     
    301301Names $\(\subset\)$ Names2 $\(\subset\)$ Names3 $\C{// enum type of Names}$
    302302\end{cfa}
    303 A subtype can be casted to its super type, assigned to a super type variable, or be used as a function argument that expects the super type.
     303A subtype can be cast to its supertype, assigned to a supertype variable, or be used as a function argument that expects the supertype.
    304304\begin{cfa}
    305305Names fred = Name.Fred;
     
    332332In most programming languages, an enumerator is implicitly converted to its value (like a typed macro substitution).
    333333However, enumerator synonyms and typed enumerations make this implicit conversion to value incorrect in some contexts.
    334 In these contexts, a programmer's initition assumes an implicit conversion to postion.
    335 
    336 For example, an intuitive use of enumerations is with the \CFA @switch@/@choose@ statement, where @choose@ performs an implict @break@ rather than a fall-through at the end of a @case@ clause.
     334In these contexts, a programmer's initition assumes an implicit conversion to position.
     335
     336For example, an intuitive use of enumerations is with the \CFA @switch@/@choose@ statement, where @choose@ performs an implicit @break@ rather than a fall-through at the end of a @case@ clause.
    337337\begin{cquote}
    338338\begin{cfa}
     
    367367enum Count { First, Second, Third @= First@, Fourth };
    368368\end{cfa}
    369 which make @Third == First@ and @Fourth == Second@, causing a compilation error because of duplicase @case@ clauses.
     369which make @Third == First@ and @Fourth == Second@, causing a compilation error because of duplicate @case@ clauses.
    370370To better match with programmer intuition, \CFA toggles between value and position semantics depending on the language context.
    371 For conditional clauses and switch statments, \CFA uses the robust position implementation.
     371For conditional clauses and switch statements, \CFA uses the robust position implementation.
    372372\begin{cfa}
    373373choose( @position@( e ) ) {
     
    392392for (c: -~=Alphabet ) { sout | c; }
    393393\end{cfa}
    394 The @range loop@ for enumeration is a syntax sugar that looping over all enumeerators and assign each enumeration to a variable in every iteration.
    395 The loop control of range loop consists of two parts: a variable declaration and a @range expression@, with type of the variable
     394The @range loop@ for enumeration is a syntax sugar that loops over all enumerators and assigns each enumeration to a variable in every iteration.
     395The loop control of the range loop consists of two parts: a variable declaration and a @range expression@, with the type of the variable
    396396can be inferred from the range expression.
    397397
    398398The range expression is an enumeration type, optionally prefixed by @+~=@ or @-~=@. Without a prefix, or prefixed with @+~=@, the control
    399 loop over all enumerator from the first to the last. With a @-~=@ prefix, the control loops backwards.
     399loop over all enumerators from the first to the last. With a @-~=@ prefix, the control loops backward.
    400400
    401401On a side note, the loop syntax
     
    405405does not work. When d == last(), the loop control will still attempt to assign succ(d) to d, which causes an @enumBound@ exception.
    406406
    407 \CFA reduces conditionals to its "if case" if the predicate not equal to ( @!=@ ) zero, and the "else case" otherwises.
     407\CFA reduces conditionals to its "if case" if the predicate is not equal to ( @!=@ ) zero, and the "else case" otherwise.
    408408Overloading the @!=@ operator with an enumeration type against the zero defines a conceptual conversion from
    409409enum to boolean, which can be used as predicates.
     
    416416\end{cfa}
    417417
    418 Indicentally, \CFA does not define boolean conversion for enumeration. If no
     418Incidentally, \CFA does not define boolean conversion for enumeration. If no
    419419@?!=?(ErrorCode, zero_t)@
    420420overloading defined,
    421 \CFA looks for the boolean conversion in terms of its value, and gives an compiler error if no such conversion is available.
     421\CFA looks for the boolean conversion in terms of its value and gives a compiler error if no such conversion is available.
    422422
    423423\begin{cfa}
     
    431431\end{cfa}
    432432
    433 As an alternatively, users can define the boolean conversion for CfaEnum:
     433As an alternative, users can define the boolean conversion for CfaEnum:
    434434
    435435\begin{cfa}
     
    442442
    443443\section{Enumerated Arrays}
    444 Enumerated array use an \CFA array as their index.
     444Enumerated arrays use an \CFA array as their index.
    445445\begin{cfa}
    446446enum() Colour {
     
    457457\VRef[Figure]{f:PlanetExample} shows an archetypal enumeration example illustrating most of the \CFA enumeration features.
    458458@Planet@ is an enumeration of type @MR@.
    459 Each of the planet enumerators is initialized to a specific mass/radius, @MR@, value.
     459Each planet enumerator is initialized to a specific mass/radius, @MR@, value.
    460460The unnamed enumeration provides the gravitational-constant enumerator @G@.
    461461Function @surfaceGravity@ uses the @with@ clause to remove @p@ qualification from fields @mass@ and @radius@.
    462462The program main uses the pseudo function @countof@ to obtain the number of enumerators in @Planet@, and safely converts the random value into a @Planet@ enumerator using @fromInt@.
    463463The resulting random orbital-body is used in a @choose@ statement.
    464 The enumerators in the @case@ clause use enumerator position for testing.
     464The enumerators in the @case@ clause use the enumerator position for testing.
    465465The prints use @label@ to print an enumerator's name.
    466466Finally, a loop enumerates through the planets computing the weight on each planet for a given earth mass.
Note: See TracChangeset for help on using the changeset viewer.