Ignore:
Timestamp:
Sep 10, 2021, 10:43:15 AM (4 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
63b3279
Parents:
d0b9247
Message:

Andrew MMath: Used (most of) Gregor's feedback to update the thesis. There are still a few \todo items as well as a general request for examples.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/existing.tex

    rd0b9247 r9cdfa5fb  
    66compatibility with C and its programmers.  \CFA is designed to have an
    77orthogonal feature-set based closely on the C programming paradigm
    8 (non-object-oriented) and these features can be added incrementally to an
    9 existing C code-base allowing programmers to learn \CFA on an as-needed basis.
     8(non-object-oriented), and these features can be added incrementally to an
     9existing C code-base,
     10allowing programmers to learn \CFA on an as-needed basis.
    1011
    1112Only those \CFA features pertaining to this thesis are discussed.
     
    4546\CFA adds a reference type to C as an auto-dereferencing pointer.
    4647They work very similarly to pointers.
    47 Reference-types are written the same way as a pointer-type but each
     48Reference-types are written the same way as pointer-types, but each
    4849asterisk (@*@) is replaced with a ampersand (@&@);
    49 this includes cv-qualifiers and multiple levels of reference.
    50 
    51 Generally, references act like pointers with an implicate dereferencing
     50this includes cv-qualifiers (\snake{const} and \snake{volatile})
     51%\todo{Should I go into even more detail on cv-qualifiers.}
     52and multiple levels of reference.
     53
     54Generally, references act like pointers with an implicit dereferencing
    5255operation added to each use of the variable.
    5356These automatic dereferences may be disabled with the address-of operator
     
    8386Mutable references may be assigned to by converting them to a pointer
    8487with a @&@ and then assigning a pointer to them, as in @&ri = &j;@ above.
    85 % ???
    8688
    8789\section{Operators}
     
    9395For example,
    9496infixed multiplication is @?*?@, while prefix dereference is @*?@.
    95 This syntax make it easy to tell the difference between prefix operations
    96 (such as @++?@) and post-fix operations (@?++@).
     97This syntax makes it easy to tell the difference between prefix operations
     98(such as @++?@) and postfix operations (@?++@).
    9799
    98100As an example, here are the addition and equality operators for a point type.
     
    104106}
    105107\end{cfa}
    106 Note that this syntax works effectively but a textual transformation,
     108Note that this syntax works effectively as a textual transformation;
    107109the compiler converts all operators into functions and then resolves them
    108110normally. This means any combination of types may be used,
     
    113115%\subsection{Constructors and Destructors}
    114116In \CFA, constructors and destructors are operators, which means they are
    115 functions with special operator names rather than type names in \Cpp.
     117functions with special operator names, rather than type names as in \Cpp.
    116118Both constructors and destructors can be implicity called by the compiler,
    117119however the operator names allow explicit calls.
     
    137139@b@ because of the explicit call and @a@ implicitly.
    138140@c@ will be initalized with the second constructor.
    139 Currently, there is no general way to skip initialation.
     141Currently, there is no general way to skip initialization.
    140142% I don't use @= anywhere in the thesis.
    141143
     
    202204do_twice(i);
    203205\end{cfa}
    204 Any object with a type fulfilling the assertion may be passed as an argument to
     206Any value with a type fulfilling the assertion may be passed as an argument to
    205207a @do_twice@ call.
    206208
     
    222224function. The matched assertion function is then passed as a function pointer
    223225to @do_twice@ and called within it.
    224 The global definition of @do_once@ is ignored, however if quadruple took a
     226The global definition of @do_once@ is ignored, however if @quadruple@ took a
    225227@double@ argument, then the global definition would be used instead as it
    226228would then be a better match.\cite{Moss19}
    227229
    228230To avoid typing long lists of assertions, constraints can be collected into
    229 convenient a package called a @trait@, which can then be used in an assertion
     231a convenient package called a @trait@, which can then be used in an assertion
    230232instead of the individual constraints.
    231233\begin{cfa}
     
    241243functions and variables, and are usually used to create a shorthand for, and
    242244give descriptive names to, common groupings of assertions describing a certain
    243 functionality, like @sumable@, @listable@, \etc.
     245functionality, like @summable@, @listable@, \etc.
    244246
    245247Polymorphic structures and unions are defined by qualifying an aggregate type
    246248with @forall@. The type variables work the same except they are used in field
    247 declarations instead of parameters, returns, and local variable declarations.
     249declarations instead of parameters, returns and local variable declarations.
    248250\begin{cfa}
    249251forall(dtype T)
     
    261263
    262264\section{Control Flow}
    263 \CFA has a number of advanced control-flow features: @generator@, @coroutine@, @monitor@, @mutex@ parameters, and @thread@.
     265\CFA has a number of advanced control-flow features: @generator@, @coroutine@,
     266@monitor@, @mutex@ parameters, and @thread@.
    264267The two features that interact with
    265268the exception system are @coroutine@ and @thread@; they and their supporting
     
    268271\subsection{Coroutine}
    269272A coroutine is a type with associated functions, where the functions are not
    270 required to finish execution when control is handed back to the caller. Instead
     273required to finish execution when control is handed back to the caller.
     274Instead,
    271275they may suspend execution at any time and be resumed later at the point of
    272 last suspension. (Generators are stackless and coroutines are stackful.) These
     276last suspension.
     277Coroutine
    273278types are not concurrent but share some similarities along with common
    274 underpinnings, so they are combined with the \CFA threading library. Further
    275 discussion in this section only refers to the coroutine because generators are
    276 similar.
     279underpinnings, so they are combined with the \CFA threading library.
     280% I had mention of generators, but they don't actually matter here.
    277281
    278282In \CFA, a coroutine is created using the @coroutine@ keyword, which is an
     
    322326\end{cfa}
    323327
    324 When the main function returns the coroutine halts and can no longer be
     328When the main function returns, the coroutine halts and can no longer be
    325329resumed.
    326330
    327331\subsection{Monitor and Mutex Parameter}
    328 Concurrency does not guarantee ordering; without ordering results are
     332Concurrency does not guarantee ordering; without ordering, results are
    329333non-deterministic. To claw back ordering, \CFA uses monitors and @mutex@
    330334(mutual exclusion) parameters. A monitor is another kind of aggregate, where
     
    332336@mutex@ parameters.
    333337
    334 A function that requires deterministic (ordered) execution, acquires mutual
     338A function that requires deterministic (ordered) execution acquires mutual
    335339exclusion on a monitor object by qualifying an object reference parameter with
    336 @mutex@.
     340the @mutex@ qualifier.
    337341\begin{cfa}
    338342void example(MonitorA & mutex argA, MonitorB & mutex argB);
     
    344348
    345349\subsection{Thread}
    346 Functions, generators, and coroutines are sequential so there is only a single
     350Functions, generators and coroutines are sequential, so there is only a single
    347351(but potentially sophisticated) execution path in a program. Threads introduce
    348352multiple execution paths that continue independently.
    349353
    350354For threads to work safely with objects requires mutual exclusion using
    351 monitors and mutex parameters. For threads to work safely with other threads,
     355monitors and mutex parameters. For threads to work safely with other threads
    352356also requires mutual exclusion in the form of a communication rendezvous, which
    353357also supports internal synchronization as for mutex objects. For exceptions,
Note: See TracChangeset for help on using the changeset viewer.