Changeset a67279a for doc/theses
- Timestamp:
- Mar 9, 2021, 2:46:59 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- ab5498ec
- Parents:
- a33dcd5 (diff), 223ee0d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/existing.tex
ra33dcd5 ra67279a 14 14 \section{Overloading and \lstinline{extern}} 15 15 \CFA has extensive overloading, allowing multiple definitions of the same name 16 to be defined .~\cite{Moss18}16 to be defined~\cite{Moss18}. 17 17 \begin{cfa} 18 18 char i; int i; double i; $\C[3.75in]{// variable overload}$ … … 46 46 pointers using the ampersand (@&@) instead of the pointer asterisk (@*@). \CFA 47 47 references may also be mutable or non-mutable. If mutable, a reference variable 48 may be assigned tousing the address-of operator (@&@), which converts the48 may be assigned using the address-of operator (@&@), which converts the 49 49 reference to a pointer. 50 50 \begin{cfa} … … 58 58 \section{Constructors and Destructors} 59 59 60 Both constructors and destructors are operators, which means they are just60 Both constructors and destructors are operators, which means they are 61 61 functions with special operator names rather than type names in \Cpp. The 62 62 special operator names may be used to call the functions explicitly (not … … 64 64 65 65 In general, operator names in \CFA are constructed by bracketing an operator 66 token with @?@, which indicates wherethe arguments. For example, infixed66 token with @?@, which indicates the position of the arguments. For example, infixed 67 67 multiplication is @?*?@ while prefix dereference is @*?@. This syntax make it 68 68 easy to tell the difference between prefix operations (such as @++?@) and … … 89 89 definition, \CFA creates a default and copy constructor, destructor and 90 90 assignment (like \Cpp). It is possible to define constructors/destructors for 91 basic and existing types .91 basic and existing types (unlike \Cpp). 92 92 93 93 \section{Polymorphism} … … 120 120 do_once(value); 121 121 } 122 void do_once( inti) { ... } // provide assertion123 inti;122 void do_once(@int@ i) { ... } // provide assertion 123 @int@ i; 124 124 do_twice(i); // implicitly pass assertion do_once to do_twice 125 125 \end{cfa} … … 172 172 declarations instead of parameters, returns, and local variable declarations. 173 173 \begin{cfa} 174 forall(dtype T)174 forall(dtype @T@) 175 175 struct node { 176 node(T) * next; // generic linked node 177 T * data; 178 } 176 node(@T@) * next; // generic linked node 177 @T@ * data; 178 } 179 node(@int@) inode; 179 180 \end{cfa} 180 181 The generic type @node(T)@ is an example of a polymorphic-type usage. Like \Cpp 181 template susage, a polymorphic-type usage must specify a type parameter.182 template usage, a polymorphic-type usage must specify a type parameter. 182 183 183 184 There are many other polymorphism features in \CFA but these are the ones used 184 185 by the exception system. 185 186 186 \section{Con currency}187 \CFA has a number of concurrency features: @thread@, @monitor@, @mutex@188 parameters, @coroutine@ and @generator@.The two features that interact with189 the exception system are @ thread@ and @coroutine@; they and their supporting187 \section{Control Flow} 188 \CFA has a number of advanced control-flow features: @generator@, @coroutine@, @monitor@, @mutex@ parameters, and @thread@. 189 The two features that interact with 190 the exception system are @coroutine@ and @thread@; they and their supporting 190 191 constructs are described here. 191 192 … … 216 217 CountUp countup; 217 218 \end{cfa} 218 Each coroutine has @main@ function, which takes a reference to a coroutine219 Each coroutine has a @main@ function, which takes a reference to a coroutine 219 220 object and returns @void@. 220 221 \begin{cfa}[numbers=left] … … 230 231 In this function, or functions called by this function (helper functions), the 231 232 @suspend@ statement is used to return execution to the coroutine's caller 232 without terminating the coroutine .233 without terminating the coroutine's function. 233 234 234 235 A coroutine is resumed by calling the @resume@ function, \eg @resume(countup)@. … … 242 243 @resume(countup).next@. 243 244 244 \subsection{Monitor s and Mutex}245 \subsection{Monitor and Mutex Parameter} 245 246 Concurrency does not guarantee ordering; without ordering results are 246 247 non-deterministic. To claw back ordering, \CFA uses monitors and @mutex@ … … 260 261 and only one runs at a time. 261 262 262 \subsection{Thread s}263 \subsection{Thread} 263 264 Functions, generators, and coroutines are sequential so there is only a single 264 265 (but potentially sophisticated) execution path in a program. Threads introduce … … 268 269 monitors and mutex parameters. For threads to work safely with other threads, 269 270 also requires mutual exclusion in the form of a communication rendezvous, which 270 also supports internal synchronization as for mutex objects. For exceptions 271 only t he basic two basic operations are important: threadfork and join.271 also supports internal synchronization as for mutex objects. For exceptions, 272 only two basic thread operations are important: fork and join. 272 273 273 274 Threads are created like coroutines with an associated @main@ function:
Note: See TracChangeset
for help on using the changeset viewer.