Changeset 9cdfa5fb for doc/theses/andrew_beach_MMath/existing.tex
- Timestamp:
- Sep 10, 2021, 10:43:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 63b3279
- Parents:
- d0b9247
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/existing.tex
rd0b9247 r9cdfa5fb 6 6 compatibility with C and its programmers. \CFA is designed to have an 7 7 orthogonal 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 9 existing C code-base, 10 allowing programmers to learn \CFA on an as-needed basis. 10 11 11 12 Only those \CFA features pertaining to this thesis are discussed. … … 45 46 \CFA adds a reference type to C as an auto-dereferencing pointer. 46 47 They work very similarly to pointers. 47 Reference-types are written the same way as a pointer-typebut each48 Reference-types are written the same way as pointer-types, but each 48 49 asterisk (@*@) 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 50 this includes cv-qualifiers (\snake{const} and \snake{volatile}) 51 %\todo{Should I go into even more detail on cv-qualifiers.} 52 and multiple levels of reference. 53 54 Generally, references act like pointers with an implicit dereferencing 52 55 operation added to each use of the variable. 53 56 These automatic dereferences may be disabled with the address-of operator … … 83 86 Mutable references may be assigned to by converting them to a pointer 84 87 with a @&@ and then assigning a pointer to them, as in @&ri = &j;@ above. 85 % ???86 88 87 89 \section{Operators} … … 93 95 For example, 94 96 infixed multiplication is @?*?@, while prefix dereference is @*?@. 95 This syntax make it easy to tell the difference between prefix operations96 (such as @++?@) and post -fix operations (@?++@).97 This syntax makes it easy to tell the difference between prefix operations 98 (such as @++?@) and postfix operations (@?++@). 97 99 98 100 As an example, here are the addition and equality operators for a point type. … … 104 106 } 105 107 \end{cfa} 106 Note that this syntax works effectively but a textual transformation,108 Note that this syntax works effectively as a textual transformation; 107 109 the compiler converts all operators into functions and then resolves them 108 110 normally. This means any combination of types may be used, … … 113 115 %\subsection{Constructors and Destructors} 114 116 In \CFA, constructors and destructors are operators, which means they are 115 functions with special operator names rather than type names in \Cpp.117 functions with special operator names, rather than type names as in \Cpp. 116 118 Both constructors and destructors can be implicity called by the compiler, 117 119 however the operator names allow explicit calls. … … 137 139 @b@ because of the explicit call and @a@ implicitly. 138 140 @c@ will be initalized with the second constructor. 139 Currently, there is no general way to skip initial ation.141 Currently, there is no general way to skip initialization. 140 142 % I don't use @= anywhere in the thesis. 141 143 … … 202 204 do_twice(i); 203 205 \end{cfa} 204 Any objectwith a type fulfilling the assertion may be passed as an argument to206 Any value with a type fulfilling the assertion may be passed as an argument to 205 207 a @do_twice@ call. 206 208 … … 222 224 function. The matched assertion function is then passed as a function pointer 223 225 to @do_twice@ and called within it. 224 The global definition of @do_once@ is ignored, however if quadrupletook a226 The global definition of @do_once@ is ignored, however if @quadruple@ took a 225 227 @double@ argument, then the global definition would be used instead as it 226 228 would then be a better match.\cite{Moss19} 227 229 228 230 To avoid typing long lists of assertions, constraints can be collected into 229 convenient apackage called a @trait@, which can then be used in an assertion231 a convenient package called a @trait@, which can then be used in an assertion 230 232 instead of the individual constraints. 231 233 \begin{cfa} … … 241 243 functions and variables, and are usually used to create a shorthand for, and 242 244 give descriptive names to, common groupings of assertions describing a certain 243 functionality, like @sum able@, @listable@, \etc.245 functionality, like @summable@, @listable@, \etc. 244 246 245 247 Polymorphic structures and unions are defined by qualifying an aggregate type 246 248 with @forall@. The type variables work the same except they are used in field 247 declarations instead of parameters, returns ,and local variable declarations.249 declarations instead of parameters, returns and local variable declarations. 248 250 \begin{cfa} 249 251 forall(dtype T) … … 261 263 262 264 \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@. 264 267 The two features that interact with 265 268 the exception system are @coroutine@ and @thread@; they and their supporting … … 268 271 \subsection{Coroutine} 269 272 A 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 273 required to finish execution when control is handed back to the caller. 274 Instead, 271 275 they 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 276 last suspension. 277 Coroutine 273 278 types 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. 279 underpinnings, so they are combined with the \CFA threading library. 280 % I had mention of generators, but they don't actually matter here. 277 281 278 282 In \CFA, a coroutine is created using the @coroutine@ keyword, which is an … … 322 326 \end{cfa} 323 327 324 When the main function returns the coroutine halts and can no longer be328 When the main function returns, the coroutine halts and can no longer be 325 329 resumed. 326 330 327 331 \subsection{Monitor and Mutex Parameter} 328 Concurrency does not guarantee ordering; without ordering results are332 Concurrency does not guarantee ordering; without ordering, results are 329 333 non-deterministic. To claw back ordering, \CFA uses monitors and @mutex@ 330 334 (mutual exclusion) parameters. A monitor is another kind of aggregate, where … … 332 336 @mutex@ parameters. 333 337 334 A function that requires deterministic (ordered) execution ,acquires mutual338 A function that requires deterministic (ordered) execution acquires mutual 335 339 exclusion on a monitor object by qualifying an object reference parameter with 336 @mutex@.340 the @mutex@ qualifier. 337 341 \begin{cfa} 338 342 void example(MonitorA & mutex argA, MonitorB & mutex argB); … … 344 348 345 349 \subsection{Thread} 346 Functions, generators , and coroutines are sequentialso there is only a single350 Functions, generators and coroutines are sequential, so there is only a single 347 351 (but potentially sophisticated) execution path in a program. Threads introduce 348 352 multiple execution paths that continue independently. 349 353 350 354 For threads to work safely with objects requires mutual exclusion using 351 monitors and mutex parameters. For threads to work safely with other threads ,355 monitors and mutex parameters. For threads to work safely with other threads 352 356 also requires mutual exclusion in the form of a communication rendezvous, which 353 357 also supports internal synchronization as for mutex objects. For exceptions,
Note: See TracChangeset
for help on using the changeset viewer.