# Changeset 67c6a47 for doc/theses

Ignore:
Timestamp:
Mar 6, 2021, 5:09:49 PM (8 months ago)
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
223ee0d
Parents:
d06707e
Message:

 rd06707e \section{Overloading and \lstinline{extern}} \CFA has extensive overloading, allowing multiple definitions of the same name to be defined.~\cite{Moss18} to be defined~\cite{Moss18}. \begin{cfa} char i; int i; double i;                        $\C[3.75in]{// variable overload}$ pointers using the ampersand (@&@) instead of the pointer asterisk (@*@). \CFA references may also be mutable or non-mutable. If mutable, a reference variable may be assigned to using the address-of operator (@&@), which converts the may be assigned using the address-of operator (@&@), which converts the reference to a pointer. \begin{cfa} \section{Constructors and Destructors} Both constructors and destructors are operators, which means they are just Both constructors and destructors are operators, which means they are functions with special operator names rather than type names in \Cpp. The special operator names may be used to call the functions explicitly (not In general, operator names in \CFA are constructed by bracketing an operator token with @?@, which indicates where the arguments. For example, infixed token with @?@, which indicates the position of the arguments. For example, infixed multiplication is @?*?@ while prefix dereference is @*?@. This syntax make it easy to tell the difference between prefix operations (such as @++?@) and definition, \CFA creates a default and copy constructor, destructor and assignment (like \Cpp). It is possible to define constructors/destructors for basic and existing types. basic and existing types (unlike \Cpp). \section{Polymorphism} do_once(value); } void do_once(int i) { ... }  // provide assertion int i; void do_once(@int@ i) { ... }  // provide assertion @int@ i; do_twice(i); // implicitly pass assertion do_once to do_twice \end{cfa} declarations instead of parameters, returns, and local variable declarations. \begin{cfa} forall(dtype T) forall(dtype @T@) struct node { node(T) * next;  // generic linked node T * data; } node(@T@) * next;  // generic linked node @T@ * data; } node(@int@) inode; \end{cfa} The generic type @node(T)@ is an example of a polymorphic-type usage.  Like \Cpp templates usage, a polymorphic-type usage must specify a type parameter. template usage, a polymorphic-type usage must specify a type parameter. There are many other polymorphism features in \CFA but these are the ones used by the exception system. \section{Concurrency} \CFA has a number of concurrency features: @thread@, @monitor@, @mutex@ parameters, @coroutine@ and @generator@. The two features that interact with the exception system are @thread@ and @coroutine@; they and their supporting \section{Control Flow} \CFA has a number of advanced control-flow features: @generator@, @coroutine@, @monitor@, @mutex@ parameters, and @thread@. The two features that interact with the exception system are @coroutine@ and @thread@; they and their supporting constructs are described here. CountUp countup; \end{cfa} Each coroutine has @main@ function, which takes a reference to a coroutine Each coroutine has a @main@ function, which takes a reference to a coroutine object and returns @void@. \begin{cfa}[numbers=left] In this function, or functions called by this function (helper functions), the @suspend@ statement is used to return execution to the coroutine's caller without terminating the coroutine. without terminating the coroutine's function. A coroutine is resumed by calling the @resume@ function, \eg @resume(countup)@. @resume(countup).next@. \subsection{Monitors and Mutex} \subsection{Monitor and Mutex Parameter} Concurrency does not guarantee ordering; without ordering results are non-deterministic. To claw back ordering, \CFA uses monitors and @mutex@ and only one runs at a time. \subsection{Threads} \subsection{Thread} Functions, generators, and coroutines are sequential so there is only a single (but potentially sophisticated) execution path in a program. Threads introduce monitors and mutex parameters. For threads to work safely with other threads, also requires mutual exclusion in the form of a communication rendezvous, which also supports internal synchronization as for mutex objects. For exceptions only the basic two basic operations are important: thread fork and join. also supports internal synchronization as for mutex objects. For exceptions, only two basic thread operations are important: fork and join. Threads are created like coroutines with an associated @main@ function: