Changeset 68a7028


Ignore:
Timestamp:
Sep 15, 2024, 2:35:13 PM (2 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
4fa7096
Parents:
0c88135
Message:

small changes

Location:
doc/theses/jiada_liang_MMath
Files:
3 edited

Legend:

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

    r0c88135 r68a7028  
    156156so these expressions remain unchanged by \CFA-cc.
    157157Therefore, a \CFA enumeration variable has the same underlying representation as its generated C enumeration.
    158 This semantics implies a \CFA enumeration variable uses the same storages as a C enumeration variable that @posn@ can use as its underlying representation, and the label and value arrays take little storage.
     158This semantics implies a \CFA enumeration variable uses the same storage as a C enumeration variable, that @posn@ can use as its underlying representation, and the label and value arrays take little storage.
    159159It should be possible to eliminated the two arrays if unused, either by \CFA if local to a translation unit and unused, or by the linker if global but unreferenced.
    160160Also, the label and value arrays are declared @static@ and initialized with constants, so the arrays are allocated in the @.data@ section and initialized before program execution.
  • doc/theses/jiada_liang_MMath/relatedwork.tex

    r0c88135 r68a7028  
    13201320let day : week = Weekend Sun
    13211321\end{ocaml}
    1322 The @week@ is a sum of @weekday@ and @weekend@; @week@ has all the enumerator from the set @weekday@ and @weekend@.
    1323 The sum type construction resembles containment inheritance from non-functional programming discipline, with
    1324 the sum type being a wrapper class that contains one of its parent type.
    1325 
    1326 The wrapper can be "unwrapped" with pattern matching:
     1322The type @week@ is the sum of @weekday@ and @weekend@, \ie @week@ has all the enumerators from the set @weekday@ and @weekend@.
     1323The sum type construction resembles containment inheritance from non-functional programming discipline, with the sum type being a wrapper class that contains one of its parent types.
     1324The wrapper is unwrapped with pattern matching:
     1325\begin{cquote}
     1326\begin{tabular}{@{}ll@{}}
    13271327\begin{ocaml}
     1328type weekday = Mon | Tue | Wed | Thu | Fri
     1329type weekend = Sat | Sun
     1330type week = Weekday of weekday |
     1331                                 Weekend of weekend
    13281332let wd : weekday = Mon
    13291333let _ = match wd with
    1330                 Mon -> printf "Mon\n" |
    1331                 _ -> printf "Take a break\n"
    1332 
     1334        Mon -> printf "Mon " | _ -> ()
    13331335let we : weekend = Sun
    13341336let _ = match we with
    1335                 Sun -> printf "Sun\n" |
    1336                 _ -> printf "Take a break\n"
    1337 
     1337        Sun -> printf "Sun " | _ -> ()
    13381338let day : week = Weekend Sun
    13391339let _ = match day with
    1340                 Weekend Sun -> printf "Sun\n" |
    1341                 _ -> printf "Take a break\n"
     1340        Weekend Sun -> printf "Sun\n" | _ -> ()
     1341
    13421342\end{ocaml}
     1343&
     1344\begin{cfa}
     1345enum() weekday { Mon, Tue, Wed, Thu, Fri };
     1346enum() weekend { Sat, Sun };
     1347enum() week { inline weekday, inline weekend };
     1348int main() {
     1349        weekday wd = Mon;
     1350
     1351        printf( "%s ", label( wd ) );
     1352        weekend we = Sun;
     1353
     1354        printf( "%s ", label( we ) );
     1355        week day = Sun;
     1356
     1357        printf( "%s\n", label( day ) );
     1358}
     1359\end{cfa}
     1360\\
     1361\begin{cfa}
     1362Mon Sun Sun
     1363\end{cfa}
     1364\end{tabular}
     1365\end{cquote}
    13431366
    13441367%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  • doc/theses/jiada_liang_MMath/test.ml

    r0c88135 r68a7028  
    2424
    2525type week = Mon | Tue | Wed | Thu | Fri | Sat | Sun [@@deriving enumerate]
    26 let _ = List.iter ( fun e -> printf "%d" (to_val e) ) all_of_week
     26(* let _ = List.iter ( fun e -> printf "%d" (to_val e) ) all_of_week*)
    2727
    2828let day : week = Mon
Note: See TracChangeset for help on using the changeset viewer.