Changes in / [e72969a:c0c8962]


Ignore:
File:
1 edited

Legend:

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

    re72969a rc0c8962  
    4242
    4343\section{Reference Type}
    44 \CFA adds a reference type to C as an auto-dereferencing pointer.
    45 They work very similarly to pointers.
    46 Reference-types are written the same way as a pointer-type is but each
    47 asterisk (@*@) is replaced with a ampersand (@&@);
    48 this includes cv-qualifiers and multiple levels of reference.
    49 
    50 They are intended for cases where you would want to use pointers but would
    51 be dereferencing them (almost) every usage.
    52 In most cases a reference can just be thought of as a pointer that
    53 automatically puts a dereference infront of each of its uses (per-level of
    54 reference).
    55 The address-of operator (@&@) acts as an escape and removes one of the
    56 automatic dereference operations.
    57 Mutable references may be assigned to by converting them to a pointer
    58 with a @&@ and then assigning a pointer too them.
    59 
    60 \begin{minipage}{0,5\textwidth}
    61 With references:
     44\CFA adds a rebindable reference type to C, but more expressive than the \Cpp
     45reference.  Multi-level references are allowed and act like auto-dereferenced
     46pointers using the ampersand (@&@) instead of the pointer asterisk (@*@). \CFA
     47references may also be mutable or non-mutable. If mutable, a reference variable
     48may be assigned using the address-of operator (@&@), which converts the
     49reference to a pointer.
    6250\begin{cfa}
    6351int i, j;
    64 int & ri = i;
    65 int && rri = ri;
    66 rri = 3;
    67 &ri = &j;
    68 ri = 5;
    69 \end{cfa}
    70 \end{minipage}
    71 \begin{minipage}{0,5\textwidth}
    72 With pointers:
    73 \begin{cfa}
    74 int i, j;
    75 int * pi = &i
    76 int ** ppi = π
    77 **ppi = 3;
    78 pi = &j;
    79 *pi = 5;
    80 \end{cfa}
    81 \end{minipage}
     52int & ri = i, && rri = ri;
     53rri = 3;  // auto-dereference assign to i
     54&ri = &j; // rebindable
     55ri = 5;   // assign to j
     56\end{cfa}
    8257
    8358\section{Constructors and Destructors}
Note: See TracChangeset for help on using the changeset viewer.