Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    re55ca05 r53ba273  
    1111%% Created On       : Wed Apr  6 14:52:25 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Apr  8 18:32:07 2016
    14 %% Update Count     : 6
     13%% Last Modified On : Wed Apr  6 21:57:27 2016
     14%% Update Count     : 2
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    3737
     38% Names used in the document.
     39
     40\newcommand{\CFA}{C$\mathbf\forall$\xspace}     % set language symbolic name
     41\newcommand{\CFL}{Cforall\xspace}               % set language text name
     42\newcommand{\CC}{C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name
     43\def\c11{ISO/IEC C} % C11 name (cannot have numbers in latex command name)
     44
     45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     46
    3847% Bespoke macros used in the document.
    39 \input{common}
     48
     49\makeatletter
     50% allow escape sequence in lstinline
     51%\usepackage{etoolbox}
     52%\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
     53
     54\renewcommand\small{%
     55   \@setfontsize\small{8.5}{11}%
     56   \abovedisplayskip 8.5pt \@plus 3pt \@minus 4pt
     57   \abovedisplayshortskip \z@ \@plus 2pt
     58   \belowdisplayshortskip 4pt \@plus 2pt \@minus 2pt
     59   \def\@listi{\leftmargin\leftmargini
     60               \topsep 4pt \@plus 2pt \@minus 2pt
     61               \parsep 2pt \@pluspt \@minuspt
     62               \itemsep \parsep}%
     63   \belowdisplayskip \abovedisplayskip
     64}
     65\usepackage{relsize}            % must be after change to small
     66
     67\renewcommand{\labelitemi}{{\raisebox{0.25ex}{\footnotesize$\bullet$}}}
     68\renewenvironment{itemize}{\begin{list}{\labelitemi}{\topsep=5pt\itemsep=5pt\parsep=0pt}}{\end{list}}
     69
     70%  Reduce size of chapter/section titles
     71\def\@makechapterhead#1{%
     72  \vspace*{50\p@}%
     73  {\parindent \z@ \raggedright \normalfont
     74    \ifnum \c@secnumdepth >\m@ne
     75        \large\bfseries \@chapapp\space \thechapter
     76        \par\nobreak
     77        \vskip 5\p@
     78    \fi
     79    \interlinepenalty\@M
     80    \Large \bfseries #1\par\nobreak
     81    \vskip 50\p@
     82  }}
     83\def\@makeschapterhead#1{%
     84  \vspace*{50\p@}%
     85  {\parindent \z@ \raggedright
     86    \normalfont
     87    \interlinepenalty\@M
     88    \Large \bfseries  #1\par\nobreak
     89    \vskip 50\p@
     90  }}
     91\renewcommand\section{\@startsection{section}{1}{\z@}{-3.0ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\large\bfseries}}
     92\renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
     93\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}{-2.5ex \@plus -1ex \@minus -.2ex}{1.0ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
     94\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
     95
     96% index macros
     97\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
     98\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     99\newcommand{\see}[1]{\emph{see} #1}
     100
     101% Define some commands that produce formatted index entries suitable for cross-references.
     102% ``\spec'' produces entries for specifications of entities.  ``\impl'' produces entries for their
     103% implementations, and ``\use'' for their uses.
     104
     105%  \newcommand{\bold}[1]{{\bf #1}}
     106%  \def\spec{\@bsphack\begingroup
     107%             \def\protect##1{\string##1\space}\@sanitize
     108%             \@wrxref{|bold}}
     109\def\impl{\@bsphack\begingroup
     110          \def\protect##1{\string##1\space}\@sanitize
     111          \@wrxref{|definition}}
     112\newcommand{\indexcode}[1]{{\lstinline$#1$}}
     113\def\use{\@bsphack\begingroup
     114         \def\protect##1{\string##1\space}\@sanitize
     115         \@wrxref{|hyperpage}}
     116\def\@wrxref#1#2{\let\thepage\relax
     117    \xdef\@gtempa{\write\@indexfile{\string
     118    \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa
     119    \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
     120%\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
     121%\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
     122
     123% inline text and lowercase index: \Index{inline and lowercase index text}
     124% inline text and as-in index: \Index[as-is index text]{inline text}
     125% inline text but index with different as-is text: \Index[index text]{inline text}
     126\newcommand{\Index}{\@ifstar\@sIndex\@Index}
     127\newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
     128\newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
     129\makeatother
     130
     131% blocks and titles
     132\newenvironment{rationale}{%
     133  \begin{quotation}\noindent$\Box$\enspace
     134}{%
     135  \hfill\enspace$\Box$\end{quotation}
     136}%
     137\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
     138\newcommand{\rewrite}{\(\Rightarrow\)}
     139\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
     140\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
     141\newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
     142\newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
     143\newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
     144
     145% BNF macros
     146\def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
     147\let\endsyntax=\endtrivlist
     148\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
     149\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
     150\newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}}
     151\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
     152\newcommand{\opt}{$_{opt}$\ }
     153
     154% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
     155% \VRef{label} => Section 2.7, \VPageref{label} => page 17
     156% \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
     157\renewcommand{\reftextfaceafter}{\unskip}
     158\renewcommand{\reftextfacebefore}{\unskip}
     159\renewcommand{\reftextafter}{\unskip}
     160\renewcommand{\reftextbefore}{\unskip}
     161\renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
     162\renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
     163\newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
     164\newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
     165
     166% CFA based on ANSI C
     167\lstdefinelanguage{CFA}[ANSI]{C}%
     168{morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
     169    _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__,
     170        fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,otype,restrict,_Static_assert,
     171        _Thread_local,throw,throwResume,trait,try,typeof,__typeof,__typeof__,},
     172}%
     173
     174\lstset{
     175language=CFA,
     176columns=flexible,
     177basicstyle=\sf\relsize{-1},
     178tabsize=4,
     179xleftmargin=\parindent,
     180escapechar=@,
     181mathescape=true,
     182keepspaces=true,
     183showstringspaces=false,
     184showlines=true,
     185aboveskip=6pt,
     186belowskip=4pt,
     187}%
     188
     189\makeatletter
     190% replace/adjust listings characters that look bad in sanserif
     191\lst@CCPutMacro
     192\lst@ProcessOther{"22}{\lst@ttfamily{"}{\raisebox{0.3ex}{\ttfamily\upshape "}}} % replace double quote
     193\lst@ProcessOther{"27}{\lst@ttfamily{'}{\raisebox{0.3ex}{\ttfamily\upshape '\hspace*{-2pt}}}} % replace single quote
     194\lst@ProcessOther{"2D}{\lst@ttfamily{-}{\ttfamily\upshape -}} % replace minus
     195\lst@ProcessOther{"3C}{\lst@ttfamily{<}{\texttt{<}}} % replace less than
     196\lst@ProcessOther{"3E}{\lst@ttfamily{<}{\texttt{>}}} % replace greater than
     197\lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex
     198\lst@ProcessOther{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore
     199\lst@ProcessOther{"60}{\lst@ttfamily{`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}} % replace backquote
     200\lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde
     201%\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde
     202\@empty\z@\@empty
     203\makeatother
    40204
    41205\setcounter{secnumdepth}{3}     % number subsubsections
     
    84248
    85249This 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++}.
     250It makes frequent reference to the {\c11} standard \cite{ANS:C11}, and occasionally compares \CFA to {\CC} \cite{c++}.
    87251
    88252The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering differs).
     
    578742
    579743There are two notable differences between \CFA's overload resolution rules and the rules for
    580 {\CC} defined in \cite{C++}.
     744{\CC} defined in \cite{c++}.
    581745First, the result type of a function plays a role.
    582746In {\CC}, a function call must be completely resolved based on the arguments to the call in most circumstances.
     
    32423406\begin{itemize}
    32433407\item
    3244 Inside a Clu cluster \cite{CLU}, the declaration of an instance states which view applies.
     3408Inside a Clu cluster \cite{clu}, the declaration of an instance states which view applies.
    32453409Two primitives called \lstinline$up$ and \lstinline$down$ can be used to convert between the views.
    32463410\item
    3247 The Simula class \cite{SIMULA87} is essentially a record type.
     3411The Simula class \cite{Simula87} is essentially a record type.
    32483412Since 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.
    32493413In {\CC}
    3250 \cite{C++}, operations on class instances include assignment and ``\lstinline$&$'', which can be overloaded.
     3414\cite{c++}, operations on class instances include assignment and ``\lstinline$&$'', which can be overloaded.
    32513415A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used.
    32523416\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.
     3417An 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.
    32543418The derived subprograms are clones of the existing subprograms with the old type replaced by the derived type.
    32553419Literals and aggregates of the old type are also cloned.
     
    38644028
    38654029\bibliographystyle{plain}
    3866 \bibliography{cfa}
     4030\bibliography{refrat}
    38674031
    38684032
Note: See TracChangeset for help on using the changeset viewer.