Ignore:
Timestamp:
Aug 7, 2024, 7:07:24 PM (4 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
b0069a30
Parents:
4e09af2
Message:

Small thesis unpdate

Location:
doc/theses/jiada_liang_MMath
Files:
2 edited

Legend:

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

    r4e09af2 r92a0ee8  
    261261enum E2 e2 = C;
    262262posn( e2 );                     $\C[1.75in]{// 0}$
    263 enum E3 e3 = e2;
    264 posn( e2 );                     $\C{// 1 cost}$
     263enum E3 e3 = e2;        $\C{// Assignment with enumeration conversion E2 to E3}$
     264posn( e2 );                     $\C{// 1 }$
    265265void foo( E3 e );
    266 foo( e2 );
    267 posn( (E3)e2 );         $\C{// 1 cost}$
    268 E3 e31 = B;
    269 posn( e31 );            $\C{// 0 cost}\CRT$
     266foo( e2 );                      $\C{// Type compatible with enumeration conversion E2 to E3}$
     267posn( (E3)e2 );         $\C{// Explicit cast with enumeration conversion E2 to E3}$
     268E3 e31 = B;                     $\C{// No conversion: E3.B}$
     269posn( e31 );            $\C{// 0 }\CRT$
    270270\end{cfa}
    271271The last expression is unambiguous.
    272 While both @E2.B@ and @E3.B@ are valid candidates, @E2.B@ has an associated safe cost, so \CFA selects the zero cost candidate.
     272While 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@.
    273273
    274274For the given function prototypes, the following calls are valid.
     
    454454float ?[?]( float * arr, E2 index ) { return arr[ value( index ) ]; }
    455455\end{cfa}
    456 When an enumeration type is being used as an array dimension, \CFA adds the enumeration type to the initializer's context.
    457 As a result, @H2@'s array destinators @A@, @B@ and @C@ are resolved unambiguously to type @E2@.
    458 (@H1@'s destinators are also resolved unambiguously to @E1@ because @E2@ has a @value@ cost.)
    459 
     456While enumerator labels @A@, @B@ and @C@ are being defined twice in different enumerations, they are 
     457unambiguous within the context. Designators in H1 are unambiguous becasue @E2@ has a @value@ cost to @int@, which
     458is more expensive than @safe@ cost from C-Enum @E1@ to @int@. On the hand, designators in @H2@ are resolved as @E2@ because
     459when a \CFA enumeration type is being used as an array dimension, \CFA adds the enumeration type to the initializer's resolution context.
    460460
    461461\section{I/O}
    462 
    463 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.
     462As 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.
    464463However, very few programming languages provide a mechanism to read in enumerator values.
    465464Even 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

    r4e09af2 r92a0ee8  
    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.