Changes in / [9d3a4cc:b0069a30]


Ignore:
Location:
doc/theses/jiada_liang_MMath
Files:
2 edited

Legend:

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

    r9d3a4cc rb0069a30  
    262262enum E2 e2 = C;
    263263posn( e2 );                     $\C[1.75in]{// 0}$
    264 enum E3 e3 = e2;
    265 posn( e2 );                     $\C{// 1 cost}$
     264enum E3 e3 = e2;        $\C{// Assignment with enumeration conversion E2 to E3}$
     265posn( e2 );                     $\C{// 1 }$
    266266void foo( E3 e );
    267 foo( e2 );
    268 posn( (E3)e2 );         $\C{// 1 cost}$
    269 E3 e31 = B;
    270 posn( e31 );            $\C{// 0 cost}\CRT$
     267foo( e2 );                      $\C{// Type compatible with enumeration conversion E2 to E3}$
     268posn( (E3)e2 );         $\C{// Explicit cast with enumeration conversion E2 to E3}$
     269E3 e31 = B;                     $\C{// No conversion: E3.B}$
     270posn( e31 );            $\C{// 0 }\CRT$
    271271\end{cfa}
    272272The last expression is unambiguous.
    273 While both @E2.B@ and @E3.B@ are valid candidates, @E2.B@ has an associated safe cost, so \CFA selects the zero cost candidate.
     273While both @E2.B@ and @E3.B@ are valid candidates, @E2.B@ has an associated safe cost and @E3.B@ need not a conversion (@zero@ cost). \CFA selects the lowest cost candidate @E3.B@.
    274274
    275275For the given function prototypes, the following calls are valid.
     
    455455float ?[?]( float * arr, E2 index ) { return arr[ value( index ) ]; }
    456456\end{cfa}
    457 When an enumeration type is being used as an array dimension, \CFA adds the enumeration type to the initializer's context.
    458 As a result, @H2@'s array destinators @A@, @B@ and @C@ are resolved unambiguously to type @E2@.
    459 (@H1@'s destinators are also resolved unambiguously to @E1@ because @E2@ has a @value@ cost.)
    460 
     457While enumerator labels @A@, @B@ and @C@ are being defined twice in different enumerations, they are 
     458unambiguous within the context. Designators in H1 are unambiguous becasue @E2@ has a @value@ cost to @int@, which
     459is more expensive than @safe@ cost from C-Enum @E1@ to @int@. On the hand, designators in @H2@ are resolved as @E2@ because
     460when a \CFA enumeration type is being used as an array dimension, \CFA adds the enumeration type to the initializer's resolution context.
    461461
    462462\section{I/O}
    463 
    464 As seen in multiple examples, enumerations can be printed and the default property printed is the enumerator's label, which is similar in other programming languages.
     463As seen in multiple examples, \CFA enumerations can be printed and the default property printed is the enumerator's label, which is similar in other programming languages.
    465464However, very few programming languages provide a mechanism to read in enumerator values.
    466465Even the @boolean@ type in many languages does not have a mechanism for input using the enumerators @true@ or @false@.
  • doc/theses/jiada_liang_MMath/trait.tex

    r9d3a4cc rb0069a30  
    164164\end{cfa}
    165165Function @fromInstance@ projects a @Bounded@ member to a number and @fromInt@ is the inverse.
    166 Function @pred@ takes an enumerator and returns the previous enumerator, if there is one, in sequential order, and @succ@ returns the next enumerator.
     166Function @pred@ and @succ@ are advancement functions:
     167@pred@ takes an enumerator and returns the previous enumerator, if there is one, in sequential order, and @succ@ returns the next enumerator.
    167168\begin{cfa}
    168169sout | fromInstance( Wed ) | fromInt( 2 ) | succ( Wed ) | pred( Wed );
Note: See TracChangeset for help on using the changeset viewer.