Changes in / [c0c8962:e72969a]

1 edited


  • doc/theses/andrew_beach_MMath/existing.tex

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