Changeset c459f99


Ignore:
Timestamp:
May 2, 2023, 11:11:34 AM (19 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
21d1c9c
Parents:
d1c51b1
Message:

formatting, small updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/text/CFA_intro.tex

    rd1c51b1 rc459f99  
    66
    77\section{Overview}
    8 The following serves as an introduction to \CFA. 
    9 \CFA is a layer over C, is transpiled\footnote{Source to source translator.} to C, and is largely considered to be an extension of C. 
    10 Beyond C, it adds productivity features, extended libraries, an advanced type system, and many control-flow/concurrency constructions.
    11 However, \CFA stays true to the C programming style, with most code revolving around @struct@'s and routines, and respects the same rules as C. 
    12 \CFA is not object oriented as it has no notion of @this@ (receiver) and no structures with methods, but supports some object oriented ideas including constructors, destructors, and limited containment inheritance. 
     8The following serves as an introduction to \CFA.
     9\CFA is a layer over C, is transpiled\footnote{Source to source translator.} to C, and is largely considered to be an extension of C.
     10Beyond C, it adds productivity features, extended libraries, an advanced type-system, and many control-flow/concurrency constructions.
     11However, \CFA stays true to the C programming style, with most code revolving around @struct@'s and routines, and respects the same rules as C.
     12\CFA is not object oriented as it has no notion of @this@ (receiver) and no structures with methods, but supports some object oriented ideas including constructors, destructors, and limited containment inheritance.
    1313While \CFA is rich with interesting features, only the subset pertinent to this work is discussed.
    1414
    1515\section{References}
    16 References in \CFA are similar to references in \CC; however \CFA references are rebindable, and support multi-level referencing.
    17 References in \CFA are a layer of syntactic sugar over pointers to reduce the number of ref/deref operations needed with pointer usage. 
     16References in \CFA are similar to references in \CC; however \CFA references are \emph{rebindable}, and support multi-level referencing.
     17References in \CFA are a layer of syntactic sugar over pointers to reduce the number of ref/deref operations needed with pointer usage.
    1818Another difference is the use of @0p@ instead of C's @NULL@ or \CC's @nullptr@.
    19 Examples of references are shown in \VRef[Listing]{l:cfa_ref}. 
     19Examples of references are shown in \VRef[Listing]{l:cfa_ref}.
    2020
    2121\begin{cfa}[caption={Example of \CFA references},label={l:cfa_ref}]
     
    3737
    3838\section{Overloading}\label{s:Overloading}
    39 \CFA routines can be overloaded on parameter type, number of parameters, and \emph{return type}. 
    40 Variables can also be overloaded on type, meaning that two variables can have the same name so long as they have different types. 
     39\CFA routines can be overloaded on parameter type, number of parameters, and \emph{return type}.
     40Variables can also be overloaded on type, meaning that two variables can have the same name so long as they have different types.
    4141A routine or variable is disambiguated at each usage site via its type and surrounding expression context.
    42 A cast is used to disambiguate any conflicting usage. 
    43 Examples of overloading are shown in \VRef[Listing]{l:cfa_overload}. 
     42A cast is used to disambiguate any conflicting usage.
     43Examples of overloading are shown in \VRef[Listing]{l:cfa_overload}.
    4444
    4545\begin{cfa}[caption={Example of \CFA overloading},label={l:cfa_overload}]
     
    6060
    6161
    62 \section{With Statement}
     62\section{\lstinline{with} Statement}
    6363The \CFA @with@ statement is for exposing fields of an aggregate type within a scope, allowing field names without qualification.
    64 This feature is also implemented in Pascal~\cite{Pascal}. 
    65 It can exist as a stand-alone statement or wrap a routine body to expose aggregate fields. 
    66 Examples of the @with@ statement are shown in \VRef[Listing]{l:cfa_with}. 
     64This feature is also implemented in Pascal~\cite{Pascal}.
     65It can exist as a stand-alone statement or wrap a routine body to expose aggregate fields.
     66Examples of the @with@ statement are shown in \VRef[Listing]{l:cfa_with}.
    6767
    6868\begin{cfa}[caption={Example of \CFA \lstinline{with} statement},label={l:cfa_with}]
     
    8383
    8484\section{Operators}
    85 Operators can be overloaded in \CFA with operator routines. 
     85Operators can be overloaded in \CFA with operator routines.
    8686Operators in \CFA are named using an operator symbol and '@?@' to represent operands.
    87 Examples of \CFA operators are shown in \VRef[Listing]{l:cfa_operate}. 
     87Examples of \CFA operators are shown in \VRef[Listing]{l:cfa_operate}.
    8888
    8989\begin{cfa}[caption={Example of \CFA operators},label={l:cfa_operate}]
     
    102102
    103103\section{Constructors and Destructors}
    104 Constructors and destructors in \CFA are special operator routines used for creation and destruction of objects. 
    105 The default constructor and destructor for a type are called implicitly upon creation and deletion, respectively. 
    106 Examples of \CFA constructors and destructors are shown in \VRef[Listing]{l:cfa_ctor}. 
     104Constructors and destructors in \CFA are special operator routines used for creation and destruction of objects.
     105The default constructor and destructor for a type are called implicitly upon creation and deletion, respectively.
     106Examples of \CFA constructors and destructors are shown in \VRef[Listing]{l:cfa_ctor}.
    107107
    108108\begin{cfa}[caption={Example of \CFA constructors and destructors},label={l:cfa_ctor}]
     
    128128\section{Polymorphism}\label{s:poly}
    129129C supports limited polymorphism, often requiring users to implement polymorphism using a @void *@ (type erasure) approach.
    130 \CFA extends C with generalized overloading polymorphism (see \VRef{s:Overloading}), as well as, parametric polymorphism and nominal inheritance.
     130\CFA extends C with generalized overloading polymorphism (see \VRef{s:Overloading}), as well as, parametric polymorphism and limited containment inheritance.
    131131
    132132\subsection{Parametric Polymorphism}
    133 \CFA provides parametric polymorphism in the form of @forall@, and @trait@s. 
    134 A @forall@ takes in a set of types and a list of constraints. 
    135 The declarations that follow the @forall@ are parameterized over the types listed that satisfy the constraints. 
    136 A list of @forall@ constraints can be refactored into a named @trait@ and reused in @forall@s. 
    137 Examples of \CFA parametric polymorphism are shown in \VRef[Listing]{l:cfa_poly}. 
     133\CFA provides parametric polymorphism in the form of @forall@, and @trait@s.
     134A @forall@ takes in a set of types and a list of constraints.
     135The declarations that follow the @forall@ are parameterized over the types listed that satisfy the constraints.
     136A list of @forall@ constraints can be refactored into a named @trait@ and reused in @forall@s.
     137Examples of \CFA parametric polymorphism are shown in \VRef[Listing]{l:cfa_poly}.
    138138
    139139\begin{cfa}[caption={Example of \CFA parametric polymorphism},label={l:cfa_poly}]
     
    180180
    181181\subsection{Inheritance}
    182 Inheritance in \CFA is taken from Plan-9 C's containment inheritance. 
    183 In \CFA, @struct@s can @inline@ another struct type to gain its fields and masquerade as that type. 
    184 Examples of \CFA containment inheritance are shown in \VRef[Listing]{l:cfa_inherit}. 
     182Inheritance in \CFA is taken from Plan-9 C's containment inheritance.
     183In \CFA, @struct@s can @inline@ another struct type to gain its fields and masquerade as that type.
     184Examples of \CFA containment inheritance are shown in \VRef[Listing]{l:cfa_inherit}.
    185185
    186186\begin{cfa}[caption={Example of \CFA containment inheritance},label={l:cfa_inherit}]
    187187struct one_d { double x; };
    188 struct two_d { 
     188struct two_d {
    189189        @inline@ one_d;
    190190        double y;
    191191};
    192 struct three_d { 
     192struct three_d {
    193193        @inline@ two_d;
    194194        double z;
Note: See TracChangeset for help on using the changeset viewer.