Ignore:
Timestamp:
May 1, 2024, 1:36:04 PM (2 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
d414664
Parents:
de3a579 (diff), 69867ad9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    rde3a579 r35897fb  
    1212The definition of member types and their constructors are from the outer lexical scope.
    1313
    14 In general, an \Newterm{algebraic data type} (ADT) is a composite type, \ie, a type formed by combining other types.
    15 Three common classes of algebraic types are \Newterm{array type}, \ie homogeneous types, \Newterm{product type}, \ie heterogeneous tuples and records (structures), and \Newterm{sum type}, \ie tagged product-types (unions).
     14In general, an \newterm{algebraic data type} (ADT) is a composite type, \ie, a type formed by combining other types.
     15Three common classes of algebraic types are \newterm{array type}, \ie homogeneous types, \newterm{product type}, \ie heterogeneous tuples and records (structures), and \newterm{sum type}, \ie tagged product-types (unions).
    1616Enumerated types are a special case of product/sum types with non-mutable fields, \ie initialized (constructed) once at the type's declaration, possible restricted to compile-time initialization.
    1717Values of algebraic types are access by subscripting, field qualification, or type (pattern) matching.
     
    5151\section{Ada}
    5252
    53 An Ada enumeration type is a set of ordered unscoped identifiers (enumerators) bound to \emph{unique} \Newterm{literals}.\footnote{%
     53An Ada enumeration type is a set of ordered unscoped identifiers (enumerators) bound to \emph{unique} \newterm{literals}.\footnote{%
    5454Ada is \emph{case-insensitive} so identifiers may appear in multiple forms and still be the same, \eg \lstinline{Mon}, \lstinline{moN}, and \lstinline{MON} (a questionable design decision).}
    5555\begin{ada}
     
    21772177Here, function @take_class@ has a @weekday@ parameter, and returns @"CS442"@, if the weekday value is @Mon@ or @Wed@, @"CS343"@, if the value is @Tue@ or @Thu@, and @"Tutorial"@ for @Fri@.
    21782178The ``@_@'' is a wildcard matching any @weekday@ value, so the function returns @"Take a break"@ for values @Sat@ or @Sun@, which are not matched by the previous cases.
    2179 Since the variant has no type, it has a \Newterm{0-arity constructor}, \ie no parameters.
    2180 Because @weekday@ is a union of values @Mon@ to @Sun@, it is a \Newterm{union type} in turns of the functional-programming paradigm.
     2179Since the variant has no type, it has a \newterm{0-arity constructor}, \ie no parameters.
     2180Because @weekday@ is a union of values @Mon@ to @Sun@, it is a \newterm{union type} in turns of the functional-programming paradigm.
    21812181
    21822182Each variant can have an associated heterogeneous type, with an n-ary constructor for creating a corresponding value.
     
    22022202type @stringList@ = Empty | Pair of string * @stringList@
    22032203\end{ocaml}
    2204 which is a recursive sum of product of types, called an \Newterm{algebraic data-type}.
     2204which is a recursive sum of product of types, called an \newterm{algebraic data-type}.
    22052205A recursive function is often used to pattern match against a recursive variant type.
    22062206\begin{ocaml}
Note: See TracChangeset for help on using the changeset viewer.