Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    re55ca05 ra752883  
    1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2 %%
    3 %% Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    4 %%
    5 %% The contents of this file are covered under the licence agreement in the
    6 %% file "LICENCE" distributed with Cforall.
    7 %%
    8 %% refrat.tex --
    9 %%
    10 %% Author           : Peter A. Buhr
    11 %% Created On       : Wed Apr  6 14:52:25 2016
    12 %% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Apr  8 18:32:07 2016
    14 %% Update Count     : 6
    15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    16 
    171% requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
    182
     
    215
    226% Latex packages used in the document.
     7
    238\usepackage{fullpage,times}
    249\usepackage{xspace}
     
    3621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    3722
     23% Names used in the document.
     24
     25\newcommand{\CFA}{C$\forall$\xspace}    % set language symbolic name
     26\newcommand{\CFL}{Cforall\xspace}               % set language text name
     27\newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
     28\def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)
     29
     30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     31
    3832% Bespoke macros used in the document.
    39 \input{common}
     33
     34\makeatletter
     35% allow escape sequence in lstinline
     36%\usepackage{etoolbox}
     37%\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
     38
     39\renewcommand\small{%
     40   \@setfontsize\small{8.5}{11}%
     41   \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt
     42   \abovedisplayshortskip \z@ \@plus 2pt
     43   \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt
     44   \def\@listi{\leftmargin\leftmargini
     45               \topsep 4pt \@plus 2pt \@minus 2pt
     46               \parsep 2pt \@pluspt \@minuspt
     47               \itemsep \parsep}%
     48   \belowdisplayskip \abovedisplayskip
     49}
     50\usepackage{relsize}            % must be after change to small
     51
     52\renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
     53\renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}}
     54
     55%  Reduce size of chapter/section titles
     56\def\@makechapterhead#1{%
     57  \vspace*{50\p@}%
     58  {\parindent \z@ \raggedright \normalfont
     59    \ifnum \c@secnumdepth >\m@ne
     60        \large\bfseries \@chapapp\space \thechapter
     61        \par\nobreak
     62        \vskip 5\p@
     63    \fi
     64    \interlinepenalty\@M
     65    \Large \bfseries #1\par\nobreak
     66    \vskip 50\p@
     67  }}
     68\def\@makeschapterhead#1{%
     69  \vspace*{50\p@}%
     70  {\parindent \z@ \raggedright
     71    \normalfont
     72    \interlinepenalty\@M
     73    \Large \bfseries  #1\par\nobreak
     74    \vskip 50\p@
     75  }}
     76\renewcommand\section{\@startsection{section}{1}{\z@}{-3.0ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\large\bfseries}}
     77\renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
     78\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
     79\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
     80
     81% index macros
     82\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
     83\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     84\newcommand{\see}[1]{\emph{see} #1}
     85
     86% Define some commands that produce formatted index entries suitable for cross-references.
     87% ``\spec'' produces entries for specifications of entities.  ``\impl'' produces entries for their
     88% implementations, and ``\use'' for their uses.
     89
     90%  \newcommand{\bold}[1]{{\bf #1}}
     91%  \def\spec{\@bsphack\begingroup
     92%             \def\protect##1{\string##1\space}\@sanitize
     93%             \@wrxref{|bold}}
     94\def\impl{\@bsphack\begingroup
     95          \def\protect##1{\string##1\space}\@sanitize
     96          \@wrxref{|definition}}
     97\newcommand{\indexcode}[1]{{\lstinline$#1$}}
     98\def\use{\@bsphack\begingroup
     99         \def\protect##1{\string##1\space}\@sanitize
     100         \@wrxref{|hyperpage}}
     101\def\@wrxref#1#2{\let\thepage\relax
     102    \xdef\@gtempa{\write\@indexfile{\string
     103    \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa
     104    \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
     105%\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
     106%\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
     107
     108% inline text and lowercase index: \Index{inline and lowercase index text}
     109% inline text and as-in index: \Index[as-is index text]{inline text}
     110% inline text but index with different as-is text: \Index[index text]{inline text}
     111\newcommand{\Index}{\@ifstar\@sIndex\@Index}
     112\newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
     113\newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
     114\makeatother
     115
     116% blocks and titles
     117\newenvironment{rationale}{%
     118  \begin{quotation}\noindent$\Box$\enspace
     119}{%
     120  \hfill\enspace$\Box$\end{quotation}
     121}%
     122\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
     123\newcommand{\rewrite}{\(\Rightarrow\)}
     124\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
     125\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
     126\newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
     127\newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
     128\newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
     129
     130% BNF macros
     131\def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
     132\let\endsyntax=\endtrivlist
     133\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
     134\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
     135\newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}}
     136\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
     137\newcommand{\opt}{$_{opt}$\ }
     138
     139% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
     140% \VRef{label} => Section 2.7, \VPageref{label} => page 17
     141% \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
     142\renewcommand{\reftextfaceafter}{\unskip}
     143\renewcommand{\reftextfacebefore}{\unskip}
     144\renewcommand{\reftextafter}{\unskip}
     145\renewcommand{\reftextbefore}{\unskip}
     146\renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
     147\renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
     148\newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
     149\newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
     150
     151% CFA based on ANSI C
     152\lstdefinelanguage{CFA}[ANSI]{C}%
     153{morekeywords={asm,_Alignas,_Alignof,_At,_Atomic,_Bool,catch,catchResume,choose,_Complex,trait,disable,dtype,enable,
     154        fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,lvalue,_Noreturn,otype,restrict,_Static_assert,
     155        _Thread_local,throw,throwResume,try,},
     156}%
     157
     158\lstset{
     159language=CFA,
     160columns=flexible,
     161basicstyle=\sf\relsize{-1},
     162tabsize=4,
     163xleftmargin=\parindent,
     164escapechar=@,
     165keepspaces=true,
     166showstringspaces=false,
     167showlines=true,
     168}%
     169
     170\makeatletter
     171% replace/adjust listings characters that look bad in sanserif
     172\lst@CCPutMacro
     173\lst@ProcessOther{"2D}{\lst@ttfamily{-{}}{{\ttfamily\upshape -}}} % replace minus
     174\lst@ProcessOther{"3C}{\lst@ttfamily{<}{\texttt{<}}} % replace less than
     175\lst@ProcessOther{"3E}{\lst@ttfamily{<}{\texttt{>}}} % replace greater than
     176\lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex
     177\lst@ProcessLetter{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore
     178\lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde
     179%\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde
     180\@empty\z@\@empty
     181\makeatother
    40182
    41183\setcounter{secnumdepth}{3}     % number subsubsections
     
    84226
    85227This document is a reference manual and rationale for \CFA, a polymorphic extension of the C programming language.
    86 It makes frequent reference to the {\c11} standard \cite{C11}, and occasionally compares \CFA to {\CC} \cite{C++}.
     228It makes frequent reference to the {\c11} standard \cite{ANS:C11}, and occasionally compares \CFA to {\CC} \cite{c++}.
    87229
    88230The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering differs).
     
    578720
    579721There are two notable differences between \CFA's overload resolution rules and the rules for
    580 {\CC} defined in \cite{C++}.
     722{\CC} defined in \cite{c++}.
    581723First, the result type of a function plays a role.
    582724In {\CC}, a function call must be completely resolved based on the arguments to the call in most circumstances.
     
    32423384\begin{itemize}
    32433385\item
    3244 Inside a Clu cluster \cite{CLU}, the declaration of an instance states which view applies.
     3386Inside a Clu cluster \cite{clu}, the declaration of an instance states which view applies.
    32453387Two primitives called \lstinline$up$ and \lstinline$down$ can be used to convert between the views.
    32463388\item
    3247 The Simula class \cite{SIMULA87} is essentially a record type.
     3389The Simula class \cite{Simula87} is essentially a record type.
    32483390Since the only operations on a record are member selection and assignment, which can not be overloaded, there is never any ambiguity as to whether the abstraction or the implementation view is being used.
    32493391In {\CC}
    3250 \cite{C++}, operations on class instances include assignment and ``\lstinline$&$'', which can be overloaded.
     3392\cite{c++}, operations on class instances include assignment and ``\lstinline$&$'', which can be overloaded.
    32513393A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used.
    32523394\item
    3253 An Ada derived type definition \cite{Ada} creates a new type from an old type, and also implicitly declares derived subprograms that correspond to the existing subprograms that use the old type as a parameter type or result type.
     3395An Ada derived type definition \cite{ada} creates a new type from an old type, and also implicitly declares derived subprograms that correspond to the existing subprograms that use the old type as a parameter type or result type.
    32543396The derived subprograms are clones of the existing subprograms with the old type replaced by the derived type.
    32553397Literals and aggregates of the old type are also cloned.
     
    37013843``\lstinline$Safe_pointer$ acts like a pointer to \lstinline$int$''.
    37023844\begin{lstlisting}
    3703 trait ptr_to( otype P | pointer( P ), otype T ) {@\impl{ptr_to}@@\use{pointer}@
     3845trait ptr_to( type P | pointer( P ), otype T ) {@\impl{ptr_to}@@\use{pointer}@
    37043846        lvalue T *?( P );
    37053847        lvalue T ?[?]( P, long int );
    37063848};
    3707 trait ptr_to_const( otype P | pointer( P ), otype T ) {@\impl{ptr_to_const}@
     3849trait ptr_to_const( type P | pointer( P ), otype T ) {@\impl{ptr_to_const}@
    37083850        const lvalue T *?( P );
    37093851        const lvalue T ?[?]( P, long int );@\use{pointer}@
    37103852};
    3711 trait ptr_to_volatile( otype P | pointer( P ), otype T ) }@\impl{ptr_to_volatile}@
     3853trait ptr_to_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_volatile}@
    37123854        volatile lvalue T *?( P );
    37133855        volatile lvalue T ?[?]( P, long int );@\use{pointer}@
    37143856};
    3715 trait ptr_to_const_volatile( otype P | pointer( P ), otype T ) }@\impl{ptr_to_const_volatile}@
     3857trait ptr_to_const_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_const_volatile}@
    37163858        const volatile lvalue T *?( P );@\use{pointer}@
    37173859        const volatile lvalue T ?[?]( P, long int );
     
    37233865``\lstinline$ptr_to$'' specifications.
    37243866\begin{lstlisting}
    3725 trait m_l_ptr_to( otype P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to}@ otype T | ptr_to( P, T )@\use{ptr_to}@ {
     3867trait m_l_ptr_to( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to}@ otype T | ptr_to( P, T )@\use{ptr_to}@ {
    37263868        P ?=?( P *, T * );
    37273869        T * ?=?( T **, P );
    37283870};
    3729 trait m_l_ptr_to_const( otype P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_const}@ otype T | ptr_to_const( P, T )@\use{ptr_to_const}@) {
     3871trait m_l_ptr_to_const( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_const}@ otype T | ptr_to_const( P, T )@\use{ptr_to_const}@) {
    37303872        P ?=?( P *, const T * );
    37313873        const T * ?=?( const T **, P );
    37323874};
    3733 trait m_l_ptr_to_volatile( otype P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_volatile}@ otype T | ptr_to_volatile( P, T )) {@\use{ptr_to_volatile}@
     3875trait m_l_ptr_to_volatile( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_volatile}@ otype T | ptr_to_volatile( P, T )) {@\use{ptr_to_volatile}@
    37343876        P ?=?( P *, volatile T * );
    37353877        volatile T * ?=?( volatile T **, P );
    37363878};
    3737 trait m_l_ptr_to_const_volatile( otype P | ptr_to_const_volatile( P ),@\use{ptr_to_const_volatile}@@\impl{m_l_ptr_to_const_volatile}@
    3738                 otype T | m_l_ptr_to_volatile( P, T ) | m_l_ptr_to_const( P )) {@\use{m_l_ptr_to_const}@@\use{m_l_ptr_to_volatile}@
     3879trait m_l_ptr_to_const_volatile( type P | ptr_to_const_volatile( P ),@\use{ptr_to_const_volatile}@@\impl{m_l_ptr_to_const_volatile}@
     3880                type T | m_l_ptr_to_volatile( P, T ) | m_l_ptr_to_const( P )) {@\use{m_l_ptr_to_const}@@\use{m_l_ptr_to_volatile}@
    37393881        P ?=?( P *, const volatile T * );
    37403882        const volatile T * ?=?( const volatile T **, P );
     
    38644006
    38654007\bibliographystyle{plain}
    3866 \bibliography{cfa}
     4008\bibliography{refrat}
    38674009
    38684010
Note: See TracChangeset for help on using the changeset viewer.