Ignore:
Timestamp:
Aug 8, 2024, 3:51:52 PM (3 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
c4aca65
Parents:
5b4c8df
Message:

(Software) grammar check

File:
1 edited

Legend:

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

    r5b4c8df rab11ab1  
    11\chapter{Introduction}
    22
    3 All basic types in a programming language have a set of constants (symbols), and these constants represent computable values, \eg integer types have constants @-1@, @17@, @0xff@ representing whole numbers, floating-point types have constants @5.3@, @2.3E-5@, @0xff.ffp0@ representing  real numbers, character types have constants @'a'@, @"abc\n"@, \mbox{\lstinline{u8"}\texttt{\guillemotleft{na\"{i}ve}\guillemotright}\lstinline{"}} representing (human readable) text, \etc.
     3All basic types in a programming language have a set of constants (symbols), and these constants represent computable values, \eg integer types have constants @-1@, @17@, @0xff@ representing whole numbers, floating-point types have constants @5.3@, @2.3E-5@, @0xff.ffp0@ representing real numbers, character types have constants @'a'@, @"abc\n"@, \mbox{\lstinline{u8"}\texttt{\guillemotleft{na\"{i}ve}\guillemotright}\lstinline{"}} representing (human readable) text, \etc.
    44Constants can be overloaded among types, \eg @0@ is a null pointer for all pointer types, and the value zero for integer and floating-point types.
    55(In \CFA, the constants @0@ and @1@ can be overloaded for any type.)
     
    1212A constant's symbolic name is dictated by language syntax related to types, \eg @5.@ (double), @5.0f@ (float), @5l@ (long double).
    1313In general, the representation of a constant's value is \newterm{opaque}, so the internal representation can be chosen arbitrarily, \eg two's complement, IEEE floating-point.
    14 In theory, there are an infinite set of constant names per type representing an infinite set of values.
     14In theory, there is an infinite set of constant names per type representing an infinite set of values.
    1515
    1616It is common in mathematics, engineering, and computer science to alias new constants to existing constants so they have the same value, \eg $\pi$, $\tau$ (2$\pi$), $\phi$ (golden ratio), K(k), M, G, T for powers of 2\footnote{Overloaded with SI powers of 10.} often prefixing bits (b) or bytes (B), \eg Gb, MB, and in general situations, \eg specific times (noon, New Years), cities (Big Apple), flowers (Lily), \etc.
     
    2323Because an aliased name is a constant, it cannot appear in a mutable context, \eg \mbox{$\pi$ \lstinline{= 42}} is meaningless, and a constant has no address, \ie it is an \newterm{rvalue}\footnote{
    2424The term rvalue defines an expression that can only appear on the right-hand side of an assignment expression.}.
    25 In theory, there are an infinite set of possible aliasing, in practice, the number of aliasing per program is finite and small.
     25In theory, there is an infinite set of possible aliasing; in practice, the number of aliasing per program is finite and small.
    2626
    2727Aliased constants can form an (ordered) set, \eg days of a week, months of a year, floors of a building (basement, ground, 1st), colours in a rainbow, \etc.
     
    5959\end{sloppypar}
    6060\item
    61 The alias names are constants, which follows transitively from their binding to other constants.
     61The alias names are constants, which follow transitively from their binding to other constants.
    6262\item
    6363Defines a type for generating instants (variables).
     
    105105Hence, the term \emph{enumeration} can be confusing and misunderstood.
    106106Furthermore, some languages conjoin the enumeration with other type features, making it difficult to tease apart which feature is being used.
    107 This section discusses some language features that are sometimes called an enumeration but do not provide all enumeration aspects.
     107This section discusses some language features that are sometimes called enumeration but do not provide all enumeration aspects.
    108108
    109109
     
    140140\end{cfa}
    141141For these reasons, aliasing is sometimes called an enumeration.
    142 However, there is no type to create a type-checked instance or iterator cursor, so there is no ability for enumerating.
     142However, there is no type to create a type-checked instance or iterator cursor, so there is no ability to enumerate.
    143143Hence, there are multiple enumeration aspects not provided by aliasing, justifying a separate enumeration type in a programming language.
    144144
     
    158158the ADT has three variants (constructors), @A@, @B@, @C@, with associated types @Int@, @Double@, and @S@.
    159159The constructors create an initialized value of the specific type that is bound to the immutable variables @foo@, @bar@, and @baz@.
    160 Hence, the ADT @Foo@ is like a union containing values of the associated types, and a constructor name is used to intialize and access the value using dynamic pattern-matching.
     160Hence, the ADT @Foo@ is like a union containing values of the associated types, and a constructor name is used to initialize and access the value using dynamic pattern-matching.
    161161\begin{cquote}
    162162\setlength{\tabcolsep}{20pt}
     
    194194baz = Z 5;
    195195\end{haskell}
    196 Here, the constructor name gives different meaning to the values in the common \lstinline[language=Haskell]{Int} type, \eg the value @3@ has different interpretations depending on the constructor name in the pattern matching.
     196Here, the constructor name gives different meanings to the values in the common \lstinline[language=Haskell]{Int} type, \eg the value @3@ has different interpretations depending on the constructor name in the pattern matching.
    197197
    198198Note, the term \newterm{variant} is often associated with ADTs.
    199199However, there are multiple languages with a @variant@ type that is not an ADT \see{Algol68~\cite{Algol68} or \CC \lstinline{variant}}.
    200 Here, the type (and possibly the position for equivalent types) is used to discriminant the specific \emph{variant} within the variant instance.
     200Here, the type (and possibly the position for equivalent types) is used to discriminate the specific \emph{variant} within the variant instance.
    201201For example, \VRef[Figure]{f:C++variant} shows the \CC equivalent of the two Haskell ADT types using variant types.
    202202In these languages, the variant cannot be used to simulate an enumeration.
     
    246246data Week = Mon | Tue | Wed | Thu | Fri | Sat | Sun deriving(Enum, Eq, Show)
    247247\end{haskell}
    248 the default type for each constructor is the unit type, and deriving from @Enum@ enforces no other associated types, @Eq@ allows equality comparison, and @Show@ is for printing.
    249 The nullary constructors for the unit types are numbered left-to-right from $0$ to @maxBound@$- 1$, and provides enumerating operations @succ@, @pred@, @enumFrom@, @enumFromTo@.
     248the default type for each constructor is the unit type, and deriving from @Enum@ enforces no other associated types. The @Eq@ allows equality comparison, and @Show@ is for printing.
     249The nullary constructors for the unit types are numbered left-to-right from $0$ to @maxBound@$- 1$, and provide enumerating operations @succ@, @pred@, @enumFrom@, @enumFromTo@.
    250250\VRef[Figure]{f:HaskellEnumeration} shows enumeration comparison and iterating (enumerating).
    251251
     
    296296However, when extended with advanced features, enumerations become complex for both the type system and the runtime implementation.
    297297
    298 The contribution of this work are:
     298The contributions of this work are:
    299299\begin{enumerate}
    300300\item
     
    303303overloading: Provide a pattern to overload functions, literals, and variables for polymorphic enumerations using the \CFA type system.
    304304\item
    305 scoping: Add a name space for enumerations and qualified access into the namespace to deal with the naming problem.
     305scoping: Add a namespace for enumerations and qualified access into the namespace to deal with the naming problem.
    306306\item
    307307generalization: Support all language types for enumerators with associated values providing enumeration constants for any type.
Note: See TracChangeset for help on using the changeset viewer.