Changeset 9724df0


Ignore:
Timestamp:
Jun 20, 2016, 10:52:40 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1f17e07, a0dcd2e, f6d4204
Parents:
1da317b
Message:

update latex macros, and user and refrat manuals

Location:
doc
Files:
25 added
6 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r1da317b r9724df0  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jun 10 16:35:25 2016
    14 %% Update Count     : 101
     13%% Last Modified On : Mon Jun 20 09:35:20 2016
     14%% Update Count     : 178
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    2323\renewcommand{\floatpagefraction}{0.8}  % float must be greater than X of the page before it is forced onto its own page
    2424\renewcommand{\textfraction}{0.0}       % the entire page maybe devoted to floats with no text on the page at all
     25
     26\lefthyphenmin=4
     27\righthyphenmin=4
     28
    2529\usepackage{pslatex}                            % reduce size of san serif font
     30
     31\usepackage[ignoredisplayed]{enumitem}  % do not affect trivlist
     32\setlist{labelsep=1ex}% global
     33\setlist[itemize]{topsep=0.5ex,parsep=0.25ex,itemsep=0.25ex,listparindent=\parindent,leftmargin=\parindent}% global
     34\setlist[itemize,1]{label=\textbullet}% local
     35%\renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
     36\setlist[enumerate]{listparindent=\parindent}% global
     37\setlist[enumerate,2]{leftmargin=\parindent,labelsep=*,align=parleft,label=\alph*.}% local
     38\setlist[description]{listparindent=\parindent,leftmargin=\parindent,labelsep=*}
    2639
    2740% Names used in the document.
     
    2942\newcommand{\CFA}{C$\mathbf\forall$\xspace}              % set language symbolic name
    3043\newcommand{\CFL}{Cforall\xspace}                        % set language text name
    31 \newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
     44\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
    3245\def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)
    3346
     
    3548
    3649\makeatletter
    37 % parindent is relative, i.e., toggled on/off in environments like itemize,
    38 % so store the value for use rather than use \parident directly.
    39 \newlength{\parindentlength}
    40 \setlength{\parindentlength}{\parindent}
     50% parindent is relative, i.e., toggled on/off in environments like itemize, so store the value for
     51% use rather than use \parident directly.
     52\newlength{\parindentlnth}
     53\setlength{\parindentlnth}{\parindent}
    4154
    4255% allow escape sequence in lstinline
    4356%\usepackage{etoolbox}
    4457%\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
    45 
    46 % make fontsize "small" slightly larger, specifically for san serif (helvetica) in program code
    47 %\renewcommand\small{%
    48 %   \@setfontsize\small{8.5}{11}%
    49 %   \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt
    50 %   \abovedisplayshortskip \z@ \@plus 2pt
    51 %   \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt
    52 %   \def\@listi{\leftmargin\leftmargini
    53 %               \topsep 4pt \@plus 2pt \@minus 2pt
    54 %               \parsep 2pt \@pluspt \@minuspt
    55 %               \itemsep \parsep}%
    56 %   \belowdisplayskip \abovedisplayskip
    57 %}
    5858
    5959\usepackage{pslatex}                                                                    % reduce size of san serif font
     
    9191\newcommand{\see}[1]{\emph{see} #1}
    9292
    93 % reduce bullet size and spacing for "itemize" macro
    94 \renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
    95 \renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}}
    96 
    9793% Define some commands that produce formatted index entries suitable for cross-references.
    9894% ``\spec'' produces entries for specifications of entities.  ``\impl'' produces entries for their
     
    140136}% quote2
    141137\newenvironment{rationale}{%
    142   \begin{quotation}\noindent$\Box$\enspace
     138  \begin{quote2}\noindent$\Box$\enspace
    143139}{%
    144   \hfill\enspace$\Box$\end{quotation}
     140  \hfill\enspace$\Box$\end{quote2}
    145141}%
    146142
     
    154150
    155151% BNF macros
    156 \def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
    157 \let\endsyntax=\endtrivlist
    158 \newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
    159 \newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
    160 \newcommand{\oldlhs}[1]{\emph{#1: \dots}\index{#1@{\emph{#1}}|italic}}
    161 \newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
     152\newenvironment{syntax}{
     153\paragraph{Syntax}
     154\begin{quote2}
     155\begin{description}[noitemsep,leftmargin=\parindentlnth]
     156}{
     157\end{description}
     158\end{quote2}
     159}
     160% \def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
     161%\let\endsyntax=\endtrivlist
     162\newcommand{\lhs}[1]{\item[\emph{#1:}\index{#1@{\emph{#1}}|italic}]~\ignorespaces}
     163\newcommand{\oldlhs}[1]{\item[\emph{#1:}\index{#1@{\emph{#1}}|italic}~\dots]~}
     164\newcommand{\rhs}{\hfil\newline}
     165\newcommand{\nonterm}[1]{\emph{#1}\index{#1@{\emph{#1}}|italic}}
    162166\newcommand{\opt}{$_{opt}$\ }
    163167
     
    204208stringstyle=\tt,
    205209tabsize=4,
    206 xleftmargin=\parindentlength,
     210xleftmargin=\parindentlnth,
    207211extendedchars=true,
    208212escapechar=§,
  • doc/bibliography/cfa.bib

    r1da317b r9724df0  
    29242924
    29252925@unpublished{Bilson,
    2926         keywords = {generic programming, generics, polymorphism},
    2927         contributor {a3moss@plg},
    2928         author = {Richard C. Bilson and Glen Ditchfield and Peter A. Buhr},
    2929         title = {Generic Programming with Inferred Models},
     2926    keywords    = {generic programming, generics, polymorphism},
     2927    contributor = {a3moss@plg},
     2928    author      = {Richard C. Bilson and Glen Ditchfield and Peter A. Buhr},
     2929    title       = {Generic Programming with Inferred Models},
    29302930}
    29312931
  • doc/refrat/Makefile

    r1da317b r9724df0  
    11## Define the appropriate configuration variables.
    22
    3 TeXLIB = .:../bibliography/:../LaTeXmacros/:
     3TeXLIB = .:../LaTeXmacros:../LaTeXmacros/listings:../LaTeXmacros/enumitem:../bibliography/:
    44LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex
    55BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
  • doc/refrat/refrat.tex

    r1da317b r9724df0  
    1111%% Created On       : Wed Apr  6 14:52:25 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jun  3 09:43:48 2016
    14 %% Update Count     : 66
     13%% Last Modified On : Sat Jun 18 19:21:30 2016
     14%% Update Count     : 74
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    1818
    1919% inline code ©...© (copyright symbol) emacs: C-q M-)
    20 % red highlighting ®...® (registered trademark sumbol) emacs: C-q M-.
    21 % latex escape §...§ (section symbol) emacs: C-q M-'
     20% red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
     21% blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
     22% green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
     23% LaTex escape §...§ (section symbol) emacs: C-q M-'
    2224% keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
    2325% math escape $...$ (dollar symbol)
     
    3234\usepackage{fullpage,times,comment}
    3335\usepackage{epic,eepic}
    34 \usepackage{upquote}                                                                    % switch curled `' to straight `'
     36\usepackage{upquote}                                                                    % switch curled `'" to straight
    3537\usepackage{xspace}
    3638\usepackage{varioref}                                                                   % extended references
    3739\usepackage{listings}                                                                   % format program code
    38 \usepackage{footmisc}                                                                   % support label/reference in footnote
     40\usepackage[flushmargin]{footmisc}                                              % support label/reference in footnote
    3941\usepackage{latexsym}                                   % \Box glyph
    4042\usepackage{mathptmx}                                   % better math font with "times"
     43\usepackage[usenames]{color}
    4144\usepackage[pagewise]{lineno}
    4245\renewcommand{\linenumberfont}{\scriptsize\sffamily}
     46\input{common}                                          % bespoke macros used in the document
    4347\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    4448\usepackage{breakurl}
     
    4751%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4852
    49 % Bespoke macros used in the document.
    50 \input{common}
    51 
    52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    53 
    5453% Names used in the document.
    5554
    5655\newcommand{\Version}{1.0.0}
     56
     57\newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}}
     58\newcommand{\Emph}[2][red]{{\color{#1}\textbf{\emph{#2}}}}
     59\newcommand{\R}[1]{\Textbf{#1}}
     60\newcommand{\B}[1]{{\Textbf[blue]{#1}}}
     61\newcommand{\G}[1]{{\Textbf[OliveGreen]{#1}}}
    5762
    5863%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    7681}% author
    7782\date{
    78 DRAFT\\\today
     83DRAFT \\
     84\today
    7985}% date
    8086
     
    390396\end{itemize}
    391397
     398
    392399\section{Lexical elements}
     400
     401
    393402\subsection{Keywords}
     403
    394404\begin{syntax}
    395405\oldlhs{keyword}
    396         \rhs ©forall©
    397         \rhs ©lvalue©
    398         \rhs ©trait©
    399         \rhs ©dtype©
    400         \rhs ©ftype©
    401         \rhs ©otype©
     406\rhs ©forall©
     407\rhs ©lvalue©
     408\rhs ©trait©
     409\rhs ©dtype©
     410\rhs ©ftype©
     411\rhs ©otype©
    402412\end{syntax}
    403413
     
    11071117\begin{syntax}
    11081118\lhs{unary-expression}
    1109 \rhs \nonterm{postfix-expression}
    1110 \rhs ©++© \nonterm{unary-expression}
    1111 \rhs ©--© \nonterm{unary-expression}
    1112 \rhs \nonterm{unary-operator} \nonterm{cast-expression}
    1113 \rhs ©sizeof© \nonterm{unary-expression}
    1114 \rhs ©sizeof© ©(© \nonterm{type-name} ©)©
    1115 \lhs{unary-operator} one of \rhs ©&© ©*© ©+© ©-© ©~© ©!©
     1119        \rhs \nonterm{postfix-expression}
     1120        \rhs ©++© \nonterm{unary-expression}
     1121        \rhs ©--© \nonterm{unary-expression}
     1122        \rhs \nonterm{unary-operator} \nonterm{cast-expression}
     1123        \rhs ©sizeof© \nonterm{unary-expression}
     1124        \rhs ©sizeof© ©(© \nonterm{type-name} ©)©
     1125\lhs{unary-operator} one of
     1126        \rhs ©&© ©*© ©+© ©-© ©~© ©!©
    11161127\end{syntax}
    11171128
  • doc/user/Makefile

    r1da317b r9724df0  
    11## Define the appropriate configuration variables.
    22
    3 TeXLIB = .:../bibliography/:../LaTeXmacros/:
     3TeXLIB = .:../LaTeXmacros:../LaTeXmacros/listings:../LaTeXmacros/enumitem:../bibliography/:
    44LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex
    55BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
  • doc/user/user.tex

    r1da317b r9724df0  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jun 10 16:38:22 2016
    14 %% Update Count     : 394
     13%% Last Modified On : Mon Jun 20 10:47:22 2016
     14%% Update Count     : 575
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    2121% blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
    2222% green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
    23 % Latex escape §...§ (section symbol) emacs: C-q M-'
     23% LaTex escape §...§ (section symbol) emacs: C-q M-'
    2424% keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
    2525% math escape $...$ (dollar symbol)
    2626
    2727\documentclass[twoside,11pt]{article}
     28
    2829%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2930
     
    3435\usepackage{fullpage,times,comment}
    3536\usepackage{epic,eepic}
    36 \usepackage{upquote}                                                                    % switch curled `'" to straight `'"
     37\usepackage{upquote}                                                                    % switch curled `'" to straight
    3738\usepackage{xspace}
    3839\usepackage{varioref}                                                                   % extended references
     
    4950\renewcommand{\UrlFont}{\small\sf}
    5051
     52\makeatletter
     53\renewcommand{\pagestyle}[1]{
     54  \@ifundefined{ps@#1}%
     55    \undefinedpagestyle
     56    {\def\@tempa{#1}\def\@tempb{headings}\def\@tempc{myheadings}%
     57     \ifx\@tempa\@tempb\setlength{\topmargin}{-0.25in}\setlength{\headsep}{0.25in}%
     58     \else\ifx\@tempa\@tempc\setlength{\topmargin}{-0.25in}\setlength{\headsep}{0.25in}\fi\fi%
     59     \@nameuse{ps@#1}}}% pagestyle
     60\makeatother
     61
     62
     63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     64
    5165% Names used in the document.
    5266
     
    6074\newcommand{\G}[1]{{\Textbf[OliveGreen]{#1}}}
    6175
     76\newsavebox{\LstBox}
     77
    6278%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6379
     
    6783
    6884%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    69 
    70 \begin{document}
    71 \pagestyle{headings}
    72 \linenumbers                                            % comment out to turn off line numbering
    7385
    7486\title{\Huge
     
    7789Version 1.0                                                     \\
    7890\vspace*{0.25in}
    79 \huge``describe not prescribe''         \\
     91\huge``describe not prescribe''
    8092\vspace*{1in}
    8193}% title
     94
    8295\author{\huge
    83 Peter A. Buhr and ...                           \\
     96Peter A. Buhr and ...
    8497}% author
     98
    8599\date{
    86 DRAFT \\
    87 \today
     100DRAFT \\ \today
    88101}% date
    89102
     103%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     104
     105\begin{document}
     106\pagestyle{headings}
    90107\pagenumbering{roman}
    91 \pagestyle{plain}
     108\linenumbers                                            % comment out to turn off line numbering
    92109
    93110\maketitle
     
    107124
    108125\clearpage
     126\markright{\CFA User Manual}
    109127\pagenumbering{arabic}
    110128
     
    471489\end{quote2}
    472490
    473 Unsupported are K\&R C declarations where the base type defaults to ©int©, if no type is specified\footnote{
    474 At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and type name~\cite[\S~6.7.2(2)]{C11}},
     491Unsupported are K\&R C declarations where the base type defaults to ©int©, if no type is specified,\footnote{
     492At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and type name~\cite[\S~6.7.2(2)]{C11}}
    475493e.g.:
    476494\begin{lstlisting}
     
    485503Clearly, both styles need to be supported for some time due to existing C-style header-files, particularly for UNIX systems.
    486504
     505
     506\section{Reference Pointers}
     507
     508Program variables are implicit pointers to memory locations generated by the compiler and automatically dereferenced, as in:
     509\begin{quote2}
     510\begin{tabular}{@{}l|l@{}}
     511\multicolumn{1}{c|}{Variables} & \multicolumn{1}{c}{Compiler generated addresses (100, 104) and dereferencing} \\
     512\hline
     513\begin{lstlisting}
     514int x, y;
     515x = 3;
     516y = x;
     517\end{lstlisting}
     518&
     519\begin{lstlisting}
     520int * const x = (int *)100, * const y = (int *)104;
     521*x = 3;         // implicit dereference
     522*y = *x;
     523\end{lstlisting}
     524\end{tabular}
     525\end{quote2}
     526A variable name only points to one location during its lifetime, i.e., it is a \Index{non-mutable} pointer.
     527For example, the variables ©x© and ©y© are constant pointers.
     528Variable addresses are usually not stored in memory and loaded before dereferencing;
     529instead, variable addresses are stored in instructions, so an instruction fetch implicitly gets the variable's address.
     530\begin{quote2}
     531\begin{tabular}{@{}l|l@{}}
     532\begin{lstlisting}
     533x = x + 1
     534&x = *(&x) + 1
     535(100) = *(100) + 1
     536\end{lstlisting}
     537&
     538\begin{lstlisting}
     539ld              r1,(100)                        // address of x
     540add             r1,1
     541st              r1,(100)                        // address of x
     542\end{lstlisting}
     543\end{tabular}
     544\end{quote2}
     545Finally, the non-mutable nature of variables and the fact that there is no storage for a variable address means pointer assignment is impossible.
     546Therefore, the expression ©x = y© only has one meaning, ©*x = *y©, i.e., copy the variable values, so explicitly writing the dereferences is unnecessary even though it occurs implicitly as part of instruction decoding.
     547
     548A variable name is generalized by a \newterm{pointer}, which is a mutable pointer variable that can point to more than one memory location during its life-time (like an integer variable versus a literal).
     549Hence, a pointer occupies memory to store its current address, and the pointer's value is loaded by dereferencing, e.g.:
     550\begin{lstlisting}
     551int x, y, z, ®*® p1, ®*® p2;
     552p1 = ®&®x;                                      // p1 points to x
     553p2 = p1;                                        // p2 also points to x
     554p1 = ®&®y;                                      // p1 points to y
     555p2 = p1 + 1;                            // p2 points to z, pointer arithmetic
     556\end{lstlisting}
     557In many cases, a pointer name is anonymous (dynamically computed), so it cannot be stored directly in an instruction like a variable name.
     558
     559Pointers have a duality: an address in memory or the value at that address.
     560In many cases, the compiler can infer which of these operations are needed:
     561\begin{lstlisting}
     562p2 = p1 + x;                            // compiler infers *p2 = *p1 + x;
     563\end{lstlisting}
     564because adding the integer value of ©x© to the address of ©p1© and storing the resulting address into ©p2© is an unlikely operation.
     565Algol68~\cite{Algol68} inferences pointer dereferencing to select the best meaning for each pointer usage.
     566However, there are ambiguous cases, especially when pointer arithmetic is possible, as in C:
     567\begin{lstlisting}
     568p1 = p2;                                        // p1 = p2 or *p1 = *p2
     569p1 = p1 + 1;                            // p1 = p1 + 1 or *p1 = *p1 + 1
     570\end{lstlisting}
     571
     572Most programming languages pick a default operation and supply an explicit operation to resolve the pointer-duality ambiguity.
     573In C, the default operation for pointers is manipulate the pointer value and the pointed-to value is explicitly accessed by dereferencing ©*©.
     574\begin{lstlisting}
     575p1 = p2;                                        // pointer value assignment
     576*p1 = *p1 + 1;                          // pointed-to value assignment/operation
     577\end{lstlisting}
     578which works well for low-level memory management, such as ©malloc©/©free©, where manipulation of addresses in the primary operation, and data is only occasionally accessed.
     579
     580However, in the majority of pointer usages, the pointed-to value is required rather than the pointer address.
     581\begin{lstlisting}
     582*p2 = ((*p1 + *p2) * (*p2 - *p1)) / (*p1 - *p2);
     583\end{lstlisting}
     584And, it is tedious and error prone to explicitly write the dereferencing, especially when pointer arithmetic with integer values is allowed.
     585It is better to have the compiler generate the dereferencing:
     586\begin{lstlisting}
     587p2 = ((p1 + p2) * (p2 - p1)) / (p1 - p2);
     588\end{lstlisting}
     589
     590To provide this capability, it is necessary to switch the default operation to resolve the pointer-duality ambiguity, which requires a new kind of pointer called a \newterm{reference} pointer.
     591\begin{lstlisting}
     592int x, y, z, ®&® r1, ®&® r2;    // & denotes reference pointer
     593r1 ®:=® &x;                                     // r1 points to x
     594r2 ®:=® &r1;                                    // r2 also points to x
     595r1 ®:=® &y;                                     // r1 points to y
     596r2 ®:=® &r1 + 1;                                // r2 points to z
     597r2 = ((r1 + r2) * (r2 - r1)) / (r1 - r2); // implicit dereferencing
     598\end{lstlisting}
     599Hence, a reference pointer behaves like a variable name for the current variable it is pointing-to, so dereferencing a reference pointer returns the address of its pointed-to value, i.e., the address in the reference pointer.
     600Notice, the explicit operator ©:=© to denote pointer assignment to a reference pointer to support both aspects of pointer duality.
     601Note, \CC deals with the pointer duality by making a reference pointer a constant (©const©), like a plain variable, so there is no reference assignment.
     602
     603Like pointers, it is possible to use ©const© qualifiers with a reference:
     604\begin{lstlisting}
     605const int cx = 5;                       // cannot change cx;
     606const int & r3 = &cx;           // cannot change what r3 is pointing to
     607r3 ®:=® &cx;                                    // can change r3
     608r3 = 7;                                         // error, cannot change cx
     609int & const r4 = &x;            // must be initialized, §\CC§ reference
     610r4 ®:=® &x;                                     // error, cannot change r4
     611const int & const r5 = &cx;     // must be initialized, §\CC§ reference
     612r5 = 7;                                         // error, cannot change cx
     613r5 ®:=® &cx;                                    // error, cannot change r5
     614\end{lstlisting}
     615Note, for type ©& const©, there is no pointer assignment, so ©r4 := &x© is disallowed, and the pointer value cannot be ©0©.
     616Since there is only one meaning for ©r4 = x©, which is to change the value of the variable pointed to by ©r4©, therefore:
     617\begin{itemize}
     618\item
     619it in impossible to take the address of ©r4© as it always means the address of what ©r4© is pointing to.
     620\item
     621the dereference at initialization is optional because there can only be one
     622\begin{lrbox}{\LstBox}%
     623\footnotesize%
     624\begin{lstlisting}%
     625void f( int p ) {...}
     626void (*fp)( int ) = &f;         // equivalent initialization
     627void (*fp)( int ) = f;          // missing dereference allowed
     628\end{lstlisting}%
     629\end{lrbox}%
     630meaning.\footnote{
     631This case is similar to initializing a routine pointer, where the routine constant should be dereferenced.
     632\newline
     633\usebox{\LstBox}
     634}% footnote
     635\begin{lstlisting}
     636int & const r4 = &x;            // equivalent initialization
     637int & const r4 = x;                     // missing dereference allowed
     638\end{lstlisting}
     639\end{itemize}
     640Similarly, when a ©const© reference is used for a parameters type, the call-site argument does not require a reference.
     641\begin{lstlisting}
     642void f( int & ri, int & const cri );
     643f( &x, x );                                     // reference not required for second argument
     644\end{lstlisting}
     645Within routine ©f©, it is possible to change an argument by changing the corresponding parameter, and parameter ©ri© can be locally reassigned within ©f©.
     646
     647Finally, when a reference parameter has a ©const© value, it is possible to pass literals and expressions.
     648\begin{lstlisting}
     649void g( const int & ri, const int & const cri );
     650f( &3, 3 );
     651f( &(x + y), x + y );
     652\end{lstlisting}
     653At the call site, the compiler implicitly creates the necessary temporary that is subsequently pointed to by the reference parameter.
     654Hence, changing the parameter only changes the temporary at the call site.
     655For the non-©const© parameter, requiring the reference on the literal or expression makes it clear that nothing is changing at the call site and allows the call to proceed, where other languages require the programmer to explicitly create the temporary for the argument.
    487656
    488657\section{Type Operators}
     
    808977\subsection{Type Nesting}
    809978
    810 \CFA allows \Index{type nesting}, and type qualification of the nested types, where as C hoists\index{type hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
    811 \begin{quote2}
     979\CFA allows \Index{type nesting}, and type qualification of the nested types (see \VRef[Figure]{f:TypeNestingQualification}), where as C hoists\index{type hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
     980\begin{figure}
    812981\begin{tabular}{@{}l@{\hspace{3em}}l|l@{}}
    813982\multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c}{\textbf{C Implicit Hoisting}}      & \multicolumn{1}{|c}{\textbf{\CFA}}    \\
     
    8701039\end{lstlisting}
    8711040\end{tabular}
    872 \end{quote2}
     1041\caption{Type Nesting / Qualification}
     1042\label{f:TypeNestingQualification}
     1043\end{figure}
    8731044In the left example in C, types ©C©, ©U© and ©T© are implicitly hoisted outside of type ©S© into the containing block scope.
    8741045In the right example in \CFA, the types are not hoisted and accessed using the field-selection operator ``©.©'' for type qualification, as does Java, rather than the \CC type-selection operator ``©::©''.
Note: See TracChangeset for help on using the changeset viewer.