Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    rb52d900 rcf16f94  
    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 : Sat Apr  9 10:19:12 2016
    14 %% Update Count     : 8
    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}
     
    2611\usepackage{listings}
    2712\usepackage{comment}
    28 \usepackage{latexsym}                                   % \Box
    29 \usepackage{mathptmx}                                   % better math font with "times"
     13\usepackage{latexsym}                                   % \Box
     14\usepackage{mathptmx}                                   % better math font with "times"
    3015\usepackage[pagewise]{lineno}
    3116\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    3217\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    3318\usepackage{breakurl}
    34 \renewcommand{\UrlFont}{\small\sf}
     19\urlstyle{sf}
    3520
    3621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    3722
     23% Names used in the document.
     24
     25\newcommand{\CFA}{Cforall\xspace}               % set language text name
     26\newcommand{\CFAA}{C$\forall$\xspace}   % set language symbolic 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}
    40 
    41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    42 
    43 \setcounter{secnumdepth}{3}                             % number subsubsections
    44 \setcounter{tocdepth}{3}                                % subsubsections in table of contents
     33
     34\makeatletter
     35% index macros
     36\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
     37\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     38\newcommand{\see}[1]{\emph{see} #1}
     39
     40% Define some commands that produce formatted index entries suitable for cross-references.
     41% ``\spec'' produces entries for specifications of entities.  ``\impl'' produces entries for their
     42% implementations, and ``\use'' for their uses.
     43
     44%  \newcommand{\bold}[1]{{\bf #1}}
     45%  \def\spec{\@bsphack\begingroup
     46%             \def\protect##1{\string##1\space}\@sanitize
     47%             \@wrxref{|bold}}
     48\def\impl{\@bsphack\begingroup
     49          \def\protect##1{\string##1\space}\@sanitize
     50          \@wrxref{|definition}}
     51\newcommand{\indexcode}[1]{{\lstinline$#1$}}
     52\def\use{\@bsphack\begingroup
     53         \def\protect##1{\string##1\space}\@sanitize
     54         \@wrxref{|hyperpage}}
     55\def\@wrxref#1#2{\let\thepage\relax
     56    \xdef\@gtempa{\write\@indexfile{\string
     57    \indexentry{#2@{\lstinline$#2$}#1}{\thepage}}}\endgroup\@gtempa
     58    \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
     59%\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
     60%\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
     61
     62% text inline and lowercase index: \Index{Inline and index text}
     63% text inline and as-in index: \Index{Inline and Index text}
     64% text inline but index with different as-is text: \Index[index text]{inline text}
     65\newcommand{\Index}{\@ifstar\@sIndex\@Index}
     66\newcommand{\@Index}[2][\@empty]{\lowercase{\def\temp{#2}}#2\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
     67\newcommand{\@sIndex}[2][\@empty]{#2\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
     68\makeatother
     69
     70% blocks and titles
     71\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
     72\newenvironment{rationale}{%
     73  \begin{quotation}\noindent$\Box$\enspace
     74}{%
     75  \hfill\enspace$\Box$\end{quotation}
     76}%
     77\newcommand{\rewrite}{\(\Rightarrow\)}
     78\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
     79\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
     80\newcommand{\semantics}{\paragraph{Semantics}~\par\noindent}
     81\newcommand{\constraints}{\paragraph{Constraints}~\par\noindent}
     82\newcommand{\predefined}{\paragraph{Predefined Identifiers}~\par\noindent}
     83
     84% BNF macros
     85\def\syntax{\paragraph{Syntax}\trivlist\parindent=.5in\item[\hskip.5in]}
     86\let\endsyntax=\endtrivlist
     87\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
     88\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
     89\newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}}
     90\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
     91\newcommand{\opt}{$_{opt}$\ }
     92
     93% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
     94% \VRef{label} => Section 2.7, \VPageref{label} => page 17
     95% \VRef[Figure]{label} => Figure 3.4, \VPageref{label} => page 17
     96\renewcommand{\reftextfaceafter}{\unskip}
     97\renewcommand{\reftextfacebefore}{\unskip}
     98\renewcommand{\reftextafter}{\unskip}
     99\renewcommand{\reftextbefore}{\unskip}
     100\renewcommand{\reftextfaraway}[1]{\unskip, p.~\pageref{#1}}
     101\renewcommand{\reftextpagerange}[2]{\unskip, pp.~\pageref{#1}--\pageref{#2}}
     102\newcommand{\VRef}[2][Section]{\ifx#1\@empty\else{#1}\nobreakspace\fi\vref{#2}}
     103\newcommand{\VPageref}[2][page]{\ifx#1\@empty\else{#1}\nobreakspace\fi\pageref{#2}}
     104
     105% adjust listings macros
     106\lstdefinelanguage{CFA}[ANSI]{C}%
     107{morekeywords={asm,_Alignas,_Alignof,_At,_Atomic,_Bool,catch,catchResume,choose,_Complex,context,disable,dtype,enable,
     108        fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,lvalue,_Noreturn,restrict,_Static_assert,
     109        _Thread_local,throw,throwResume,try,type,},
     110}%
     111
     112\lstset{
     113language=CFA,
     114columns=flexible,
     115basicstyle=\sf\small,
     116tabsize=4,
     117xleftmargin=\parindent,
     118escapechar=@,
     119keepspaces=true,
     120%showtabs=true,
     121%tab=\rightarrowfill,
     122}%
     123
     124\makeatletter
     125% replace/adjust listings characters that look bad in sanserif
     126\lst@CCPutMacro
     127\lst@ProcessOther{"2D}{\lst@ttfamily{-{}}{{\ttfamily\upshape -}}} % replace minus
     128\lst@ProcessOther{"3C}{\lst@ttfamily{<}{\texttt{<}}} % replace less than
     129\lst@ProcessOther{"3E}{\lst@ttfamily{<}{\texttt{>}}} % replace greater than
     130\lst@ProcessOther{"5E}{\raisebox{0.4ex}{$\scriptstyle\land\,$}} % replace circumflex
     131\lst@ProcessLetter{"5F}{\lst@ttfamily{\char95}{{\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}}} % replace underscore
     132\lst@ProcessOther{"7E}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}} % replace tilde
     133%\lst@ProcessOther{"7E}{\raisebox{-.4ex}[1ex][0pt]{\textasciitilde}} % lower tilde
     134\@empty\z@\@empty
     135\makeatother
     136
     137\setcounter{secnumdepth}{3}     % number subsubsections
     138\setcounter{tocdepth}{3}                % subsubsections in table of contents
    45139\makeindex
    46140
     
    49143\begin{document}
    50144\pagestyle{headings}
    51 \linenumbers                                            % comment out to turn off line numbering
    52 
    53 \title{\Huge
    54 \vspace*{1in}
    55 \CFA (\CFL) Reference Manual and Rationale
    56 }% title
    57 \author{\huge
    58 Glen Ditchfield and Peter A. Buhr
    59 }% author
    60 \date{
    61 DRAFT\\\today
    62 }% date
     145\linenumbers                                    % comment out to turn off line numbering
     146
     147\title{\CFA (\CFAA) Reference Manual and Rationale}
     148\author{Glen Ditchfield \and Peter A. Buhr}
     149\date{DRAFT\\\today}
    63150
    64151\pagenumbering{roman}
     
    72159\copyright\,2015 Glen Ditchfield \\ \\
    73160\noindent
    74 This work is licensed under the Creative Commons Attribution 4.0 International License.
    75 To view a copy of this license, visit {\small\url{http://creativecommons.org/licenses/by/4.0}}.
     161This work is licensed under the Creative Commons Attribution 4.0 International License. To view a
     162copy of this license, visit {\small\url{http://creativecommons.org/licenses/by/4.0}}.
    76163\vspace*{1in}
    77164
     
    86173\chapter*{Introduction}\addcontentsline{toc}{chapter}{Introduction}
    87174
    88 This document is a reference manual and rationale for \CFA, a polymorphic extension of the C programming language.
    89 It makes frequent reference to the {\c11} standard \cite{C11}, and occasionally compares \CFA to {\CC} \cite{C++}.
    90 
    91 The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering differs).
    92 Unfortunately, this means the manual contains more ``forward references'' than usual, making it harder to follow if the reader does not have a copy of the {\c11} standard.
    93 For a simple introduction to \CFA, see the companion document ``An Overview of \CFA''
     175This document is a reference manual and rationale for \CFA, a polymorphic extension of the C
     176programming language. It makes frequent reference to the {\c11} standard \cite{ANS:C11}, and
     177occasionally compares \CFA to {\CC} \cite{c++}.
     178
     179The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering
     180differs). Unfortunately, this means the manual contains more ``forward references'' than usual,
     181making it harder to follow if the reader does not have a copy of the {\c11} standard. For a simple
     182introduction to \CFA, see the companion document ``An Overview of \CFA''
    94183\cite{Ditchfield96:Overview}.
    95184
    96185\begin{rationale}
    97 Commentary (like this) is quoted with quads.
    98 Commentary usually deals with subtle points, the rationale behind a rule, and design decisions.
     186Commentary (like this) is quoted with quads. Commentary usually deals with subtle points, the
     187rationale behind a rule, and design decisions.
    99188\end{rationale}
    100189
     
    105194\chapter{Terms, definitions, and symbols}
    106195
    107 Terms from the {\c11} standard used in this document have the same meaning as in the {\c11} standard.
     196Terms from the {\c11} standard used in this document have the same meaning as in the {\c11}
     197standard.
    108198
    109199% No ``Conformance'' or ``Environment'' chapters yet.
     
    115205
    116206\section{Notation}
    117 The syntax notation used in this document is the same as in the {\c11} standard, with one exception: ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that these rules extend a previous definition, which occurs in this document or in the {\c11} standard.
     207The syntax notation used in this document is the same as in the {\c11} standard, with one exception:
     208ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that
     209these rules extend a previous definition, which occurs in this document or in the {\c11} standard.
    118210
    119211
     
    123215\subsection{Scopes of identifiers}\index{scopes}
    124216
    125 \CFA's scope rules differ from C's in one major respect: a declaration of an identifier may overload\index{overloading} outer declarations of lexically identical identifiers in the same
    126 \Index{name space}, instead of hiding them.
    127 The outer declaration is hidden if the two declarations have \Index{compatible type}, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type, or if one declaration is a \lstinline$type$\use{type} or
     217\CFA's scope rules differ from C's in one major respect: a declaration of an identifier may
     218overload\index{overloading} outer declarations of lexically identical identifiers in the same
     219\Index{name space}, instead of hiding them. The outer declaration is hidden if the two declarations
     220have \Index{compatible type}, or if one declares an array type and the other declares a pointer type
     221and the element type and pointed-at type are compatible, or if one has function type and the other
     222is a pointer to a compatible function type, or if one declaration is a \lstinline$type$\use{type} or
    128223\lstinline$typedef$\use{typedef} declaration and the other is not.  The outer declaration becomes
    129224\Index{visible} when the scope of the inner declaration terminates.
    130225\begin{rationale}
    131 Hence, a \CFA program can declare an \lstinline$int v$ and a \lstinline$float v$ in the same scope;
    132 a {\CC} program can not.
     226Hence, a \CFA program can declare an \lstinline$int v$ and a \lstinline$float v$ in the same
     227scope; a {\CC} program can not.
    133228\end{rationale}
    134229
     
    137232\index{linkage}
    138233
    139 \CFA's linkage rules differ from C's in only one respect: instances of a particular identifier with external or internal linkage do not necessarily denote the same object or function.
    140 Instead, in the set of translation units and libraries that constitutes an entire program, any two instances of a particular identifier with \Index{external linkage} denote the same object or function if they have
    141 \Index{compatible type}s, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type.
    142 Within one translation unit, each instance of an identifier with \Index{internal linkage} denotes the same object or function in the same circumstances.
     234\CFA's linkage rules differ from C's in only one respect: instances of a particular identifier with
     235external or internal linkage do not necessarily denote the same object or function. Instead, in the
     236set of translation units and libraries that constitutes an entire program, any two instances of a
     237particular identifier with \Index{external linkage} denote the same object or function if they have
     238\Index{compatible type}s, or if one declares an array type and the other declares a pointer type and
     239the element type and pointed-at type are compatible, or if one has function type and the other is a
     240pointer to a compatible function type. Within one translation unit, each instance of an identifier
     241with \Index{internal linkage} denotes the same object or function in the same circumstances.
    143242Identifiers with \Index{no linkage} always denote unique entities.
    144243\begin{rationale}
    145 A \CFA program can declare an \lstinline$extern int v$ and an \lstinline$extern float v$;
    146 a C program cannot.
     244A \CFA program can declare an \lstinline$extern int v$ and an \lstinline$extern float v$; a C
     245program cannot.
    147246\end{rationale}
    148247
     
    154253\subsubsection{Semantics}
    155254
    156 \CFA provides a capability for generic types;
    157 using this capability a single "generic type generator" can be written that can represent multiple concrete type instantiations by substitution of the "type parameters" of the generic type for concrete types.
    158 Syntactically a generic type generator is represented by putting a forall specifier on a struct or union declaration, as defined in \VRef{forall}.
    159 An instantiation of the generic type is written by specifying the type parameters in parentheses after the name of the generic type generator:
    160 \begin{lstlisting}
    161 forall( otype T | sumable( T ) ) struct pair {
     255\CFA provides a capability for generic types; using this capability a single "generic type
     256generator" can be written that can represent multiple concrete type instantiations by substitution
     257of the "type parameters" of the generic type for concrete types. Syntactically a generic type
     258generator is represented by putting a forall specifier on a struct or union declaration, as defined
     259in \VRef{forall}. An instantiation of the generic type is written by specifying the type parameters
     260in parentheses after the name of the generic type generator:
     261\begin{lstlisting}
     262forall( type T | sumable( T ) ) struct pair {
    162263        T x;
    163264        T y;
     
    166267\end{lstlisting}
    167268
    168 The type parameters in an instantiation of a generic type must satisfy any constraints in the forall specifier on the type generator declaration, e.g., \lstinline$sumable$.
    169 The instantiation then has the semantics that would result if the type parameters were substituted into the type generator declaration by macro substitution.
    170 
    171 Polymorphic functions may have generic types as parameters, and those generic types may use type parameters of the polymorphic function as type parameters of the generic type:
    172 \begin{lstlisting}
    173 forall( otype T ) void swap( pair(T) *p ) {
     269The type parameters in an instantiation of a generic type must satisfy any constraints in the forall
     270specifier on the type generator declaration, e.g., \lstinline$sumable$. The instantiation then has
     271the semantics that would result if the type parameters were substituted into the type generator
     272declaration by macro substitution.
     273
     274Polymorphic functions may have generic types as parameters, and those generic types may use type
     275parameters of the polymorphic function as type parameters of the generic type:
     276\begin{lstlisting}
     277forall( type T ) void swap( pair(T) *p ) {
    174278        T z = p->x;
    175279        p->x = p->y;
     
    181285\subsubsection{Constraints}
    182286
    183 To avoid unduly constraining implementors, the generic type generator definition must be visible at any point where it is instantiated.
    184 Forward declarations of generic type generators are not forbidden, but the definition must be visible to instantiate the generic type.  Equivalently, instantiations of generic types are not allowed to be incomplete types.
     287To avoid unduly constraining implementors, the generic type generator definition must be visible at
     288any point where it is instantiated.  Forward declarations of generic type generators are not
     289forbidden, but the definition must be visible to instantiate the generic type.  Equivalently,
     290instantiations of generic types are not allowed to be incomplete types.
    185291
    186292\examples
    187293\begin{lstlisting}
    188 forall( otype T ) struct A;
    189 
    190 forall( otype T ) struct B {
    191         A(T) *a;                        // legal, but cannot instantiate B(T)
     294forall( type T ) struct A;
     295
     296forall( type T ) struct B {
     297        A(T) *a;  // legal, but cannot instantiate B(T)
    192298};
    193299
    194 B(T) x;                                 // illegal, *x.a is of an incomplete generic type
    195  
    196 forall( otype T ) struct A {
     300B(T) x; // illegal, *x.a is of an incomplete generic type
     301
     302forall( type T ) struct A {
    197303        B( T ) *b;
    198304};
    199305
    200 B( T ) y;                               // legal, *x.a is now of a complete generic type
     306B( T ) y; // legal, *x.a is now of a complete generic type
     307
    201308
    202309// box.h:
    203         forall( otype T ) struct box;
    204         forall( otype T ) box( T ) *make_box( T );
    205         forall( otype T ) void use_box( box( T ) *b );
     310        forall( type T ) struct box;
     311        forall( type T ) box( T ) *make_box( T );
     312        forall( type T ) void use_box( box( T ) *b );
    206313       
    207314// main.c:
    208         box( int ) *b = make_box( 42 ); // illegal, definition of box not visible
    209         use_box( b );           // illegal
     315        box( int ) *b = make_box( 42 ); // illegal, def'n of box not visible
     316        use_box( b ); // illegal
    210317\end{lstlisting}
    211318
     
    213320\section{Conversions}
    214321\CFA defines situations where values of one type are automatically converted to another type.
    215 These conversions are called \define{implicit conversion}s.
    216 The programmer can request
     322These conversions are called \define{implicit conversion}s. The programmer can request
    217323\define{explicit conversion}s using cast expressions.
    218324
     
    224330\subsubsection{Safe arithmetic conversions}
    225331
    226 In C, a pattern of conversions known as the \define{usual arithmetic conversion}s is used with most binary arithmetic operators to convert the operands to a common type and determine the type of the operator's result.
    227 In \CFA, these conversions play a role in overload resolution, and collectively are called the \define{safe arithmetic conversion}s.
    228 
    229 Let \(int_r\) and \(unsigned_r\) be the signed and unsigned integer types with integer conversion rank\index{integer conversion rank}\index{rank|see{integer conversion rank}} $r$.
    230 Let \(unsigned_{mr}\) be the unsigned integer type with maximal rank.
     332In C, a pattern of conversions known as the \define{usual arithmetic conversion}s is used with most
     333binary arithmetic operators to convert the operands to a common type and determine the type of the
     334operator's result. In \CFA, these conversions play a role in overload resolution, and
     335collectively are called the \define{safe arithmetic conversion}s.
     336
     337Let \(int_r\) and \(unsigned_r\) be the signed and unsigned integer types with integer conversion
     338rank\index{integer conversion rank}\index{rank|see{integer conversion rank}} $r$. Let
     339\(unsigned_{mr}\) be the unsigned integer type with maximal rank.
    231340
    232341The following conversions are \emph{direct} safe arithmetic conversions.
     
    234343\item
    235344The \Index{integer promotion}s.
    236 \item
    237 For every rank $r$ greater than or equal to the rank of \lstinline$int$, conversion from \(int_r\) to \(unsigned_r\).
    238 \item
    239 For every rank $r$ greater than or equal to the rank of \lstinline$int$, where \(int_{r+1}\) exists and can represent all values of \(unsigned_r\), conversion from \(unsigned_r\) to \(int_{r+1}\).
     345
     346\item
     347For every rank $r$ greater than or equal to the rank of \lstinline$int$, conversion from \(int_r\)
     348to \(unsigned_r\).
     349
     350\item
     351For every rank $r$ greater than or equal to the rank of \lstinline$int$, where \(int_{r+1}\) exists
     352and can represent all values of \(unsigned_r\), conversion from \(unsigned_r\) to \(int_{r+1}\).
     353
    240354\item
    241355Conversion from \(unsigned_{mr}\) to \lstinline$float$.
     356
    242357\item
    243358Conversion from an enumerated type to its compatible integer type.
    244 \item
    245 Conversion from \lstinline$float$ to \lstinline$double$, and from \lstinline$double$ to \lstinline$long double$.
    246 \item
    247 Conversion from \lstinline$float _Complex$ to \lstinline$double _Complex$, and from \lstinline$double _Complex$ to \lstinline$long double _Complex$.
     359
     360\item
     361Conversion from \lstinline$float$ to \lstinline$double$, and from \lstinline$double$ to
     362\lstinline$long double$.
     363
     364\item
     365Conversion from \lstinline$float _Complex$ to \lstinline$double _Complex$,
     366and from \lstinline$double _Complex$ to \lstinline$long double _Complex$.
     367
    248368\begin{sloppypar}
    249369\item
    250 Conversion from \lstinline$float _Imaginary$ to \lstinline$double _Imaginary$, and from \lstinline$double _Imaginary$ to \lstinline$long double$ \lstinline$_Imaginary$, if the implementation supports imaginary types.
     370Conversion from \lstinline$float _Imaginary$ to \lstinline$double _Imaginary$, and from
     371\lstinline$double _Imaginary$ to \lstinline$long double$ \lstinline$_Imaginary$, if the
     372implementation supports imaginary types.
    251373\end{sloppypar}
    252374\end{itemize}
    253375
    254 If type \lstinline$T$ can be converted to type \lstinline$U$ by a safe direct arithmetic conversion and type \lstinline$U$ can be converted to type \lstinline$V$ by a safe arithmetic conversion, then the conversion from \lstinline$T$ to type \lstinline$V$ is an \emph{indirect} safe arithmetic conversion.
    255 
    256 \begin{rationale}
    257 Note that {\c11} does not include conversion from \Index{real type}s to \Index{complex type}s in the usual arithmetic conversions, and \CFA does not include them as safe conversions.
     376If type \lstinline$T$ can be converted to type \lstinline$U$ by a safe direct arithmetic conversion
     377and type \lstinline$U$ can be converted to type \lstinline$V$ by a safe arithmetic conversion, then
     378the conversion from \lstinline$T$ to type \lstinline$V$ is an \emph{indirect} safe arithmetic
     379conversion.
     380
     381\begin{rationale}
     382Note that {\c11} does not include conversion from \Index{real type}s to \Index{complex type}s in the
     383usual arithmetic conversions, and \CFA does not include them as safe conversions.
    258384\end{rationale}
    259385
     
    267393
    268394If an expression's type is a pointer to a structure or union type that has a member that is an
    269 \Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's type.
    270 The result of the conversion is a pointer to the member.
     395\Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly
     396converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's
     397type. The result of the conversion is a pointer to the member.
    271398
    272399\examples
     
    275402        int x, y;
    276403};
    277 void move_by( struct point * p1, struct point * p2 ) {@\impl{move_by}@
     404void move_by(struct point * p1, struct point * p2) {@\impl{move_by}@
    278405        p1->x += p2.x;
    279406        p1->y += p2.y;
    280407}
     408
    281409struct color_point {
    282410        enum { RED, BLUE, GREEN } color;
    283411        struct point;
    284412} cp1, cp2;
    285 move_to( &cp1, &cp2 );
     413move_to(&cp1, &cp2);
    286414\end{lstlisting}
    287415Thanks to implicit conversion, the two arguments that \lstinline$move_by()$ receives are pointers to
     
    290418
    291419\subsubsection{Specialization}
    292 A function or value whose type is polymorphic may be implicitly converted to one whose type is \Index{less polymorphic} by binding values to one or more of its \Index{inferred parameter}.
    293 Any value that is legal for the inferred parameter may be used, including other inferred parameters.
    294 
    295 If, after the inferred parameter binding, an \Index{assertion parameter} has no inferred parameters in its type, then an object or function must be visible at the point of the specialization that has the same identifier as the assertion parameter and has a type that is compatible\index{compatible type} with or can be specialized to the type of the assertion parameter.
    296 The assertion parameter is bound to that object or function.
    297 
    298 The type of the specialization is the type of the original with the bound inferred parameters and the bound assertion parameters replaced by their bound values.
     420A function or value whose type is polymorphic may be implicitly converted to one whose type is
     421\Index{less polymorphic} by binding values to one or more of its \Index{inferred parameter}. Any
     422value that is legal for the inferred parameter may be used, including other inferred parameters.
     423
     424If, after the inferred parameter binding, an \Index{assertion parameter} has no inferred parameters
     425in its type, then an object or function must be visible at the point of the specialization that has
     426the same identifier as the assertion parameter and has a type that is compatible\index{compatible
     427  type} with or can be specialized to the type of the assertion parameter.  The assertion parameter
     428is bound to that object or function.
     429
     430The type of the specialization is the type of the original with the bound inferred parameters and
     431the bound assertion parameters replaced by their bound values.
    299432
    300433\examples
    301434The type
    302435\begin{lstlisting}
    303 forall( otype T, otype U ) void (*)( T, U );
     436forall( type T, type U ) void (*)( T, U );
    304437\end{lstlisting}
    305438can be specialized to (among other things)
    306439\begin{lstlisting}
    307 forall( otype T ) void (*)( T, T );             // U bound to T
    308 forall( otype T ) void (*)( T, real );  // U bound to real
    309 forall( otype U ) void (*)( real, U );  // T bound to real
     440forall( type T ) void (*)( T, T );              // U bound to T
     441forall( type T ) void (*)( T, real );   // U bound to real
     442forall( type U ) void (*)( real, U );   // T bound to real
    310443void f( real, real );                                   // both bound to real
    311444\end{lstlisting}
     
    313446The type
    314447\begin{lstlisting}
    315 forall( otype T | T ?+?( T, T ) ) T (*)( T );
     448forall( type T | T ?+?( T, T )) T (*)( T );
    316449\end{lstlisting}
    317450can be specialized to (among other things)
    318451\begin{lstlisting}
    319 int (*)( int );         // T bound to int, and T ?+?(T, T ) bound to int ?+?( int, int )
     452int (*)( int );                                         // T bound to int, and T ?+?(T, T ) bound to int ?+?( int, int )
    320453\end{lstlisting}
    321454
     
    332465from a pointer to any non-\lstinline$void$ type to a pointer to \lstinline$void$;
    333466\item
    334 from a pointer to any type to a pointer to a more qualified version of the type\index{qualified type};
    335 \item
    336 from a pointer to a structure or union type to a pointer to the type of a member of the structure or union that is an \Index{anonymous structure} or an \Index{anonymous union};
    337 \item
    338 within the scope of an initialized \Index{type declaration}, conversions between a type and its implementation or between a pointer to a type and a pointer to its implementation.
     467from a pointer to any type to a pointer to a more qualified version of the type\index{qualified
     468type};
     469\item
     470from a pointer to a structure or union type to a pointer to the type of a member of the structure or
     471union that is an \Index{anonymous structure} or an \Index{anonymous union};
     472\item
     473within the scope of an initialized \Index{type declaration}, conversions between a type and its
     474implementation or between a pointer to a type and a pointer to its implementation.
    339475\end{itemize}
    340476
    341477Conversions that are not safe conversions are \define{unsafe conversion}s.
    342478\begin{rationale}
    343 As in C, there is an implicit conversion from \lstinline$void *$ to any pointer type.
    344 This is clearly dangerous, and {\CC} does not have this implicit conversion.
    345 \CFA\index{deficiencies!void * conversion} keeps it, in the interest of remaining as pure a superset of C as possible, but discourages it by making it unsafe.
     479As in C, there is an implicit conversion from \lstinline$void *$ to any pointer type. This is
     480clearly dangerous, and {\CC} does not have this implicit conversion.
     481\CFA\index{deficiencies!void * conversion} keeps it, in the interest of remaining as pure a
     482superset of C as possible, but discourages it by making it unsafe.
    346483\end{rationale}
    347484
     
    349486\subsection{Conversion cost}
    350487
    351 The \define{conversion cost} of a safe\index{safe conversion} conversion\footnote{Unsafe\index{unsafe conversion} conversions do not have defined conversion costs.} is a measure of how desirable or undesirable it is.
    352 It is defined as follows.
     488The \define{conversion cost} of a safe\index{safe conversion}
     489conversion\footnote{Unsafe\index{unsafe conversion} conversions do not have defined conversion
     490costs.} is a measure of how desirable or undesirable it is. It is defined as follows.
    353491\begin{itemize}
    354492\item
     
    359497
    360498\item
    361 The cost of an indirect safe arithmetic conversion is the smallest number of direct conversions needed to make up the conversion.
     499The cost of an indirect safe arithmetic conversion is the smallest number of direct conversions
     500needed to make up the conversion.
    362501\end{itemize}
    363502
     
    367506\begin{itemize}
    368507\item
    369 The cost of an implicit conversion from \lstinline$int$ to \lstinline$long$ is 1.
    370 The cost of an implicit conversion from \lstinline$long$ to \lstinline$double$ is 3, because it is defined in terms of conversions from \lstinline$long$ to \lstinline$unsigned long$, then to \lstinline$float$, and then to \lstinline$double$.
    371 
    372 \item
    373 If \lstinline$int$ can represent all the values of \lstinline$unsigned short$, then the cost of an implicit conversion from \lstinline$unsigned short$ to \lstinline$unsigned$ is 2:
    374 \lstinline$unsigned short$ to \lstinline$int$ to \lstinline$unsigned$.
    375 Otherwise, \lstinline$unsigned short$ is converted directly to \lstinline$unsigned$, and the cost is 1.
    376 
    377 \item
    378 If \lstinline$long$ can represent all the values of \lstinline$unsigned$, then the conversion cost of \lstinline$unsigned$ to \lstinline$long$ is 1.
    379 Otherwise, the conversion is an unsafe conversion, and its conversion cost is undefined.
     508The cost of an implicit conversion from \lstinline$int$ to \lstinline$long$ is 1. The cost of an
     509implicit conversion from \lstinline$long$ to \lstinline$double$ is 3, because it is defined in terms
     510of conversions from \lstinline$long$ to \lstinline$unsigned long$, then to \lstinline$float$, and
     511then to \lstinline$double$.
     512
     513\item
     514If \lstinline$int$ can represent all the values of \lstinline$unsigned short$, then the cost of an
     515implicit conversion from \lstinline$unsigned short$ to \lstinline$unsigned$ is 2:
     516\lstinline$unsigned short$ to \lstinline$int$ to \lstinline$unsigned$. Otherwise,
     517\lstinline$unsigned short$ is converted directly to \lstinline$unsigned$, and the cost is 1.
     518
     519\item
     520If \lstinline$long$ can represent all the values of \lstinline$unsigned$, then the conversion cost
     521of \lstinline$unsigned$ to \lstinline$long$ is 1. Otherwise, the conversion is an unsafe
     522conversion, and its conversion cost is undefined.
    380523\end{itemize}
    381524
     
    386529        \rhs \lstinline$forall$
    387530        \rhs \lstinline$lvalue$
    388         \rhs \lstinline$trait$
     531        \rhs \lstinline$context$
    389532        \rhs \lstinline$dtype$
    390533        \rhs \lstinline$ftype$
     
    395538\subsection{Identifiers}
    396539
    397 \CFA allows operator \Index{overloading} by associating operators with special function identifiers.
    398 Furthermore, the constants ``\lstinline$0$'' and ``\lstinline$1$'' have special status for many of C's data types (and for many programmer-defined data types as well), so \CFA treats them as overloadable identifiers.
    399 Programmers can use these identifiers to declare functions and objects that implement operators and constants for their own types.
     540\CFA allows operator \Index{overloading} by associating operators with special function
     541identifiers. Furthermore, the constants ``\lstinline$0$'' and ``\lstinline$1$'' have special status
     542for many of C's data types (and for many programmer-defined data types as well), so \CFA treats them
     543as overloadable identifiers. Programmers can use these identifiers to declare functions and objects
     544that implement operators and constants for their own types.
    400545
    401546
     
    409554\end{syntax}
    410555
    411 \index{constant identifiers}\index{identifiers!for constants} The tokens ``\lstinline$0$''\impl{0} and ``\lstinline$1$''\impl{1} are identifiers.
    412 No other tokens defined by the rules for integer constants are considered to be identifiers.
    413 \begin{rationale}
    414 Why ``\lstinline$0$'' and ``\lstinline$1$''? Those integers have special status in C.
    415 All scalar types can be incremented and decremented, which is defined in terms of adding or subtracting 1.
    416 The operations ``\lstinline$&&$'', ``\lstinline$||$'', and ``\lstinline$!$'' can be applied to any scalar arguments, and are defined in terms of comparison against 0.
    417 A \nonterm{constant-expression} that evaluates to 0 is effectively compatible with every pointer type.
    418 
    419 In C, the integer constants 0 and 1 suffice because the integer promotion rules can convert them to any arithmetic type, and the rules for pointer expressions treat constant expressions evaluating to 0 as a special case.
    420 However, user-defined arithmetic types often need the equivalent of a 1 or 0 for their functions or operators, polymorphic functions often need 0 and 1 constants of a type matching their polymorphic parameters, and user-defined pointer-like types may need a null value.
    421 Defining special constants for a user-defined type is more efficient than defining a conversion to the type from \lstinline$_Bool$.
    422 
    423 Why \emph{just} ``\lstinline$0$'' and ``\lstinline$1$''? Why not other integers? No other integers have special status in C.
    424 A facility that let programmers declare specific constants---``\lstinline$const Rational 12$'', for instance---would not be much of an improvement.
    425 Some facility for defining the creation of values of programmer-defined types from arbitrary integer tokens would be needed.
    426 The complexity of such a feature doesn't seem worth the gain.
     556\index{constant identifiers}\index{identifiers!for constants} The tokens ``\lstinline$0$''\impl{0}
     557and ``\lstinline$1$''\impl{1} are identifiers. No other tokens defined by the rules for integer
     558constants are considered to be identifiers.
     559\begin{rationale}
     560Why ``\lstinline$0$'' and ``\lstinline$1$''? Those integers have special status in C. All scalar
     561types can be incremented and decremented, which is defined in terms of adding or subtracting 1. The
     562operations ``\lstinline$&&$'', ``\lstinline$||$'', and ``\lstinline$!$'' can be applied to any
     563scalar arguments, and are defined in terms of comparison against 0. A \nonterm{constant-expression}
     564that evaluates to 0 is effectively compatible with every pointer type.
     565
     566In C, the integer constants 0 and 1 suffice because the integer promotion rules can convert them to
     567any arithmetic type, and the rules for pointer expressions treat constant expressions evaluating to
     5680 as a special case. However, user-defined arithmetic types often need the equivalent of a 1 or 0
     569for their functions or operators, polymorphic functions often need 0 and 1 constants of a type
     570matching their polymorphic parameters, and user-defined pointer-like types may need a null value.
     571Defining special constants for a user-defined type is more efficient than defining a conversion to
     572the type from \lstinline$_Bool$.
     573
     574Why \emph{just} ``\lstinline$0$'' and ``\lstinline$1$''? Why not other integers? No other integers
     575have special status in C. A facility that let programmers declare specific
     576constants---``\lstinline$const Rational 12$'', for instance---would not be much of an improvement.
     577Some facility for defining the creation of values of programmer-defined types from arbitrary integer
     578tokens would be needed. The complexity of such a feature doesn't seem worth the gain.
    427579\end{rationale}
    428580
     
    430582\subsubsection{Operator identifiers}
    431583
    432 \index{operator identifiers}\index{identifiers!for operators} Table \ref{opids} lists the programmer-definable operator identifiers and the operations they are associated with.
    433 Functions that are declared with (or pointed at by function pointers that are declared with) these identifiers can be called by expressions that use the operator tokens and syntax, or the operator identifiers and ``function call'' syntax.
    434 The relationships between operators and function calls are discussed in descriptions of the operators.
     584\index{operator identifiers}\index{identifiers!for operators} Table \ref{opids} lists the
     585programmer-definable operator identifiers and the operations they are associated with. Functions
     586that are declared with (or pointed at by function pointers that are declared with) these identifiers
     587can be called by expressions that use the operator tokens and syntax, or the operator identifiers
     588and ``function call'' syntax. The relationships between operators and function calls are discussed
     589in descriptions of the operators.
    435590
    436591\begin{table}[hbt]
     
    489644
    490645\begin{rationale}
    491 Operator identifiers are made up of the characters of the operator token, with question marks added to mark the positions of the arguments of operators.
    492 The question marks serve as mnemonic devices;
    493 programmers can not create new operators by arbitrarily mixing question marks and other non-alphabetic characters.
    494 Note that prefix and postfix versions of the increment and decrement operators are distinguished by the position of the question mark.
    495 \end{rationale}
    496 
    497 \begin{rationale}
    498 The use of ``\lstinline$?$'' in identifiers means that some C programs are not \CFA programs.  For instance, the sequence of characters ``\lstinline$(i < 0)?--i:i$'' is legal in a C program, but a
    499 \CFA compiler detects a syntax error because it treats ``\lstinline$?--$'' as an identifier, not as the two tokens ``\lstinline$?$'' and ``\lstinline$--$''.
     646Operator identifiers are made up of the characters of the operator token, with question marks added
     647to mark the positions of the arguments of operators. The question marks serve as mnemonic devices;
     648programmers can not create new operators by arbitrarily mixing question marks and other
     649non-alphabetic characters. Note that prefix and postfix versions of the increment and decrement
     650operators are distinguished by the position of the question mark.
     651\end{rationale}
     652
     653\begin{rationale}
     654The use of ``\lstinline$?$'' in identifiers means that some C programs are not \CFA programs.  For
     655instance, the sequence of characters ``\lstinline$(i < 0)?--i:i$'' is legal in a C program, but a
     656\CFA compiler detects a syntax error because it treats ``\lstinline$?--$'' as an identifier, not
     657as the two tokens ``\lstinline$?$'' and ``\lstinline$--$''.
    500658\end{rationale}
    501659
     
    505663\item
    506664The logical operators ``\lstinline$&&$'' and ``\lstinline$||$'', and the conditional operator
    507 ``\lstinline$?:$''.
    508 These operators do not always evaluate their operands, and hence can not be properly defined by functions unless some mechanism like call-by-name is added to the language.
    509 Note that the definitions of ``\lstinline$&&$'' and ``\lstinline$||$'' say that they work by checking that their arguments are unequal to 0, so defining ``\lstinline$!=$'' and ``\lstinline$0$'' for user-defined types is enough to allow them to be used in logical expressions.
    510 
    511 \item
    512 The comma operator\index{comma expression}.
    513 It is a control-flow operator like those above.
     665``\lstinline$?:$''. These operators do not always evaluate their operands, and hence can not be
     666properly defined by functions unless some mechanism like call-by-name is added to the language.
     667Note that the definitions of ``\lstinline$&&$'' and ``\lstinline$||$'' say that they work by
     668checking that their arguments are unequal to 0, so defining ``\lstinline$!=$'' and ``\lstinline$0$''
     669for user-defined types is enough to allow them to be used in logical expressions.
     670
     671\item
     672The comma operator\index{comma expression}. It is a control-flow operator like those above.
    514673Changing its meaning seems pointless and confusing.
    515674
    516675\item
    517 The ``address of'' operator.
    518 It would seem useful to define a unary ``\lstinline$&$'' operator that returns values of some programmer-defined pointer-like type.
    519 The problem lies with the type of the operator.
    520 Consider the expression ``\lstinline$p = &x$'', where \lstinline$x$ is of type
    521 \lstinline$T$ and \lstinline$p$ has the programmer-defined type \lstinline$T_ptr$.
    522 The expression might be treated as a call to the unary function ``\lstinline$&?$''.
    523 Now what is the type of the function's parameter? It can not be \lstinline$T$, because then \lstinline$x$ would be passed by value, and there is no way to create a useful pointer-like result from a value.
    524 Hence the parameter must have type \lstinline$T *$.
    525 But then the expression must be rewritten as ``\lstinline$p = &?( &x )$''
     676The ``address of'' operator. It would seem useful to define a unary ``\lstinline$&$'' operator that
     677returns values of some programmer-defined pointer-like type. The problem lies with the type of the
     678operator. Consider the expression ``\lstinline$p = &x$'', where \lstinline$x$ is of type
     679\lstinline$T$ and \lstinline$p$ has the programmer-defined type \lstinline$T_ptr$. The expression
     680might be treated as a call to the unary function ``\lstinline$&?$''. Now what is the type of the
     681function's parameter? It can not be \lstinline$T$, because then \lstinline$x$ would be passed by
     682value, and there is no way to create a useful pointer-like result from a value. Hence the parameter
     683must have type \lstinline$T *$. But then the expression must be rewritten as ``\lstinline$p = &?( &x )$''
    526684---which doesn't seem like progress!
    527685
    528 The rule for address-of expressions would have to be something like ``keep applying address-of functions until you get one that takes a pointer argument, then use the built-in operator and stop''.
    529 It seems simpler to define a conversion function from \lstinline$T *$ to \lstinline$T_ptr$.
    530 
    531 \item
    532 The \lstinline$sizeof$ operator.
    533 It is already defined for every object type, and intimately tied into the language's storage allocation model.
    534 Redefining it seems pointless.
    535 
    536 \item
    537 The ``member of'' operators ``\lstinline$.$'' and ``\lstinline$->$''.
    538 These are not really infix operators, since their right ``operand'' is not a value or object.
    539 
    540 \item
    541 Cast operators\index{cast expression}.
    542 Anything that can be done with an explicit cast can be done with a function call.
    543 The difference in syntax is small.
     686The rule for address-of expressions would have to be something like ``keep applying address-of
     687functions until you get one that takes a pointer argument, then use the built-in operator and
     688stop''. It seems simpler to define a conversion function from \lstinline$T *$ to \lstinline$T_ptr$.
     689
     690\item
     691The \lstinline$sizeof$ operator. It is already defined for every object type, and intimately tied
     692into the language's storage allocation model. Redefining it seems pointless.
     693
     694\item
     695The ``member of'' operators ``\lstinline$.$'' and ``\lstinline$->$''. These are not really infix
     696operators, since their right ``operand'' is not a value or object.
     697
     698\item
     699Cast operators\index{cast expression}. Anything that can be done with an explicit cast can be done
     700with a function call. The difference in syntax is small.
    544701\end{itemize}
    545702\end{rationale}
     
    548705\section{Expressions}
    549706
    550 \CFA allows operators and identifiers to be overloaded.
    551 Hence, each expression can have a number of \define{interpretation}s, each of which has a different type.
    552 The interpretations that are potentially executable are called \define{valid interpretation}s.
    553 The set of interpretations depends on the kind of expression and on the interpretations of the subexpressions that it contains.
    554 The rules for determining the valid interpretations of an expression are discussed below for each kind of expression.
    555 Eventually the context of the outermost expression chooses one interpretation of that expression.
    556 
    557 An \define{ambiguous interpretation} is an interpretation which does not specify the exact object or function denoted by every identifier in the expression.
    558 An expression can have some interpretations that are ambiguous and others that are unambiguous.
    559 An expression that is chosen to be executed shall not be ambiguous.
    560 
    561 The \define{best valid interpretations} are the valid interpretations that use the fewest unsafe\index{unsafe conversion} conversions.
    562 Of these, the best are those where the functions and objects involved are the least polymorphic\index{less polymorphic}.
    563 Of these, the best have the lowest total \Index{conversion cost}, including all implicit conversions in the argument expressions.
    564 Of these, the best have the highest total conversion cost for the implicit conversions
    565 (if any) applied to the argument expressions.
    566 If there is no single best valid interpretation, or if the best valid interpretation is ambiguous, then the resulting interpretation is ambiguous\index{ambiguous interpretation}.
    567 
    568 \begin{rationale}
    569 \CFA's rules for selecting the best interpretation are designed to allow overload resolution to mimic C's operator semantics.
    570 In C, the ``usual arithmetic conversions'' are applied to the operands of binary operators if necessary to convert the operands to types with a common real type.
    571 In \CFA, those conversions are ``safe''.
    572 The ``fewest unsafe conversions'' rule ensures that the usual conversions are done, if possible.
    573 The ``lowest total expression cost'' rule chooses the proper common type.
    574 The odd-looking ``highest argument conversion cost'' rule ensures that, when unary expressions must be converted, conversions of function results are preferred to conversion of function arguments: \lstinline$(double)-i$ will be preferred to \lstinline$-(double)i$.
    575 
    576 The ``least polymorphic'' rule reduces the number of polymorphic function calls, since such functions are presumably more expensive than monomorphic functions and since the more specific function is presumably more appropriate.
    577 It also gives preference to monomorphic values (such as the
     707\CFA allows operators and identifiers to be overloaded. Hence, each expression can have a number
     708of \define{interpretation}s, each of which has a different type. The interpretations that are
     709potentially executable are called \define{valid interpretation}s. The set of interpretations
     710depends on the kind of expression and on the interpretations of the subexpressions that it contains.
     711The rules for determining the valid interpretations of an expression are discussed below for each
     712kind of expression. Eventually the context of the outermost expression chooses one interpretation
     713of that expression.
     714
     715An \define{ambiguous interpretation} is an interpretation which does not specify the exact object or
     716function denoted by every identifier in the expression. An expression can have some interpretations
     717that are ambiguous and others that are unambiguous. An expression that is chosen to be executed
     718shall not be ambiguous.
     719
     720The \define{best valid interpretations} are the valid interpretations that use the fewest
     721unsafe\index{unsafe conversion} conversions. Of these, the best are those where the functions and
     722objects involved are the least polymorphic\index{less polymorphic}. Of these, the best have the
     723lowest total \Index{conversion cost}, including all implicit conversions in the argument
     724expressions. Of these, the best have the highest total conversion cost for the implicit conversions
     725(if any) applied to the argument expressions. If there is no single best valid interpretation, or if
     726the best valid interpretation is ambiguous, then the resulting interpretation is
     727ambiguous\index{ambiguous interpretation}.
     728
     729\begin{rationale}
     730\CFA's rules for selecting the best interpretation are designed to allow overload resolution to
     731mimic C's operator semantics. In C, the ``usual arithmetic conversions'' are applied to the
     732operands of binary operators if necessary to convert the operands to types with a common real type.
     733In \CFA, those conversions are ``safe''. The ``fewest unsafe conversions'' rule ensures that the
     734usual conversions are done, if possible. The ``lowest total expression cost'' rule chooses the
     735proper common type. The odd-looking ``highest argument conversion cost'' rule ensures that, when
     736unary expressions must be converted, conversions of function results are preferred to conversion of
     737function arguments: \lstinline$(double)-i$ will be preferred to \lstinline$-(double)i$.
     738
     739The ``least polymorphic'' rule reduces the number of polymorphic function calls, since such
     740functions are presumably more expensive than monomorphic functions and since the more specific
     741function is presumably more appropriate. It also gives preference to monomorphic values (such as the
    578742\lstinline$int$ \lstinline$0$) over polymorphic values (such as the \Index{null pointer}
    579 \lstinline$0$\use{0}).
    580 However, interpretations that call polymorphic functions are preferred to interpretations that perform unsafe conversions, because those conversions potentially lose accuracy or violate strong typing.
     743\lstinline$0$\use{0}). However, interpretations that call polymorphic functions are preferred to
     744interpretations that perform unsafe conversions, because those conversions potentially lose accuracy
     745or violate strong typing.
    581746
    582747There are two notable differences between \CFA's overload resolution rules and the rules for
    583 {\CC} defined in \cite{C++}.
    584 First, the result type of a function plays a role.
    585 In {\CC}, a function call must be completely resolved based on the arguments to the call in most circumstances.
    586 In \CFA, a function call may have several interpretations, each with a different result type, and the interpretations of the containing context choose among them.
    587 Second, safe conversions are used to choose among interpretations of all sorts of functions;
    588 in {\CC}, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators.
    589 \end{rationale}
    590 
    591 Expressions involving certain operators\index{operator identifiers} are considered to be equivalent to function calls.
    592 A transformation from ``operator'' syntax to ``function call'' syntax is defined by \define{rewrite rules}.
    593 Each operator has a set of predefined functions that overload its identifier.
    594 Overload resolution determines which member of the set is executed in a given expression.
    595 The functions have \Index{internal linkage} and are implicitly declared with \Index{file scope}.
    596 The predefined functions and rewrite rules are discussed below for each of these operators.
    597 \begin{rationale}
    598 Predefined functions and constants have internal linkage because that simplifies optimization in traditional compile-and-link environments.
    599 For instance, ``\lstinline$an_int + an_int$'' is equivalent to ``\lstinline$?+?(an_int, an_int)$''.
    600 If integer addition has not been redefined in the current scope, a compiler can generate code to perform the addition directly.
    601 If predefined functions had external linkage, this optimization would be difficult.
    602 \end{rationale}
    603 
    604 \begin{rationale}
    605 Since each subsection describes the interpretations of an expression in terms of the interpretations of its subexpressions, this chapter can be taken as describing an overload resolution algorithm that uses one bottom-up pass over an expression tree.
    606 Such an algorithm was first described (for Ada) by Baker~\cite{Bak:overload}.
    607 It is extended here to handle polymorphic functions and arithmetic conversions.
    608 The overload resolution rules and the predefined functions have been chosen so that, in programs that do not introduce overloaded declarations, expressions will have the same meaning in C and in \CFA.
    609 \end{rationale}
    610 
    611 \begin{rationale}
    612 Expression syntax is quoted from the {\c11} standard.
    613 The syntax itself defines the precedence and associativity of operators.
    614 The sections are arranged in decreasing order of precedence, with all operators in a section having the same precedence.
     748{\CC} defined in \cite{c++}. First, the result type of a function plays a role. In {\CC}, a
     749function call must be completely resolved based on the arguments to the call in most circumstances.
     750In \CFA, a function call may have several interpretations, each with a different result type, and
     751the interpretations of the containing context choose among them. Second, safe conversions are used
     752to choose among interpretations of all sorts of functions; in {\CC}, the ``usual arithmetic
     753conversions'' are a separate set of rules that apply only to the built-in operators.
     754\end{rationale}
     755
     756Expressions involving certain operators\index{operator identifiers} are considered to be equivalent
     757to function calls. A transformation from ``operator'' syntax to ``function call'' syntax is defined
     758by \define{rewrite rules}. Each operator has a set of predefined functions that overload its
     759identifier. Overload resolution determines which member of the set is executed in a given
     760expression. The functions have \Index{internal linkage} and are implicitly declared with \Index{file
     761scope}. The predefined functions and rewrite rules are discussed below for each of these
     762operators.
     763\begin{rationale}
     764Predefined functions and constants have internal linkage because that simplifies optimization in
     765traditional compile-and-link environments. For instance, ``\lstinline$an_int + an_int$'' is
     766equivalent to ``\lstinline$?+?(an_int, an_int)$''. If integer addition has not been redefined in
     767the current scope, a compiler can generate code to perform the addition directly. If predefined
     768functions had external linkage, this optimization would be difficult.
     769\end{rationale}
     770
     771\begin{rationale}
     772Since each subsection describes the interpretations of an expression in terms of the interpretations
     773of its subexpressions, this chapter can be taken as describing an overload resolution algorithm that
     774uses one bottom-up pass over an expression tree. Such an algorithm was first described (for Ada) by
     775Baker~\cite{Bak:overload}. It is extended here to handle polymorphic functions and arithmetic
     776conversions. The overload resolution rules and the predefined functions have been chosen so that, in
     777programs that do not introduce overloaded declarations, expressions will have the same meaning in C
     778and in \CFA.
     779\end{rationale}
     780
     781\begin{rationale}
     782Expression syntax is quoted from the {\c11} standard. The syntax itself defines the precedence and
     783associativity of operators. The sections are arranged in decreasing order of precedence, with all
     784operators in a section having the same precedence.
    615785\end{rationale}
    616786
     
    631801const int 1;@\use{1}@
    632802const int 0;@\use{0}@
    633 forall( dtype DT ) DT * const 0;
    634 forall( ftype FT ) FT * const 0;
     803forall( dtype DT ) DT *const 0;
     804forall( ftype FT ) FT *const 0;
    635805\end{lstlisting}
    636806
    637807\semantics
    638 The \Index{valid interpretation} of an \nonterm{identifier} are given by the visible\index{visible} declarations of the identifier.
    639 
    640 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by {\c11}.
    641 The predefined integer identifiers ``\lstinline$1$'' and ``\lstinline$0$'' have the integer values 1 and 0, respectively.
    642 The other two predefined ``\lstinline$0$'' identifiers are bound to polymorphic pointer values that, when specialized\index{specialization} with a data type or function type respectively, produce a null pointer of that type.
     808The \Index{valid interpretation} of an \nonterm{identifier} are given by the visible\index{visible}
     809declarations of the identifier.
     810
     811A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type
     812and value defined by {\c11}. The predefined integer identifiers ``\lstinline$1$'' and
     813``\lstinline$0$'' have the integer values 1 and 0, respectively. The other two predefined
     814``\lstinline$0$'' identifiers are bound to polymorphic pointer values that, when
     815specialized\index{specialization} with a data type or function type respectively, produce a null
     816pointer of that type.
    643817
    644818A parenthesised expression has the same interpretations as the contained \nonterm{expression}.
    645819
    646820\examples
    647 The expression \lstinline$(void *)0$\use{0} specializes the (polymorphic) null pointer to a null pointer to \lstinline$void$. \lstinline$(const void *)0$ does the same, and also uses a safe conversion from \lstinline$void *$ to \lstinline$const void *$.
    648 In each case, the null pointer conversion is better\index{best valid interpretations} than the unsafe conversion of the integer
     821The expression \lstinline$(void *)0$\use{0} specializes the (polymorphic) null pointer to a null
     822pointer to \lstinline$void$. \lstinline$(const void *)0$ does the same, and also uses a safe
     823conversion from \lstinline$void *$ to \lstinline$const void *$. In each case, the null pointer
     824conversion is better\index{best valid interpretations} than the unsafe conversion of the integer
    649825\lstinline$0$ to a pointer.
    650826
     
    652828Note that the predefined identifiers have addresses.
    653829
    654 \CFA does not have C's concept of ``null pointer constants'', which are not typed values but special strings of tokens.
    655 The C token ``\lstinline$0$'' is an expression of type \lstinline$int$ with the value ``zero'', and it \emph{also} is a null pointer constant.
    656 Similarly,
    657 ``\lstinline$(void *)0$ is an expression of type \lstinline$(void *)$ whose value is a null pointer, and it also is a null pointer constant.
    658 However, in C, ``\lstinline$(void *)(void *)0$'' is
    659 \emph{not} a null pointer constant, even though it is null-valued, a pointer, and constant! The semantics of C expressions contain many special cases to deal with subexpressions that are null pointer constants.
    660 
    661 \CFA handles these cases through overload resolution.
    662 The declaration
    663 \begin{lstlisting}
    664 forall( dtype DT ) DT * const 0;
    665 \end{lstlisting} means that \lstinline$0$ is a polymorphic object, and contains a value that can have \emph{any} pointer-to-object type or pointer-to-incomplete type.
    666 The only such value is the null pointer.
    667 Therefore the type \emph{alone} is enough to identify a null pointer.
    668 Where C defines an operator with a special case for the null pointer constant, \CFA defines predefined functions with a polymorphic object parameter.
     830\CFA does not have C's concept of ``null pointer constants'', which are not typed values but
     831special strings of tokens. The C token ``\lstinline$0$'' is an expression of type \lstinline$int$
     832with the value ``zero'', and it \emph{also} is a null pointer constant. Similarly,
     833``\lstinline$(void *)0$ is an expression of type \lstinline$(void *)$ whose value is a null pointer,
     834and it also is a null pointer constant. However, in C, ``\lstinline$(void *)(void *)0$'' is
     835\emph{not} a null pointer constant, even though it is null-valued, a pointer, and constant! The
     836semantics of C expressions contain many special cases to deal with subexpressions that are null
     837pointer constants.
     838
     839\CFA handles these cases through overload resolution. The declaration
     840\begin{lstlisting}
     841forall( dtype DT ) DT *const 0;
     842\end{lstlisting}
     843means that \lstinline$0$ is a polymorphic object, and contains a value that can have \emph{any}
     844pointer-to-object type or pointer-to-incomplete type. The only such value is the null pointer.
     845Therefore the type \emph{alone} is enough to identify a null pointer. Where C defines an operator
     846with a special case for the null pointer constant, \CFA defines predefined functions with a
     847polymorphic object parameter.
    669848\end{rationale}
    670849
     
    672851\subsubsection{Generic selection}
    673852
    674 \constraints The best interpretation of the controlling expression shall be unambiguous\index{ambiguous interpretation}, and shall have type compatible with at most one of the types named in its generic association list.
    675 If a generic selection has no \lstinline$default$ generic association, the best interpretation of its controlling expression shall have type compatible with exactly one of the types named in its generic association list.
     853\constraints The best interpretation of the controlling expression shall be
     854unambiguous\index{ambiguous interpretation}, and shall have type compatible with at most one of the
     855types named in its generic association list. If a generic selection has no \lstinline$default$
     856generic association, the best interpretation of its controlling expression shall have type
     857compatible with exactly one of the types named in its generic association list.
    676858
    677859\semantics
     
    701883\rewriterules
    702884\begin{lstlisting}
    703 a[b] @\rewrite@ ?[?]( b, a ) // if a has integer type@\use{?[?]}@
     885a[b] @\rewrite@ ?[?]( b, a ) // if a has integer type */@\use{?[?]}@
    704886a[b] @\rewrite@ ?[?]( a, b ) // otherwise
    705 a( @\emph{arguments}@ ) @\rewrite@ ?()( a, @\emph{arguments}@ )@\use{?()}@
     887a( ${\em arguments }$ ) @\rewrite@ ?()( a, ${\em arguments} )$@\use{?()}@
    706888a++ @\rewrite@ ?++(&( a ))@\use{?++}@
    707889a-- @\rewrite@ ?--(&( a ))@\use{?--}@
     
    713895\predefined
    714896\begin{lstlisting}
    715 forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
    716 forall( otype T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
    717 forall( otype T ) lvalue const T ?[?]( const T *, ptrdiff_t );
    718 forall( otype T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
    719 forall( otype T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
    720 forall( otype T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
    721 forall( otype T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
    722 forall( otype T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
    723 forall( otype T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
    724 forall( otype T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
    725 forall( otype T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
    726 forall( otype T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
    727 forall( otype T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
    728 forall( otype T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
    729 forall( otype T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
    730 forall( otype T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
     897forall( type T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
     898forall( type T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
     899forall( type T ) lvalue const T ?[?]( const T *, ptrdiff_t );
     900forall( type T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
     901forall( type T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
     902forall( type T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
     903forall( type T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
     904forall( type T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
     905forall( type T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
     906forall( type T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
     907forall( type T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
     908forall( type T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
     909forall( type T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
     910forall( type T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
     911forall( type T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
     912forall( type T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
    731913\end{lstlisting}
    732914\semantics
    733 The interpretations of subscript expressions are the interpretations of the corresponding function call expressions.
     915The interpretations of subscript expressions are the interpretations of the corresponding function
     916call expressions.
    734917\begin{rationale}
    735918C defines subscripting as pointer arithmetic in a way that makes \lstinline$a[i]$ and
    736 \lstinline$i[a]$ equivalent. \CFA provides the equivalence through a rewrite rule to reduce the number of overloadings of \lstinline$?[?]$.
    737 
    738 Subscript expressions are rewritten as function calls that pass the first parameter by value.
    739 This is somewhat unfortunate, since array-like types tend to be large.
    740 The alternative is to use the rewrite rule ``\lstinline$a[b]$ \rewrite \lstinline$?[?](&(a), b)$''.
    741 However, C semantics forbid this approach: the \lstinline$a$ in ``\lstinline$a[b]$'' can be an arbitrary pointer value, which does not have an address.
     919\lstinline$i[a]$ equivalent. \CFA provides the equivalence through a rewrite rule to reduce the
     920number of overloadings of \lstinline$?[?]$.
     921
     922Subscript expressions are rewritten as function calls that pass the first parameter by value. This
     923is somewhat unfortunate, since array-like types tend to be large. The alternative is to use the
     924rewrite rule ``\lstinline$a[b]$ \rewrite \lstinline$?[?](&(a), b)$''. However, C semantics forbid
     925this approach: the \lstinline$a$ in ``\lstinline$a[b]$'' can be an arbitrary pointer value, which
     926does not have an address.
    742927
    743928The repetitive form of the predefined identifiers shows up a deficiency\index{deficiencies!pointers
    744  to qualified types} of \CFA's type system.
    745 Type qualifiers are not included in type values, so polymorphic functions that take pointers to arbitrary types often come in one flavor for each possible qualification of the pointed-at type.
     929 to qualified types} of \CFA's type system. Type qualifiers are not included in type values, so
     930polymorphic functions that take pointers to arbitrary types often come in one flavor for each
     931possible qualification of the pointed-at type.
    746932\end{rationale}
    747933
     
    750936
    751937\semantics
    752 A \define{function designator} is an interpretation of an expression that has function type.
    753 The
    754 \nonterm{postfix-expression} in a function call may have some interpretations that are function designators and some that are not.
    755 
    756 For those interpretations of the \nonterm{postfix-expression} that are not function designators, the expression is rewritten and becomes a call of a function named ``\lstinline$?()$''.
    757 The valid interpretations of the rewritten expression are determined in the manner described below.
    758 
    759 Each combination of function designators and argument interpretations is considered.
    760 For those interpretations of the \nonterm{postfix-expression} that are \Index{monomorphic function} designators, the combination has a \Index{valid interpretation} if the function designator accepts the number of arguments given, and each argument interpretation matches the corresponding explicit parameter:
     938A \define{function designator} is an interpretation of an expression that has function type. The
     939\nonterm{postfix-expression} in a function call may have some interpretations that are function
     940designators and some that are not.
     941
     942For those interpretations of the \nonterm{postfix-expression} that are not function designators, the
     943expression is rewritten and becomes a call of a function named ``\lstinline$?()$''. The valid
     944interpretations of the rewritten expression are determined in the manner described below.
     945
     946Each combination of function designators and argument interpretations is considered. For those
     947interpretations of the \nonterm{postfix-expression} that are \Index{monomorphic function}
     948designators, the combination has a \Index{valid interpretation} if the function designator accepts
     949the number of arguments given, and each argument interpretation matches the corresponding explicit
     950parameter:
    761951\begin{itemize}
    762 \item if the argument corresponds to a parameter in the function designator's prototype, the argument interpretation must have the same type as the corresponding parameter, or be implicitly convertible to the parameter's type
    763 \item if the function designator's type does not include a prototype or if the argument corresponds to
     952\item
     953if the argument corresponds to a parameter in the function designator's prototype, the argument
     954interpretation must have the same type as the corresponding parameter, or be implicitly convertible
     955to the parameter's type
     956\item
     957if the function designator's type does not include a prototype or if the argument corresponds to
    764958``\lstinline$...$'' in a prototype, a \Index{default argument promotion} is applied to it.
    765959\end{itemize}
     
    767961
    768962For those combinations where the interpretation of the \nonterm{postfix-expression} is a
    769 \Index{polymorphic function} designator and the function designator accepts the number of arguments given, there shall be at least one set of \define{implicit argument}s for the implicit parameters such that
     963\Index{polymorphic function} designator and the function designator accepts the number of arguments
     964given, there shall be at least one set of \define{implicit argument}s for the implicit parameters
     965such that
    770966\begin{itemize}
    771967\item
    772 If the declaration of the implicit parameter uses \Index{type-class} \lstinline$type$\use{type}, the implicit argument must be an object type;
    773 if it uses \lstinline$dtype$, the implicit argument must be an object type or an incomplete type;
    774 and if it uses \lstinline$ftype$, the implicit argument must be a function type.
    775 
    776 \item if an explicit parameter's type uses any implicit parameters, then the corresponding explicit argument must have a type that is (or can be safely converted\index{safe conversion} to) the type produced by substituting the implicit arguments for the implicit parameters in the explicit parameter type.
    777 
    778 \item the remaining explicit arguments must match the remaining explicit parameters, as described for monomorphic function designators.
    779 
    780 \item for each \Index{assertion parameter} in the function designator's type, there must be an object or function with the same identifier that is visible at the call site and whose type is compatible with or can be specialized to the type of the assertion declaration.
     968If the declaration of the implicit parameter uses \Index{type-class} \lstinline$type$\use{type}, the
     969implicit argument must be an object type; if it uses \lstinline$dtype$, the implicit argument must
     970be an object type or an incomplete type; and if it uses \lstinline$ftype$, the implicit argument
     971must be a function type.
     972
     973\item
     974if an explicit parameter's type uses any implicit parameters, then the corresponding explicit
     975argument must have a type that is (or can be safely converted\index{safe conversion} to) the type
     976produced by substituting the implicit arguments for the implicit parameters in the explicit
     977parameter type.
     978
     979\item
     980the remaining explicit arguments must match the remaining explicit parameters, as described for
     981monomorphic function designators.
     982
     983\item
     984for each \Index{assertion parameter} in the function designator's type, there must be an object or
     985function with the same identifier that is visible at the call site and whose type is compatible with
     986or can be specialized to the type of the assertion declaration.
    781987\end{itemize}
    782 There is a valid interpretation for each such set of implicit parameters.
    783 The type of each valid interpretation is the return type of the function designator with implicit parameter values substituted for the implicit arguments.
    784 
    785 A valid interpretation is ambiguous\index{ambiguous interpretation} if the function designator or any of the argument interpretations is ambiguous.
    786 
    787 Every valid interpretation whose return type is not compatible with any other valid interpretation's return type is an interpretation of the function call expression.
    788 
    789 Every set of valid interpretations that have mutually compatible\index{compatible type} result types also produces an interpretation of the function call expression.
    790 The type of the interpretation is the \Index{composite type} of the types of the valid interpretations, and the value of the interpretation is that of the \Index{best valid interpretation}.
    791 \begin{rationale}
    792 One desirable property of a polymorphic programming language is \define{generalizability}: the ability to replace an abstraction with a more general but equivalent abstraction without requiring changes in any of the uses of the original\cite{Cormack90}.
    793 For instance, it should be possible to replace a function ``\lstinline$int f( int );$'' with ``\lstinline$forall( otype T ) T f( T );$'' without affecting any calls of \lstinline$f$.
     988There is a valid interpretation for each such set of implicit parameters. The type of each valid
     989interpretation is the return type of the function designator with implicit parameter values
     990substituted for the implicit arguments.
     991
     992A valid interpretation is ambiguous\index{ambiguous interpretation} if the function designator or
     993any of the argument interpretations is ambiguous.
     994
     995Every valid interpretation whose return type is not compatible with any other valid interpretation's
     996return type is an interpretation of the function call expression.
     997
     998Every set of valid interpretations that have mutually compatible\index{compatible type} result types
     999also produces an interpretation of the function call expression. The type of the interpretation is
     1000the \Index{composite type} of the types of the valid interpretations, and the value of the
     1001interpretation is that of the \Index{best valid interpretation}.
     1002\begin{rationale}
     1003One desirable property of a polymorphic programming language is \define{generalizability}: the
     1004ability to replace an abstraction with a more general but equivalent abstraction without requiring
     1005changes in any of the uses of the original\cite{Cormack90}. For instance, it should be possible to
     1006replace a function ``\lstinline$int f( int );$'' with ``\lstinline$forall( type T ) T f( T );$''
     1007without affecting any calls of \lstinline$f$.
    7941008
    7951009\CFA\index{deficiencies!generalizability} does not fully possess this property, because
     
    8011015float f;
    8021016double d;
    803 f = g( f, f );          // (1)
    804 f = g( i, f );          // (2) (safe conversion to float)
    805 f = g( d, f );          // (3) (unsafe conversion to float)
    806 \end{lstlisting}
    807 If \lstinline$g$ was replaced by ``\lstinline$forall( otype T ) T g( T, T );$'', the first and second calls would be unaffected, but the third would change: \lstinline$f$ would be converted to
     1017f = g( f, f );  // (1)
     1018f = g( i, f );  // (2) (safe conversion to float)
     1019f = g( d, f );  // (3) (unsafe conversion to float)
     1020\end{lstlisting}
     1021If \lstinline$g$ was replaced by ``\lstinline$forall( type T ) T g( T, T );$'', the first and second
     1022calls would be unaffected, but the third would change: \lstinline$f$ would be converted to
    8081023\lstinline$double$, and the result would be a \lstinline$double$.
    8091024
    810 Another example is the function ``\lstinline$void h( int *);$''.
    811 This function can be passed a
    812 \lstinline$void *$ argument, but the generalization ``\lstinline$forall( otype T ) void h( T *);$'' can not.
    813 In this case, \lstinline$void$ is not a valid value for \lstinline$T$ because it is not an object type.
    814 If unsafe conversions were allowed, \lstinline$T$ could be inferred to be \emph{any} object type, which is undesirable.
     1025Another example is the function ``\lstinline$void h( int *);$''. This function can be passed a
     1026\lstinline$void *$ argument, but the generalization ``\lstinline$forall( type T ) void h( T *);$''
     1027can not. In this case, \lstinline$void$ is not a valid value for \lstinline$T$ because it is not an
     1028object type. If unsafe conversions were allowed, \lstinline$T$ could be inferred to be \emph{any}
     1029object type, which is undesirable.
    8151030\end{rationale}
    8161031
     
    8181033A function called ``\lstinline$?()$'' might be part of a numerical differentiation package.
    8191034\begin{lstlisting}
    820 extern otype Derivative;
     1035extern type Derivative;
    8211036extern double ?()( Derivative, double );
    8221037extern Derivative derivative_of( double (*f)( double ) );
     
    8301045For that interpretation, the function call is treated as ``\lstinline$?()( sin_dx, 12.9 )$''.
    8311046\begin{lstlisting}
    832 int f( long );          // (1)
    833 int f( int, int );      // (2)
     1047int f( long );          // (1) 
     1048int f( int, int );      // (2) 
    8341049int f( int *);          // (3)
     1050
    8351051int i = f( 5 );         // calls (1)
    8361052\end{lstlisting}
    837 Function (1) provides a valid interpretation of ``\lstinline$f( 5 )$'', using an implicit \lstinline$int$ to \lstinline$long$ conversion.
    838 The other functions do not, since the second requires two arguments, and since there is no implicit conversion from \lstinline$int$ to \lstinline$int *$ that could be used with the third function.
    839 
    840 \begin{lstlisting}
    841 forall( otype T ) T h( T );
     1053Function (1) provides a valid interpretation of ``\lstinline$f( 5 )$'', using an implicit
     1054\lstinline$int$ to \lstinline$long$ conversion. The other functions do not, since the second
     1055requires two arguments, and since there is no implicit conversion from \lstinline$int$ to
     1056\lstinline$int *$ that could be used with the third function.
     1057
     1058\begin{lstlisting}
     1059forall( type T ) T h( T );
    8421060double d = h( 1.5 );
    8431061\end{lstlisting}
     
    8461064
    8471065\begin{lstlisting}
    848 forall( otype T, otype U ) void g( T, U );      // (4)
    849 forall( otype T ) void g( T, T );                       // (5)
    850 forall( otype T ) void g( T, long );                    // (6)
    851 void g( long, long );                                           // (7)
     1066forall( type T, type U ) void g( T, U );        // (4)
     1067forall( type T ) void g( T, T );                        // (5)
     1068forall( type T ) void g( T, long );                     // (6)
     1069void g( long, long );                                           // (7) 
    8521070double d;
    8531071int i;
    8541072int *p;
    855 g( d, d );                      // calls (5)
    856 g( d, i );                      // calls (6)
    857 g( i, i );                      // calls (7)
     1073
     1074g( d, d );                      // calls (5)
     1075g( d, i );                      // calls (6)
     1076g( i, i );                      // calls (7)
    8581077g( i, p );                      // calls (4)
    8591078\end{lstlisting}
    860 The first call has valid interpretations for all four versions of \lstinline$g$. (6) and (7) are discarded because they involve unsafe \lstinline$double$-to-\lstinline$long$ conversions. (5) is chosen because it is less polymorphic than (4).
    861 
    862 For the second call, (7) is again discarded.
    863 Of the remaining interpretations for (4), (5), and (6) (with \lstinline$i$ converted to \lstinline$long$), (6) is chosen because it is the least polymorphic.
    864 
    865 The third call has valid interpretations for all of the functions;
    866 (7) is chosen since it is not polymorphic at all.
    867 
    868 The fourth call has no interpretation for (5), because its arguments must have compatible type. (4) is chosen because it does not involve unsafe conversions.
    869 \begin{lstlisting}
    870 forall( otype T ) T min( T, T );
     1079The first call has valid interpretations for all four versions of \lstinline$g$. (6) and (7) are
     1080discarded because they involve unsafe \lstinline$double$-to-\lstinline$long$ conversions. (5) is
     1081chosen because it is less polymorphic than (4).
     1082
     1083For the second call, (7) is again discarded. Of the remaining interpretations for (4), (5), and (6)
     1084(with \lstinline$i$ converted to \lstinline$long$), (6) is chosen because it is the least
     1085polymorphic.
     1086
     1087The third call has valid interpretations for all of the functions; (7) is chosen since it is not
     1088polymorphic at all.
     1089
     1090The fourth call has no interpretation for (5), because its arguments must have compatible type. (4)
     1091is chosen because it does not involve unsafe conversions.
     1092\begin{lstlisting}
     1093forall( type T ) T min( T, T );
    8711094double max( double, double );
    872 trait min_max( T ) {@\impl{min_max}@
     1095context min_max( T ) {@\impl{min_max}@
    8731096        T min( T, T );
    8741097        T max( T, T );
    8751098}
    876 forall( otype U | min_max( U ) ) void shuffle( U, U );
    877 shuffle( 9, 10 );
    878 \end{lstlisting}
    879 The only possibility for \lstinline$U$ is \lstinline$double$, because that is the type used in the only visible \lstinline$max$ function. 9 and 10 must be converted to \lstinline$double$, and
     1099forall( type U | min_max( U ) ) void shuffle( U, U );
     1100shuffle(9, 10);
     1101\end{lstlisting}
     1102The only possibility for \lstinline$U$ is \lstinline$double$, because that is the type used in the
     1103only visible \lstinline$max$ function. 9 and 10 must be converted to \lstinline$double$, and
    8801104\lstinline$min$ must be specialized with \lstinline$T$ bound to \lstinline$double$.
    8811105\begin{lstlisting}
    882 extern void q( int );           // (8)
    883 extern void q( void * );        // (9)
     1106extern void q( int );           // (8) 
     1107extern void q( void * );        // (9) 
    8841108extern void r();
    8851109q( 0 );
    8861110r( 0 );
    8871111\end{lstlisting}
    888 The \lstinline$int 0$ could be passed to (8), or the \lstinline$(void *)$ \Index{specialization} of the null pointer\index{null pointer} \lstinline$0$\use{0} could be passed to (9).
    889 The former is chosen because the \lstinline$int$ \lstinline$0$ is \Index{less polymorphic}.
    890 For the same reason, \lstinline$int$ \lstinline$0$ is passed to \lstinline$r()$, even though it has \emph{no} declared parameter types.
     1112The \lstinline$int 0$ could be passed to (8), or the \lstinline$(void *)$ \Index{specialization} of
     1113the null pointer\index{null pointer} \lstinline$0$\use{0} could be passed to (9). The former is
     1114chosen because the \lstinline$int$ \lstinline$0$ is \Index{less polymorphic}. For
     1115the same reason, \lstinline$int$ \lstinline$0$ is passed to \lstinline$r()$, even though it has
     1116\emph{no} declared parameter types.
    8911117
    8921118
    8931119\subsubsection{Structure and union members}
    8941120
    895 \semantics In the member selection expression ``\lstinline$s$.\lstinline$m$'', there shall be at least one interpretation of \lstinline$s$ whose type is a structure type or union type containing a member named \lstinline$m$.
    896 If two or more interpretations of \lstinline$s$ have members named
    897 \lstinline$m$ with mutually compatible types, then the expression has an \Index{ambiguous interpretation} whose type is the composite type of the types of the members.
    898 If an interpretation of \lstinline$s$ has a member \lstinline$m$ whose type is not compatible with any other
    899 \lstinline$s$'s \lstinline$m$, then the expression has an interpretation with the member's type.
    900 The expression has no other interpretations.
     1121\semantics In the member selection expression ``\lstinline$s$.\lstinline$m$'', there shall be at
     1122least one interpretation of \lstinline$s$ whose type is a structure type or union type containing a
     1123member named \lstinline$m$. If two or more interpretations of \lstinline$s$ have members named
     1124\lstinline$m$ with mutually compatible types, then the expression has an \Index{ambiguous
     1125interpretation} whose type is the composite type of the types of the members. If an interpretation
     1126of \lstinline$s$ has a member \lstinline$m$ whose type is not compatible with any other
     1127\lstinline$s$'s \lstinline$m$, then the expression has an interpretation with the member's type. The
     1128expression has no other interpretations.
    9011129
    9021130The expression ``\lstinline$p->m$'' has the same interpretations as the expression
     
    9081136\predefined
    9091137\begin{lstlisting}
    910 _Bool ?++( volatile _Bool * ), ?++( _Atomic volatile _Bool * );
    911 char ?++( volatile char * ), ?++( _Atomic volatile char * );
    912 signed char ?++( volatile signed char * ), ?++( _Atomic volatile signed char * );
    913 unsigned char ?++( volatile signed char * ), ?++( _Atomic volatile signed char * );
    914 short int ?++( volatile short int * ), ?++( _Atomic volatile short int * );
    915 unsigned short int ?++( volatile unsigned short int * ), ?++( _Atomic volatile unsigned short int * );
    916 int ?++( volatile int * ), ?++( _Atomic volatile int * );
    917 unsigned int ?++( volatile unsigned int * ), ?++( _Atomic volatile unsigned int * );
    918 long int ?++( volatile long int * ), ?++( _Atomic volatile long int * );
    919 long unsigned int ?++( volatile long unsigned int * ), ?++( _Atomic volatile long unsigned int * );
    920 long long int ?++( volatile long long int * ), ?++( _Atomic volatile long long int * );
    921 long long unsigned ?++( volatile long long unsigned int * ), ?++( _Atomic volatile long long unsigned int * );
    922 float ?++( volatile float * ), ?++( _Atomic volatile float * );
    923 double ?++( volatile double * ), ?++( _Atomic volatile double * );
    924 long double ?++( volatile long double * ), ?++( _Atomic volatile long double * );
    925 
    926 forall( otype T ) T * ?++( T * restrict volatile * ), * ?++( T * _Atomic restrict volatile * );
    927 forall( otype T ) _Atomic T * ?++( _Atomic T * restrict volatile * ), * ?++( _Atomic T * _Atomic restrict volatile * );
    928 forall( otype T ) const T * ?++( const T * restrict volatile * ), * ?++( const T * _Atomic restrict volatile * );
    929 forall( otype T ) volatile T * ?++( volatile T * restrict volatile * ), * ?++( volatile T * _Atomic restrict volatile * );
    930 forall( otype T ) restrict T * ?++( restrict T * restrict volatile * ), * ?++( restrict T * _Atomic restrict volatile * );
    931 forall( otype T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
     1138_Bool ?++( volatile _Bool * ),
     1139        ?++( _Atomic volatile _Bool * );
     1140char ?++( volatile char * ),
     1141        ?++( _Atomic volatile char * );
     1142signed char ?++( volatile signed char * ),
     1143        ?++( _Atomic volatile signed char * );
     1144unsigned char ?++( volatile signed char * ),
     1145        ?++( _Atomic volatile signed char * );
     1146short int ?++( volatile short int * ),
     1147        ?++( _Atomic volatile short int * );
     1148unsigned short int ?++( volatile unsigned short int * ),
     1149        ?++( _Atomic volatile unsigned short int * );
     1150int ?++( volatile int * ),
     1151        ?++( _Atomic volatile int * );
     1152unsigned int ?++( volatile unsigned int * ),
     1153        ?++( _Atomic volatile unsigned int * );
     1154long int ?++( volatile long int * ),
     1155        ?++( _Atomic volatile long int * );
     1156long unsigned int ?++( volatile long unsigned int * ),
     1157        ?++( _Atomic volatile long unsigned int * );
     1158long long int ?++( volatile long long int * ),
     1159        ?++( _Atomic volatile long long int * );
     1160long long unsigned ?++( volatile long long unsigned int * ),
     1161        ?++( _Atomic volatile long long unsigned int * );
     1162float ?++( volatile float * ),
     1163        ?++( _Atomic volatile float * );
     1164double ?++( volatile double * ),
     1165        ?++( _Atomic volatile double * );
     1166long double ?++( volatile long double * ),
     1167        ?++( _Atomic volatile long double * );
     1168
     1169forall( type T ) T * ?++( T * restrict volatile * ),
     1170        * ?++( T * _Atomic restrict volatile * );
     1171
     1172forall( type T ) _Atomic T * ?++( _Atomic T * restrict volatile * ),
     1173        * ?++( _Atomic T * _Atomic restrict volatile * );
     1174
     1175forall( type T ) const T * ?++( const T * restrict volatile * ),
     1176        * ?++( const T * _Atomic restrict volatile * );
     1177
     1178forall( type T ) volatile T * ?++( volatile T * restrict volatile * ),
     1179        * ?++( volatile T * _Atomic restrict volatile * );
     1180
     1181forall( type T ) restrict T * ?++( restrict T * restrict volatile * ),
     1182        * ?++( restrict T * _Atomic restrict volatile * );
     1183
     1184forall( type T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
    9321185        * ?++( _Atomic const T * _Atomic restrict volatile * );
    933 forall( otype T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
     1186
     1187forall( type T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
    9341188        * ?++( _Atomic restrict T * _Atomic restrict volatile * );
    935 forall( otype T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
     1189
     1190forall( type T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
    9361191        * ?++( _Atomic volatile T * _Atomic restrict volatile * );
    937 forall( otype T ) const restrict T * ?++( const restrict T * restrict volatile * ),
     1192
     1193forall( type T ) const restrict T * ?++( const restrict T * restrict volatile * ),
    9381194        * ?++( const restrict T * _Atomic restrict volatile * );
    939 forall( otype T ) const volatile T * ?++( const volatile T * restrict volatile * ),
     1195
     1196forall( type T ) const volatile T * ?++( const volatile T * restrict volatile * ),
    9401197        * ?++( const volatile T * _Atomic restrict volatile * );
    941 forall( otype T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
     1198
     1199forall( type T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
    9421200        * ?++( restrict volatile T * _Atomic restrict volatile * );
    943 forall( otype T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
     1201
     1202forall( type T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
    9441203        * ?++( _Atomic const restrict T * _Atomic restrict volatile * );
    945 forall( otype T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
     1204
     1205forall( type T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
    9461206        * ?++( _Atomic const volatile T * _Atomic restrict volatile * );
    947 forall( otype T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
     1207
     1208forall( type T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
    9481209        * ?++( _Atomic restrict volatile T * _Atomic restrict volatile * );
    949 forall( otype T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
     1210
     1211forall( type T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
    9501212        * ?++( const restrict volatile T * _Atomic restrict volatile * );
    951 forall( otype T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
     1213
     1214forall( type T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
    9521215        * ?++( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    9531216
    954 _Bool ?--( volatile _Bool * ), ?--( _Atomic volatile _Bool * );
    955 char ?--( volatile char * ), ?--( _Atomic volatile char * );
    956 signed char ?--( volatile signed char * ), ?--( _Atomic volatile signed char * );
    957 unsigned char ?--( volatile signed char * ), ?--( _Atomic volatile signed char * );
    958 short int ?--( volatile short int * ), ?--( _Atomic volatile short int * );
    959 unsigned short int ?--( volatile unsigned short int * ), ?--( _Atomic volatile unsigned short int * );
    960 int ?--( volatile int * ), ?--( _Atomic volatile int * );
    961 unsigned int ?--( volatile unsigned int * ), ?--( _Atomic volatile unsigned int * );
    962 long int ?--( volatile long int * ), ?--( _Atomic volatile long int * );
    963 long unsigned int ?--( volatile long unsigned int * ), ?--( _Atomic volatile long unsigned int * );
    964 long long int ?--( volatile long long int * ), ?--( _Atomic volatile long long int * );
    965 long long unsigned ?--( volatile long long unsigned int * ), ?--( _Atomic volatile long long unsigned int * );
    966 float ?--( volatile float * ), ?--( _Atomic volatile float * );
    967 double ?--( volatile double * ), ?--( _Atomic volatile double * );
    968 long double ?--( volatile long double * ), ?--( _Atomic volatile long double * );
    969 
    970 forall( otype T ) T * ?--( T * restrict volatile * ), * ?--( T * _Atomic restrict volatile * );
    971 forall( otype T ) _Atomic T * ?--( _Atomic T * restrict volatile * ), * ?--( _Atomic T * _Atomic restrict volatile * );
    972 forall( otype T ) const T * ?--( const T * restrict volatile * ), * ?--( const T * _Atomic restrict volatile * );
    973 forall( otype T ) volatile T * ?--( volatile T * restrict volatile * ), * ?--( volatile T * _Atomic restrict volatile * );
    974 forall( otype T ) restrict T * ?--( restrict T * restrict volatile * ), * ?--( restrict T * _Atomic restrict volatile * );
    975 forall( otype T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
     1217_Bool ?--( volatile _Bool * ),
     1218        ?--( _Atomic volatile _Bool * );
     1219char ?--( volatile char * ),
     1220        ?--( _Atomic volatile char * );
     1221signed char ?--( volatile signed char * ),
     1222        ?--( _Atomic volatile signed char * );
     1223unsigned char ?--( volatile signed char * ),
     1224        ?--( _Atomic volatile signed char * );
     1225short int ?--( volatile short int * ),
     1226        ?--( _Atomic volatile short int * );
     1227unsigned short int ?--( volatile unsigned short int * ),
     1228        ?--( _Atomic volatile unsigned short int * );
     1229int ?--( volatile int * ),
     1230        ?--( _Atomic volatile int * );
     1231unsigned int ?--( volatile unsigned int * ),
     1232        ?--( _Atomic volatile unsigned int * );
     1233long int ?--( volatile long int * ),
     1234        ?--( _Atomic volatile long int * );
     1235long unsigned int ?--( volatile long unsigned int * ),
     1236        ?--( _Atomic volatile long unsigned int * );
     1237long long int ?--( volatile long long int * ),
     1238        ?--( _Atomic volatile long long int * );
     1239long long unsigned ?--( volatile long long unsigned int * ),
     1240        ?--( _Atomic volatile long long unsigned int * );
     1241float ?--( volatile float * ),
     1242        ?--( _Atomic volatile float * );
     1243double ?--( volatile double * ),
     1244        ?--( _Atomic volatile double * );
     1245long double ?--( volatile long double * ),
     1246        ?--( _Atomic volatile long double * );
     1247
     1248forall( type T ) T * ?--( T * restrict volatile * ),
     1249        * ?--( T * _Atomic restrict volatile * );
     1250
     1251forall( type T ) _Atomic T * ?--( _Atomic T * restrict volatile * ),
     1252        * ?--( _Atomic T * _Atomic restrict volatile * );
     1253
     1254forall( type T ) const T * ?--( const T * restrict volatile * ),
     1255        * ?--( const T * _Atomic restrict volatile * );
     1256
     1257forall( type T ) volatile T * ?--( volatile T * restrict volatile * ),
     1258        * ?--( volatile T * _Atomic restrict volatile * );
     1259
     1260forall( type T ) restrict T * ?--( restrict T * restrict volatile * ),
     1261        * ?--( restrict T * _Atomic restrict volatile * );
     1262
     1263forall( type T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
    9761264        * ?--( _Atomic const T * _Atomic restrict volatile * );
    977 forall( otype T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
     1265
     1266forall( type T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
    9781267        * ?--( _Atomic restrict T * _Atomic restrict volatile * );
    979 forall( otype T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
     1268
     1269forall( type T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
    9801270        * ?--( _Atomic volatile T * _Atomic restrict volatile * );
    981 forall( otype T ) const restrict T * ?--( const restrict T * restrict volatile * ),
     1271
     1272forall( type T ) const restrict T * ?--( const restrict T * restrict volatile * ),
    9821273        * ?--( const restrict T * _Atomic restrict volatile * );
    983 forall( otype T ) const volatile T * ?--( const volatile T * restrict volatile * ),
     1274
     1275forall( type T ) const volatile T * ?--( const volatile T * restrict volatile * ),
    9841276        * ?--( const volatile T * _Atomic restrict volatile * );
    985 forall( otype T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
     1277
     1278forall( type T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
    9861279        * ?--( restrict volatile T * _Atomic restrict volatile * );
    987 forall( otype T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
     1280
     1281forall( type T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
    9881282        * ?--( _Atomic const restrict T * _Atomic restrict volatile * );
    989 forall( otype T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
     1283
     1284forall( type T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
    9901285        * ?--( _Atomic const volatile T * _Atomic restrict volatile * );
    991 forall( otype T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
     1286
     1287forall( type T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
    9921288        * ?--( _Atomic restrict volatile T * _Atomic restrict volatile * );
    993 forall( otype T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
     1289
     1290forall( type T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
    9941291        * ?--( const restrict volatile T * _Atomic restrict volatile * );
    995 forall( otype T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
     1292
     1293forall( type T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
    9961294        * ?--( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    9971295\end{lstlisting}
     
    10101308
    10111309\begin{rationale}
    1012 Note that ``\lstinline$++$'' and ``\lstinline$--$'' are rewritten as function calls that are given a pointer to that operand. (This is true of all operators that modify an operand.) As Hamish Macdonald has pointed out, this forces the modified operand of such expressions to be an lvalue.
    1013 This partially enforces the C semantic rule that such operands must be \emph{modifiable} lvalues.
    1014 \end{rationale}
    1015 
    1016 \begin{rationale}
    1017 In C, a semantic rule requires that pointer operands of increment and decrement be pointers to object types.
    1018 Hence, \lstinline$void *$ objects cannot be incremented.
    1019 In \CFA, the restriction follows from the use of a \lstinline$type$ parameter in the predefined function definitions, as opposed to \lstinline$dtype$, since only object types can be inferred arguments corresponding to the type parameter \lstinline$T$.
     1310Note that ``\lstinline$++$'' and ``\lstinline$--$'' are rewritten as function calls that are given a
     1311pointer to that operand. (This is true of all operators that modify an operand.) As Hamish Macdonald
     1312has pointed out, this forces the modified operand of such expressions to be an lvalue. This
     1313partially enforces the C semantic rule that such operands must be \emph{modifiable} lvalues.
     1314\end{rationale}
     1315
     1316\begin{rationale}
     1317In C, a semantic rule requires that pointer operands of increment and decrement be pointers to
     1318object types. Hence, \lstinline$void *$ objects cannot be incremented. In \CFA, the restriction
     1319follows from the use of a \lstinline$type$ parameter in the predefined function definitions, as
     1320opposed to \lstinline$dtype$, since only object types can be inferred arguments corresponding to the
     1321type parameter \lstinline$T$.
    10201322\end{rationale}
    10211323
    10221324\semantics
    1023 First, each interpretation of the operand of an increment or decrement expression is considered separately.
    1024 For each interpretation that is a bit-field or is declared with the
    1025 \lstinline$register$\index{register@{\lstinline$register$}} \index{Itorage-class specifier}, the expression has one valid interpretation, with the type of the operand, and the expression is ambiguous if the operand is.
    1026 
    1027 For the remaining interpretations, the expression is rewritten, and the interpretations of the expression are the interpretations of the corresponding function call.
    1028 Finally, all interpretations of the expression produced for the different interpretations of the operand are combined to produce the interpretations of the expression as a whole; where interpretations have compatible result types, the best interpretations are selected in the manner described for function call expressions.
     1325First, each interpretation of the operand of an increment or decrement expression is considered
     1326separately. For each interpretation that is a bit-field or is declared with the
     1327\lstinline$register$\index{register@{\lstinline$register$}} \index{Itorage-class specifier}, the
     1328expression has one valid interpretation, with the type of the operand, and the expression is
     1329ambiguous if the operand is.
     1330
     1331For the remaining interpretations, the expression is rewritten, and the interpretations of the
     1332expression are the interpretations of the corresponding function call. Finally, all interpretations
     1333of the expression produced for the different interpretations of the operand are combined to produce
     1334the interpretations of the expression as a whole; where interpretations have compatible result
     1335types, the best interpretations are selected in the manner described for function call expressions.
    10291336
    10301337\examples
     
    10391346\lstinline$vs++$ calls the \lstinline$?++$ function with the \lstinline$volatile short *$ parameter.
    10401347\lstinline$s++$ does the same, applying the safe conversion from \lstinline$short int *$ to
    1041 \lstinline$volatile short int *$.
    1042 Note that there is no conversion that adds an \lstinline$_Atomic$ qualifier, so the \lstinline$_Atomic volatile short int$ overloading does not provide a valid interpretation.
     1348\lstinline$volatile short int *$. Note that there is no conversion that adds an \lstinline$_Atomic$
     1349qualifier, so the \lstinline$_Atomic volatile short int$ overloading does not provide a valid
     1350interpretation.
    10431351\end{sloppypar}
    10441352
    1045 There is no safe conversion from \lstinline$const short int *$ to \lstinline$volatile short int *$, and no \lstinline$?++$ function that accepts a \lstinline$const *$ parameter, so \lstinline$cs++$ has no valid interpretations.
    1046 
    1047 The best valid interpretation of \lstinline$as++$ calls the \lstinline$short ?++$ function with the \lstinline$_Atomic volatile short int *$ parameter, applying a safe conversion to add the \lstinline$volatile$ qualifier.
    1048 \begin{lstlisting}
    1049 char * const restrict volatile * restrict volatile pqpc;
    1050 pqpc++
    1051 char * * restrict volatile ppc;
    1052 ppc++;
    1053 \end{lstlisting}
    1054 Since \lstinline$&(pqpc)$ has type \lstinline$char * const restrict volatile * restrict volatile *$, the best valid interpretation of \lstinline$pqpc++$ calls the polymorphic \lstinline$?++$ function with the \lstinline$const restrict volatile T * restrict volatile *$ parameter, inferring \lstinline$T$ to be \lstinline$char *$.
    1055 
    1056 \lstinline$ppc++$ calls the same function, again inferring \lstinline$T$ to be \lstinline$char *$, and using the safe conversions from \lstinline$T$ to \lstinline$T const$ \lstinline$restrict volatile$.
    1057 
    1058 \begin{rationale}
    1059 Increment and decrement expressions show up a deficiency of \CFA's type system.
    1060 There is no such thing as a pointer to a register object or bit-field\index{deficiencies!pointers to bit-fields}.
    1061 Therefore, there is no way to define a function that alters them, and hence no way to define increment and decrement functions for them.
    1062 As a result, the semantics of increment and decrement expressions must treat them specially.
    1063 This holds true for all of the operators that may modify such objects.
    1064 \end{rationale}
    1065 
    1066 \begin{rationale}
    1067 The polymorphic overloadings for pointer increment and decrement can be understood by considering increasingly complex types.
     1353There is no safe conversion from \lstinline$const short int *$ to \lstinline$volatile short int *$,
     1354and no \lstinline$?++$ function that accepts a \lstinline$const *$ parameter, so \lstinline$cs++$
     1355has no valid interpretations.
     1356
     1357The best valid interpretation of \lstinline$as++$ calls the \lstinline$short ?++$ function with the
     1358\lstinline$_Atomic volatile short int *$ parameter, applying a safe conversion to add the
     1359\lstinline$volatile$ qualifier.
     1360
     1361\begin{lstlisting}
     1362char * const restrict volatile * restrict volatile pqpc; pqpc++
     1363char * * restrict volatile ppc; ppc++;
     1364\end{lstlisting}
     1365Since \lstinline$&(pqpc)$ has type \lstinline$char * const restrict volatile * restrict volatile *$,
     1366the best valid interpretation of \lstinline$pqpc++$ calls the polymorphic \lstinline$?++$ function
     1367with the \lstinline$const restrict volatile T * restrict volatile *$ parameter, inferring
     1368\lstinline$T$ to be \lstinline$char *$.
     1369
     1370\begin{sloppypar}
     1371\lstinline$ppc++$ calls the same function, again inferring \lstinline$T$ to be \lstinline$char *$,
     1372and using the safe conversions from \lstinline$T$ to \lstinline$T const restrict volatile$.
     1373\end{sloppypar}
     1374
     1375\begin{rationale}
     1376Increment and decrement expressions show up a deficiency of \CFA's type system. There is no such
     1377thing as a pointer to a register object or bit-field\index{deficiencies!pointers to bit-fields}.
     1378Therefore, there is no way to define a function that alters them, and hence no way to define
     1379increment and decrement functions for them. As a result, the semantics of increment and decrement
     1380expressions must treat them specially. This holds true for all of the operators that may modify
     1381such objects.
     1382\end{rationale}
     1383
     1384\begin{rationale}
     1385The polymorphic overloadings for pointer increment and decrement can be understood by considering
     1386increasingly complex types.
    10681387\begin{enumerate}
    10691388\item
    1070 ``\lstinline$char * p; p++;$''.
    1071 The argument to \lstinline$?++$ has type \lstinline$char * *$, and the result has type \lstinline$char *$.
    1072 The expression would be valid if \lstinline$?++$ were declared by
    1073 \begin{lstlisting}
    1074 forall( otype T ) T * ?++( T * * );
    1075 \end{lstlisting} with \lstinline$T$ inferred to be \lstinline$char$.
    1076 
    1077 \item
    1078 ``\lstinline$char *restrict volatile qp; qp++$''.
    1079 The result again has type \lstinline$char *$, but the argument now has type \lstinline$char *restrict volatile *$, so it cannot be passed to the hypothetical function declared in point 1.
    1080 Hence the actual predefined function is
    1081 \begin{lstlisting}
    1082 forall( otype T ) T * ?++( T * restrict volatile * );
    1083 \end{lstlisting} which also accepts a \lstinline$char * *$ argument, because of the safe conversions that add
    1084 \lstinline$volatile$ and \lstinline$restrict$ qualifiers. (The parameter is not const-qualified, so constant pointers cannot be incremented.)
    1085 
    1086 \item
    1087 ``\lstinline$char *_Atomic ap; ap++$''.
    1088 The result again has type \lstinline$char *$, but no safe conversion adds an \lstinline$_Atomic$ qualifier, so the function in point 2 is not applicable.
    1089 A separate overloading of \lstinline$?++$ is required.
    1090 
    1091 \item
    1092 ``\lstinline$char const volatile * pq; pq++$''.
    1093 Here the result has type
     1389``\lstinline$char * p; p++;$''. The argument to \lstinline$?++$ has type \lstinline$char * *$, and
     1390the result has type \lstinline$char *$. The expression would be valid if \lstinline$?++$ were
     1391declared by
     1392\begin{lstlisting}
     1393forall( type T ) T * ?++( T * * );
     1394\end{lstlisting}
     1395with \lstinline$T$ inferred to be \lstinline$char$.
     1396
     1397\item
     1398``\lstinline$char *restrict volatile qp; qp++$''. The result again has type \lstinline$char *$, but
     1399the argument now has type \lstinline$char *restrict volatile *$, so it cannot be passed to the
     1400hypothetical function declared in point 1. Hence the actual predefined function is
     1401\begin{lstlisting}
     1402forall( type T ) T * ?++( T * restrict volatile * );
     1403\end{lstlisting}
     1404which also accepts a \lstinline$char * *$ argument, because of the safe conversions that add
     1405\lstinline$volatile$ and \lstinline$restrict$ qualifiers. (The parameter is not const-qualified, so
     1406constant pointers cannot be incremented.)
     1407
     1408\item
     1409``\lstinline$char *_Atomic ap; ap++$''. The result again has type \lstinline$char *$, but no safe
     1410conversion adds an \lstinline$_Atomic$ qualifier, so the function in point 2 is not applicable. A
     1411separate overloading of \lstinline$?++$ is required.
     1412
     1413\item
     1414``\lstinline$char const volatile * pq; pq++$''. Here the result has type
    10941415\lstinline$char const volatile *$, so a new overloading is needed:
    10951416\begin{lstlisting}
    1096 forall( otype T ) T const volatile * ?++( T const volatile *restrict volatile * );
    1097 \end{lstlisting}
    1098 One overloading is needed for each combination of qualifiers in the pointed-at type\index{deficiencies!pointers to qualified types}.
     1417forall( type T ) T const volatile * ?++( T const volatile *restrict volatile * );
     1418\end{lstlisting}
     1419One overloading is needed for each combination of qualifiers in the pointed-at
     1420type\index{deficiencies!pointers to qualified types}.
    10991421 
    11001422\item
    1101 ``\lstinline$float *restrict * prp; prp++$''.
    1102 The \lstinline$restrict$ qualifier is handled just like \lstinline$const$ and \lstinline$volatile$ in the previous case:
    1103 \begin{lstlisting}
    1104 forall( otype T ) T restrict * ?++( T restrict *restrict volatile * );
    1105 \end{lstlisting} with \lstinline$T$ inferred to be \lstinline$float *$.
    1106 This looks odd, because {\c11} contains a constraint that requires restrict-qualified types to be pointer-to-object types, and \lstinline$T$ is not syntactically a pointer type. \CFA loosens the constraint.
     1423``\lstinline$float *restrict * prp; prp++$''. The \lstinline$restrict$ qualifier is handled just
     1424like \lstinline$const$ and \lstinline$volatile$ in the previous case:
     1425\begin{lstlisting}
     1426forall( type T ) T restrict * ?++( T restrict *restrict volatile * );
     1427\end{lstlisting}
     1428with \lstinline$T$ inferred to be \lstinline$float *$. This looks odd, because {\c11} contains a
     1429constraint that requires restrict-qualified types to be pointer-to-object types, and \lstinline$T$
     1430is not syntactically a pointer type. \CFA loosens the constraint.
    11071431\end{enumerate}
    11081432\end{rationale}
     
    11121436
    11131437\semantics
    1114 A compound literal has one interpretation, with the type given by the \nonterm{type-name} of the compound literal.
     1438A compound literal has one interpretation, with the type given by the \nonterm{type-name} of the
     1439compound literal.
    11151440
    11161441
     
    11301455\rewriterules
    11311456\begin{lstlisting}
    1132 *a      @\rewrite@ *?( a ) @\use{*?}@
    1133 +a      @\rewrite@ +?( a ) @\use{+?}@
    1134 -a      @\rewrite@ -?( a ) @\use{-?}@
    1135 ~a      @\rewrite@ ~?( a ) @\use{~?}@
    1136 !a      @\rewrite@ !?( a ) @\use{"!?}@
    1137 ++a     @\rewrite@ ++?(&( a )) @\use{++?}@
    1138 --a     @\rewrite@ --?(&( a )) @\use{--?}@
     1457*a      @\rewrite@ *?(a) @\use{*?}@
     1458+a      @\rewrite@ +?(a) @\use{+?}@
     1459-a      @\rewrite@ -?(a) @\use{-?}@
     1460~a      @\rewrite@ ~?(a) @\use{~?}@
     1461!a      @\rewrite@ !?(a) @\use{"!?}@
     1462++a     @\rewrite@ ++?(&(a)) @\use{++?}@
     1463--a     @\rewrite@ --?(&(a)) @\use{--?}@
    11391464\end{lstlisting}
    11401465
     
    11441469\predefined
    11451470\begin{lstlisting}
    1146 _Bool ++?( volatile _Bool * ), ++?( _Atomic volatile _Bool * );
    1147 char ++?( volatile char * ), ++?( _Atomic volatile char * );
    1148 signed char ++?( volatile signed char * ), ++?( _Atomic volatile signed char * );
    1149 unsigned char ++?( volatile signed char * ), ++?( _Atomic volatile signed char * );
    1150 short int ++?( volatile short int * ), ++?( _Atomic volatile short int * );
    1151 unsigned short int ++?( volatile unsigned short int * ), ++?( _Atomic volatile unsigned short int * );
    1152 int ++?( volatile int * ), ++?( _Atomic volatile int * );
    1153 unsigned int ++?( volatile unsigned int * ), ++?( _Atomic volatile unsigned int * );
    1154 long int ++?( volatile long int * ), ++?( _Atomic volatile long int * );
    1155 long unsigned int ++?( volatile long unsigned int * ), ++?( _Atomic volatile long unsigned int * );
    1156 long long int ++?( volatile long long int * ), ++?( _Atomic volatile long long int * );
    1157 long long unsigned ++?( volatile long long unsigned int * ), ++?( _Atomic volatile long long unsigned int * );
    1158 float ++?( volatile float * ), ++?( _Atomic volatile float * );
    1159 double ++?( volatile double * ), ++?( _Atomic volatile double * );
    1160 long double ++?( volatile long double * ), ++?( _Atomic volatile long double * );
    1161 
    1162 forall( otype T ) T * ++?( T * restrict volatile * ), * ++?( T * _Atomic restrict volatile * );
    1163 forall( otype T ) _Atomic T * ++?( _Atomic T * restrict volatile * ), * ++?( _Atomic T * _Atomic restrict volatile * );
    1164 forall( otype T ) const T * ++?( const T * restrict volatile * ), * ++?( const T * _Atomic restrict volatile * );
    1165 forall( otype T ) volatile T * ++?( volatile T * restrict volatile * ), * ++?( volatile T * _Atomic restrict volatile * );
    1166 forall( otype T ) restrict T * ++?( restrict T * restrict volatile * ), * ++?( restrict T * _Atomic restrict volatile * );
    1167 forall( otype T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
     1471_Bool ++?( volatile _Bool * ),
     1472        ++?( _Atomic volatile _Bool * );
     1473char ++?( volatile char * ),
     1474        ++?( _Atomic volatile char * );
     1475signed char ++?( volatile signed char * ),
     1476        ++?( _Atomic volatile signed char * );
     1477unsigned char ++?( volatile signed char * ),
     1478        ++?( _Atomic volatile signed char * );
     1479short int ++?( volatile short int * ),
     1480        ++?( _Atomic volatile short int * );
     1481unsigned short int ++?( volatile unsigned short int * ),
     1482        ++?( _Atomic volatile unsigned short int * );
     1483int ++?( volatile int * ),
     1484        ++?( _Atomic volatile int * );
     1485unsigned int ++?( volatile unsigned int * ),
     1486        ++?( _Atomic volatile unsigned int * );
     1487long int ++?( volatile long int * ),
     1488        ++?( _Atomic volatile long int * );
     1489long unsigned int ++?( volatile long unsigned int * ),
     1490        ++?( _Atomic volatile long unsigned int * );
     1491long long int ++?( volatile long long int * ),
     1492        ++?( _Atomic volatile long long int * );
     1493long long unsigned ++?( volatile long long unsigned int * ),
     1494        ++?( _Atomic volatile long long unsigned int * );
     1495float ++?( volatile float * ),
     1496        ++?( _Atomic volatile float * );
     1497double ++?( volatile double * ),
     1498        ++?( _Atomic volatile double * );
     1499long double ++?( volatile long double * ),
     1500        ++?( _Atomic volatile long double * );
     1501
     1502forall( type T ) T * ++?( T * restrict volatile * ),
     1503        * ++?( T * _Atomic restrict volatile * );
     1504
     1505forall( type T ) _Atomic T * ++?( _Atomic T * restrict volatile * ),
     1506        * ++?( _Atomic T * _Atomic restrict volatile * );
     1507
     1508forall( type T ) const T * ++?( const T * restrict volatile * ),
     1509        * ++?( const T * _Atomic restrict volatile * );
     1510
     1511forall( type T ) volatile T * ++?( volatile T * restrict volatile * ),
     1512        * ++?( volatile T * _Atomic restrict volatile * );
     1513
     1514forall( type T ) restrict T * ++?( restrict T * restrict volatile * ),
     1515        * ++?( restrict T * _Atomic restrict volatile * );
     1516
     1517forall( type T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
    11681518        * ++?( _Atomic const T * _Atomic restrict volatile * );
    1169 forall( otype T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
     1519
     1520forall( type T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
    11701521        * ++?( _Atomic volatile T * _Atomic restrict volatile * );
    1171 forall( otype T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
     1522
     1523forall( type T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
    11721524        * ++?( _Atomic restrict T * _Atomic restrict volatile * );
    1173 forall( otype T ) const volatile T * ++?( const volatile T * restrict volatile * ),
     1525
     1526forall( type T ) const volatile T * ++?( const volatile T * restrict volatile * ),
    11741527        * ++?( const volatile T * _Atomic restrict volatile * );
    1175 forall( otype T ) const restrict T * ++?( const restrict T * restrict volatile * ),
     1528
     1529forall( type T ) const restrict T * ++?( const restrict T * restrict volatile * ),
    11761530        * ++?( const restrict T * _Atomic restrict volatile * );
    1177 forall( otype T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
     1531
     1532forall( type T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
    11781533        * ++?( restrict volatile T * _Atomic restrict volatile * );
    1179 forall( otype T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
     1534
     1535forall( type T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
    11801536        * ++?( _Atomic const volatile T * _Atomic restrict volatile * );
    1181 forall( otype T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
     1537
     1538forall( type T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
    11821539        * ++?( _Atomic const restrict T * _Atomic restrict volatile * );
    1183 forall( otype T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
     1540
     1541forall( type T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
    11841542        * ++?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1185 forall( otype T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
     1543
     1544forall( type T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
    11861545        * ++?( const restrict volatile T * _Atomic restrict volatile * );
    1187 forall( otype T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
     1546
     1547forall( type T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
    11881548        * ++?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    11891549
    1190 _Bool --?( volatile _Bool * ), --?( _Atomic volatile _Bool * );
    1191 char --?( volatile char * ), --?( _Atomic volatile char * );
    1192 signed char --?( volatile signed char * ), --?( _Atomic volatile signed char * );
    1193 unsigned char --?( volatile signed char * ), --?( _Atomic volatile signed char * );
    1194 short int --?( volatile short int * ), --?( _Atomic volatile short int * );
    1195 unsigned short int --?( volatile unsigned short int * ), --?( _Atomic volatile unsigned short int * );
    1196 int --?( volatile int * ), --?( _Atomic volatile int * );
    1197 unsigned int --?( volatile unsigned int * ), --?( _Atomic volatile unsigned int * );
    1198 long int --?( volatile long int * ), --?( _Atomic volatile long int * );
    1199 long unsigned int --?( volatile long unsigned int * ), --?( _Atomic volatile long unsigned int * );
    1200 long long int --?( volatile long long int * ), --?( _Atomic volatile long long int * );
    1201 long long unsigned --?( volatile long long unsigned int * ), --?( _Atomic volatile long long unsigned int * );
    1202 float --?( volatile float * ), --?( _Atomic volatile float * );
    1203 double --?( volatile double * ), --?( _Atomic volatile double * );
    1204 long double --?( volatile long double * ), --?( _Atomic volatile long double * );
    1205 
    1206 forall( otype T ) T * --?( T * restrict volatile * ), * --?( T * _Atomic restrict volatile * );
    1207 forall( otype T ) _Atomic T * --?( _Atomic T * restrict volatile * ), * --?( _Atomic T * _Atomic restrict volatile * );
    1208 forall( otype T ) const T * --?( const T * restrict volatile * ), * --?( const T * _Atomic restrict volatile * );
    1209 forall( otype T ) volatile T * --?( volatile T * restrict volatile * ), * --?( volatile T * _Atomic restrict volatile * );
    1210 forall( otype T ) restrict T * --?( restrict T * restrict volatile * ), * --?( restrict T * _Atomic restrict volatile * );
    1211 forall( otype T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
     1550_Bool --?( volatile _Bool * ),
     1551        --?( _Atomic volatile _Bool * );
     1552char --?( volatile char * ),
     1553        --?( _Atomic volatile char * );
     1554signed char --?( volatile signed char * ),
     1555        --?( _Atomic volatile signed char * );
     1556unsigned char --?( volatile signed char * ),
     1557        --?( _Atomic volatile signed char * );
     1558short int --?( volatile short int * ),
     1559        --?( _Atomic volatile short int * );
     1560unsigned short int --?( volatile unsigned short int * ),
     1561        --?( _Atomic volatile unsigned short int * );
     1562int --?( volatile int * ),
     1563        --?( _Atomic volatile int * );
     1564unsigned int --?( volatile unsigned int * ),
     1565        --?( _Atomic volatile unsigned int * );
     1566long int --?( volatile long int * ),
     1567        --?( _Atomic volatile long int * );
     1568long unsigned int --?( volatile long unsigned int * ),
     1569        --?( _Atomic volatile long unsigned int * );
     1570long long int --?( volatile long long int * ),
     1571        --?( _Atomic volatile long long int * );
     1572long long unsigned --?( volatile long long unsigned int * ),
     1573        --?( _Atomic volatile long long unsigned int * );
     1574float --?( volatile float * ),
     1575        --?( _Atomic volatile float * );
     1576double --?( volatile double * ),
     1577        --?( _Atomic volatile double * );
     1578long double --?( volatile long double * ),
     1579        --?( _Atomic volatile long double * );
     1580
     1581forall( type T ) T * --?( T * restrict volatile * ),
     1582        * --?( T * _Atomic restrict volatile * );
     1583
     1584forall( type T ) _Atomic T * --?( _Atomic T * restrict volatile * ),
     1585        * --?( _Atomic T * _Atomic restrict volatile * );
     1586
     1587forall( type T ) const T * --?( const T * restrict volatile * ),
     1588        * --?( const T * _Atomic restrict volatile * );
     1589
     1590forall( type T ) volatile T * --?( volatile T * restrict volatile * ),
     1591        * --?( volatile T * _Atomic restrict volatile * );
     1592
     1593forall( type T ) restrict T * --?( restrict T * restrict volatile * ),
     1594        * --?( restrict T * _Atomic restrict volatile * );
     1595
     1596forall( type T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
    12121597        * --?( _Atomic const T * _Atomic restrict volatile * );
    1213 forall( otype T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
     1598
     1599forall( type T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
    12141600        * --?( _Atomic volatile T * _Atomic restrict volatile * );
    1215 forall( otype T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
     1601
     1602forall( type T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
    12161603        * --?( _Atomic restrict T * _Atomic restrict volatile * );
    1217 forall( otype T ) const volatile T * --?( const volatile T * restrict volatile * ),
     1604
     1605forall( type T ) const volatile T * --?( const volatile T * restrict volatile * ),
    12181606        * --?( const volatile T * _Atomic restrict volatile * );
    1219 forall( otype T ) const restrict T * --?( const restrict T * restrict volatile * ),
     1607
     1608forall( type T ) const restrict T * --?( const restrict T * restrict volatile * ),
    12201609        * --?( const restrict T * _Atomic restrict volatile * );
    1221 forall( otype T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
     1610
     1611forall( type T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
    12221612        * --?( restrict volatile T * _Atomic restrict volatile * );
    1223 forall( otype T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
     1613
     1614forall( type T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
    12241615        * --?( _Atomic const volatile T * _Atomic restrict volatile * );
    1225 forall( otype T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
     1616
     1617forall( type T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
    12261618        * --?( _Atomic const restrict T * _Atomic restrict volatile * );
    1227 forall( otype T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
     1619
     1620forall( type T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
    12281621        * --?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1229 forall( otype T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
     1622
     1623forall( type T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
    12301624        * --?( const restrict volatile T * _Atomic restrict volatile * );
    1231 forall( otype T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
     1625
     1626forall( type T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
    12321627        * --?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    12331628\end{lstlisting}
     
    12501645
    12511646\semantics
    1252 The interpretations of prefix increment and decrement expressions are determined in the same way as the interpretations of postfix increment and decrement expressions.
     1647The interpretations of prefix increment and decrement expressions are
     1648determined in the same way as the interpretations of postfix increment and
     1649decrement expressions.
    12531650
    12541651
     
    12571654\predefined
    12581655\begin{lstlisting}
    1259 forall( otype T ) lvalue T *?( T * );
    1260 forall( otype T ) _Atomic lvalue T *?( _Atomic T * );
    1261 forall( otype T ) const lvalue T *?( const T * );
    1262 forall( otype T ) volatile lvalue T *?( volatile T * );
    1263 forall( otype T ) restrict lvalue T *?( restrict T * );
    1264 forall( otype T ) _Atomic const lvalue T *?( _Atomic const T * );
    1265 forall( otype T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
    1266 forall( otype T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
    1267 forall( otype T ) const volatile lvalue T *?( const volatile T * );
    1268 forall( otype T ) const restrict lvalue T *?( const restrict T * );
    1269 forall( otype T ) restrict volatile lvalue T *?( restrict volatile T * );
    1270 forall( otype T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
    1271 forall( otype T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
    1272 forall( otype T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
    1273 forall( otype T ) const restrict volatile lvalue T *?( const restrict volatile T * );
    1274 forall( otype T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
     1656forall( type T ) lvalue T *?( T * );
     1657forall( type T ) _Atomic lvalue T *?( _Atomic T * );
     1658forall( type T ) const lvalue T *?( const T * );
     1659forall( type T ) volatile lvalue T *?( volatile T * );
     1660forall( type T ) restrict lvalue T *?( restrict T * );
     1661forall( type T ) _Atomic const lvalue T *?( _Atomic const T * );
     1662forall( type T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
     1663forall( type T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
     1664forall( type T ) const volatile lvalue T *?( const volatile T * );
     1665forall( type T ) const restrict lvalue T *?( const restrict T * );
     1666forall( type T ) restrict volatile lvalue T *?( restrict volatile T * );
     1667forall( type T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
     1668forall( type T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
     1669forall( type T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
     1670forall( type T ) const restrict volatile lvalue T *?( const restrict volatile T * );
     1671forall( type T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
     1672
    12751673forall( ftype FT ) FT *?( FT * );
    12761674\end{lstlisting}
     
    12841682\lstinline$T$ is the type of the operand.
    12851683
    1286 The interpretations of an indirection expression are the interpretations of the corresponding function call.
     1684The interpretations of an indirection expression are the interpretations of the corresponding
     1685function call.
    12871686
    12881687
     
    12911690\predefined
    12921691\begin{lstlisting}
    1293 int     +?( int ), -?( int ), ~?( int );
    1294 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int );
    1295 long int +?( long int ), -?( long int ), ~?( long int );
    1296 long unsigned int +?( long unsigned int ), -?( long unsigned int ), ~?( long unsigned int );
    1297 long long int +?( long long int ), -?( long long int ), ~?( long long int );
    1298 long long unsigned int +?( long long unsigned int ), -?( long long unsigned int ), ~?( long long unsigned int );
    1299 float +?( float ), -?( float );
    1300 double +?( double ), -?( double );
    1301 long double +?( long double ), -?( long double );
    1302 _Complex float +?( _Complex float ), -?( _Complex float );
    1303 _Complex double +?( _Complex double ), -?( _Complex double );
    1304 _Complex long double +?( _Complex long double ), -?( _Complex long double );
    1305 int !?( int ), !?( unsigned int ), !?( long ), !?( long unsigned int ),
    1306         !?( long long int ), !?( long long unsigned int ),
    1307         !?( float ), !?( double ), !?( long double ),
    1308         !?( _Complex float ), !?( _Complex double ), !?( _Complex long double );
     1692int
     1693        +?( int ),
     1694        -?( int ),
     1695        ~?( int );
     1696unsigned int
     1697        +?( unsigned int ),
     1698        -?( unsigned int ),
     1699         ~?( unsigned int );
     1700long int
     1701        +?( long int ),
     1702        -?( long int ),
     1703        ~?( long int );
     1704long unsigned int
     1705        +?( long unsigned int ),
     1706        -?( long unsigned int ),
     1707        ~?( long unsigned int );
     1708long long int
     1709        +?( long long int ),
     1710        -?( long long int ),
     1711        ~?( long long int );
     1712long long unsigned int
     1713        +?( long long unsigned int ),
     1714        -?( long long unsigned int ),
     1715        ~?( long long unsigned int );
     1716float
     1717        +?( float ),
     1718        -?( float );
     1719double
     1720        +?( double ),
     1721        -?( double );
     1722long double
     1723        +?( long double ),
     1724        -?( long double );
     1725_Complex float
     1726        +?( _Complex float ),
     1727        -?( _Complex float );
     1728_Complex double
     1729        +?( _Complex double ),
     1730        -?( _Complex double );
     1731_Complex long double
     1732        +?( _Complex long double ),
     1733        -?( _Complex long double );
     1734
     1735int !?( int ),
     1736        !?( unsigned int ),
     1737        !?( long ),
     1738        !?( long unsigned int ),
     1739        !?( long long int ),
     1740        !?( long long unsigned int ),
     1741        !?( float ),
     1742        !?( double ),
     1743        !?( long double ),
     1744        !?( _Complex float ),
     1745        !?( _Complex double ),
     1746        !?( _Complex long double );
     1747
    13091748forall( dtype DT ) int !?( const restrict volatile DT * );
    13101749forall( dtype DT ) int !?( _Atomic const restrict volatile DT * );
    13111750forall( ftype FT ) int !?( FT * );
    13121751\end{lstlisting}
    1313 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     1752For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     1753rank of \lstinline$int$ there exist
    13141754% Don't use predefined: keep this out of prelude.cf.
    13151755\begin{lstlisting}
     
    13191759
    13201760\semantics
    1321 The interpretations of a unary arithmetic expression are the interpretations of the corresponding function call.
     1761The interpretations of a unary arithmetic expression are the interpretations of the corresponding
     1762function call.
    13221763
    13231764\examples
     
    13251766long int li;
    13261767void eat_double( double );@\use{eat_double}@
    1327 eat_double(-li ); // @\rewrite@ eat_double( -?( li ) );
     1768
     1769eat_double(-li ); // @\rewrite@ eat_double( -?( li ) );
    13281770\end{lstlisting}
    13291771The valid interpretations of ``\lstinline$-li$'' (assuming no extended integer types exist) are
    13301772\begin{center}
    1331 \begin{tabular}{llc} interpretation & result type & expression conversion cost \\
     1773\begin{tabular}{llc}
     1774interpretation & result type & expression conversion cost \\
    13321775\hline
    13331776\lstinline$-?( (int)li )$                                       & \lstinline$int$                                       & (unsafe) \\
     
    13451788\end{tabular}
    13461789\end{center}
    1347 The valid interpretations of the \lstinline$eat_double$ call, with the cost of the argument conversion and the cost of the entire expression, are
     1790The valid interpretations of the \lstinline$eat_double$ call, with the cost of the argument
     1791conversion and the cost of the entire expression, are
    13481792\begin{center}
    1349 \begin{tabular}{lcc} interpretation & argument cost & expression cost \\
     1793\begin{tabular}{lcc}
     1794interpretation & argument cost & expression cost \\
    13501795\hline
    13511796\lstinline$eat_double( (double)-?( (int)li) )$                                  & 7                     & (unsafe) \\
     
    13631808\end{tabular}
    13641809\end{center}
    1365 Each has result type \lstinline$void$, so the best must be selected.
    1366 The interpretations involving unsafe conversions are discarded.
    1367 The remainder have equal expression conversion costs, so the
     1810Each has result type \lstinline$void$, so the best must be selected. The interpretations involving
     1811unsafe conversions are discarded. The remainder have equal expression conversion costs, so the
    13681812``highest argument conversion cost'' rule is invoked, and the chosen interpretation is
    13691813\lstinline$eat_double( (double)-?(li) )$.
     
    13761820\lstinline$dtype$, or \lstinline$ftype$.
    13771821
    1378 When the \lstinline$sizeof$\use{sizeof} operator is applied to an expression, the expression shall have exactly one \Index{interpretation}\index{ambiguous interpretation}, which shall be unambiguous. \semantics A \lstinline$sizeof$ or \lstinline$_Alignof$ expression has one interpretation, of type \lstinline$size_t$.
     1822When the \lstinline$sizeof$\use{sizeof} operator is applied to an expression, the expression shall
     1823have exactly one \Index{interpretation}\index{ambiguous interpretation}, which shall
     1824be unambiguous. \semantics A \lstinline$sizeof$ or \lstinline$_Alignof$ expression has one
     1825interpretation, of type \lstinline$size_t$.
    13791826
    13801827When \lstinline$sizeof$ is applied to an identifier declared by a \nonterm{type-declaration} or a
    1381 \nonterm{type-parameter}, it yields the size in bytes of the type that implements the operand.
    1382 When the operand is an opaque type or an inferred type parameter\index{inferred parameter}, the expression is not a constant expression.
     1828\nonterm{type-parameter}, it yields the size in bytes of the type that implements the operand. When
     1829the operand is an opaque type or an inferred type parameter\index{inferred parameter}, the
     1830expression is not a constant expression.
    13831831
    13841832When \lstinline$_Alignof$ is applied to an identifier declared by a \nonterm{type-declaration} or a
    1385 \nonterm{type-parameter}, it yields the alignment requirement of the type that implements the operand.
    1386 When the operand is an opaque type or an inferred type parameter\index{inferred parameter}, the expression is not a constant expression.
    1387 \begin{rationale}
    1388 \begin{lstlisting}
    1389 otype Pair = struct { int first, second; };
     1833\nonterm{type-parameter}, it yields the alignment requirement of the type that implements the
     1834operand. When the operand is an opaque type or an inferred type parameter\index{inferred
     1835parameter}, the expression is not a constant expression.
     1836\begin{rationale}
     1837\begin{lstlisting}
     1838type Pair = struct { int first, second; };
    13901839size_t p_size = sizeof(Pair);           // constant expression
    1391 extern otype Rational;@\use{Rational}@
     1840
     1841extern type Rational;@\use{Rational}@
    13921842size_t c_size = sizeof(Rational);       // non-constant expression
     1843
    13931844forall(type T) T f(T p1, T p2) {
    13941845        size_t t_size = sizeof(T);              // non-constant expression
     
    13961847}
    13971848\end{lstlisting}
    1398 ``\lstinline$sizeof Rational$'', although not statically known, is fixed.
    1399 Within \lstinline$f()$,
     1849``\lstinline$sizeof Rational$'', although not statically known, is fixed. Within \lstinline$f()$,
    14001850``\lstinline$sizeof(T)$'' is fixed for each call of \lstinline$f()$, but may vary from call to call.
    14011851\end{rationale}
     
    14171867
    14181868In a \Index{cast expression} ``\lstinline$($\nonterm{type-name}\lstinline$)e$'', if
    1419 \nonterm{type-name} is the type of an interpretation of \lstinline$e$, then that interpretation is the only interpretation of the cast expression;
    1420 otherwise, \lstinline$e$ shall have some interpretation that can be converted to \nonterm{type-name}, and the interpretation of the cast expression is the cast of the interpretation that can be converted at the lowest cost.
    1421 The cast expression's interpretation is ambiguous\index{ambiguous interpretation} if more than one interpretation can be converted at the lowest cost or if the selected interpretation is ambiguous.
    1422 
    1423 \begin{rationale}
    1424 Casts can be used to eliminate ambiguity in expressions by selecting interpretations of subexpressions, and to specialize polymorphic functions and values.
     1869\nonterm{type-name} is the type of an interpretation of \lstinline$e$, then that interpretation is
     1870the only interpretation of the cast expression; otherwise, \lstinline$e$ shall have some
     1871interpretation that can be converted to \nonterm{type-name}, and the interpretation of the cast
     1872expression is the cast of the interpretation that can be converted at the lowest cost. The cast
     1873expression's interpretation is ambiguous\index{ambiguous interpretation} if more than one
     1874interpretation can be converted at the lowest cost or if the selected interpretation is ambiguous.
     1875
     1876\begin{rationale}
     1877Casts can be used to eliminate ambiguity in expressions by selecting interpretations of
     1878subexpressions, and to specialize polymorphic functions and values.
    14251879\end{rationale}
    14261880
     
    14451899\predefined
    14461900\begin{lstlisting}
    1447 int?*?( int, int ), ?/?( int, int ), ?%?( int, int );
    1448 unsigned int?*?( unsigned int, unsigned int ), ?/?( unsigned int, unsigned int ), ?%?( unsigned int, unsigned int );
    1449 long int?*?( long int, long int ), ?/?( long, long ), ?%?( long, long );
     1901int?*?( int, int ),
     1902        ?/?( int, int ),
     1903        ?%?( int, int );
     1904unsigned int?*?( unsigned int, unsigned int ),
     1905        ?/?( unsigned int, unsigned int ),
     1906        ?%?( unsigned int, unsigned int );
     1907long int?*?( long int, long int ),
     1908        ?/?( long, long ),
     1909        ?%?( long, long );
    14501910long unsigned int?*?( long unsigned int, long unsigned int ),
    1451         ?/?( long unsigned int, long unsigned int ), ?%?( long unsigned int, long unsigned int );
    1452 long long int?*?( long long int, long long int ), ?/?( long long int, long long int ),
     1911        ?/?( long unsigned int, long unsigned int ),
     1912        ?%?( long unsigned int, long unsigned int );
     1913long long int?*?( long long int, long long int ),
     1914        ?/?( long long int, long long int ),
    14531915        ?%?( long long int, long long int );
    14541916long long unsigned int ?*?( long long unsigned int, long long unsigned int ),
    1455         ?/?( long long unsigned int, long long unsigned int ), ?%?( long long unsigned int, long long unsigned int );
    1456 float?*?( float, float ), ?/?( float, float );
    1457 double?*?( double, double ), ?/?( double, double );
    1458 long double?*?( long double, long double ), ?/?( long double, long double );
    1459 _Complex float?*?( float, _Complex float ), ?/?( float, _Complex float ),
    1460         ?*?( _Complex float, float ), ?/?( _Complex float, float ),
    1461         ?*?( _Complex float, _Complex float ), ?/?( _Complex float, _Complex float );
    1462 _Complex double?*?( double, _Complex double ), ?/?( double, _Complex double ),
    1463         ?*?( _Complex double, double ), ?/?( _Complex double, double ),
    1464         ?*?( _Complex double, _Complex double ), ?/?( _Complex double, _Complex double );
    1465 _Complex long double?*?( long double, _Complex long double ), ?/?( long double, _Complex long double ),
    1466         ?*?( _Complex long double, long double ), ?/?( _Complex long double, long double ),
    1467         ?*?( _Complex long double, _Complex long double ), ?/?( _Complex long double, _Complex long double );
    1468 \end{lstlisting}
    1469 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     1917        ?/?( long long unsigned int, long long unsigned int ),
     1918        ?%?( long long unsigned int, long long unsigned int );
     1919float?*?( float, float ),
     1920        ?/?( float, float );
     1921double?*?( double, double ),
     1922        ?/?( double, double );
     1923long double?*?( long double, long double ),
     1924        ?/?( long double, long double );
     1925_Complex float?*?( float, _Complex float ),
     1926        ?/?( float, _Complex float ),
     1927        ?*?( _Complex float, float ),
     1928        ?/?( _Complex float, float ),
     1929        ?*?( _Complex float, _Complex float ),
     1930        ?/?( _Complex float, _Complex float );
     1931_Complex double?*?( double, _Complex double ),
     1932        ?/?( double, _Complex double ),
     1933        ?*?( _Complex double, double ),
     1934        ?/?( _Complex double, double ),
     1935        ?*?( _Complex double, _Complex double ),
     1936        ?/?( _Complex double, _Complex double );
     1937_Complex long double?*?( long double, _Complex long double ),
     1938        ?/?( long double, _Complex long double ),
     1939        ?*?( _Complex long double, long double ),
     1940        ?/?( _Complex long double, long double ),
     1941        ?*?( _Complex long double, _Complex long double ),
     1942        ?/?( _Complex long double, _Complex long double );
     1943\end{lstlisting}
     1944For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     1945rank of \lstinline$int$ there exist
    14701946% Don't use predefined: keep this out of prelude.cf.
    14711947\begin{lstlisting}
     
    14751951\begin{rationale}
    14761952{\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the
    1477 \Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
     1953\Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary
     1954operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
    14781955\end{rationale}
    14791956
    14801957\semantics
    1481 The interpretations of multiplicative expressions are the interpretations of the corresponding function call.
     1958The interpretations of multiplicative expressions are the interpretations of the corresponding
     1959function call.
    14821960
    14831961\examples
     
    14881966eat_double( li % i );
    14891967\end{lstlisting}
    1490 ``\lstinline$li % i$'' is rewritten as ``\lstinline$?%?(li, i )$''.
    1491 The valid interpretations of \lstinline$?%?(li, i )$, the cost\index{conversion cost} of converting their arguments, and the cost of converting the result to \lstinline$double$ (assuming no extended integer types are present ) are
     1968``\lstinline$li % i$'' is rewritten as ``\lstinline$?%?(li, i )$''. The valid interpretations
     1969of \lstinline$?%?(li, i )$, the cost\index{conversion cost} of converting their arguments, and
     1970the cost of converting the result to \lstinline$double$ (assuming no extended integer types are
     1971present ) are
    14921972\begin{center}
    1493 \begin{tabular}{lcc} interpretation & argument cost & result cost \\
     1973\begin{tabular}{lcc}
     1974interpretation & argument cost & result cost \\
    14941975\hline
    14951976\lstinline$ ?%?( (int)li, i )$                                                                          & (unsafe)      & 6     \\
    14961977\lstinline$ ?%?( (unsigned)li,(unsigned)i )$                                            & (unsafe)      & 5     \\
    1497 \lstinline$ ?%?( li, (long)i )$                                                                         & 1                     & 4     \\
     1978\lstinline$ ?%?(li,(long)i )$                                                                           & 1                     & 4     \\
    14981979\lstinline$ ?%?( (long unsigned)li,(long unsigned)i )$                          & 3                     & 3     \\
    14991980\lstinline$ ?%?( (long long)li,(long long)i )$                                          & 5                     & 2     \\
     
    15021983\end{center}
    15031984The best interpretation of \lstinline$eat_double( li, i )$ is
    1504 \lstinline$eat_double( (double)?%?(li, (long)i ))$, which has no unsafe conversions and the lowest total cost.
    1505 
    1506 \begin{rationale}
    1507 {\c11} defines most arithmetic operations to apply an \Index{integer promotion} to any argument that belongs to a type that has an \Index{integer conversion rank} less than that of \lstinline$int$.If
     1985\lstinline$eat_double( (double)?%?(li, (long)i ))$, which has no unsafe conversions and the
     1986lowest total cost.
     1987
     1988\begin{rationale}
     1989{\c11} defines most arithmetic operations to apply an \Index{integer promotion} to any argument that
     1990belongs to a type that has an \Index{integer conversion rank} less than that of \lstinline$int$.If
    15081991\lstinline$s$ is a \lstinline$short int$, ``\lstinline$s *s$'' does not have type \lstinline$short int$;
    1509 it is treated as ``\lstinline$( (int)s ) * ( (int)s )$'', and has type \lstinline$int$. \CFA matches that pattern;
    1510 it does not predefine ``\lstinline$short ?*?( short, short )$''.
    1511 
    1512 These ``missing'' operators limit polymorphism.
    1513 Consider
    1514 \begin{lstlisting}
    1515 forall( otype T | T ?*?( T, T ) ) T square( T );
     1992it is treated as ``\lstinline$( (int)s ) * ( (int)s )$'', and has type \lstinline$int$. \CFA matches
     1993that pattern; it does not predefine ``\lstinline$short ?*?( short, short )$''.
     1994
     1995These ``missing'' operators limit polymorphism. Consider
     1996\begin{lstlisting}
     1997forall( type T | T ?*?( T, T ) ) T square( T );
    15161998short s;
    15171999square( s );
     
    15192001Since \CFA does not define a multiplication operator for \lstinline$short int$,
    15202002\lstinline$square( s )$ is treated as \lstinline$square( (int)s )$, and the result has type
    1521 \lstinline$int$.
    1522 This is mildly surprising, but it follows the {\c11} operator pattern.
     2003\lstinline$int$. This is mildly surprising, but it follows the {\c11} operator pattern.
    15232004
    15242005A more troubling example is
    15252006\begin{lstlisting}
    1526 forall( otype T | ?*?( T, T ) ) T product( T[], int n );
     2007forall( type T | ?*?( T, T ) ) T product( T[], int n );
    15272008short sa[5];
    15282009product( sa, 5);
    15292010\end{lstlisting}
    15302011This has no valid interpretations, because \CFA has no conversion from ``array of
    1531 \lstinline$short int$'' to ``array of \lstinline$int$''.
    1532 The alternatives in such situations include
     2012\lstinline$short int$'' to ``array of \lstinline$int$''. The alternatives in such situations
     2013include
    15332014\begin{itemize}
    15342015\item
     
    15392020\lstinline$product$.
    15402021\item
    1541 Defining \lstinline$product$ to take as an argument a conversion function from the ``small'' type to the operator's argument type.
     2022Defining \lstinline$product$ to take as an argument a conversion function from the ``small'' type to
     2023the operator's argument type.
    15422024\end{itemize}
    15432025\end{rationale}
     
    15612043\predefined
    15622044\begin{lstlisting}
    1563 int?+?( int, int ), ?-?( int, int );
    1564 unsigned int?+?( unsigned int, unsigned int ), ?-?( unsigned int, unsigned int );
    1565 long int?+?( long int, long int ), ?-?( long int, long int );
    1566 long unsigned int?+?( long unsigned int, long unsigned int ), ?-?( long unsigned int, long unsigned int );
    1567 long long int?+?( long long int, long long int ), ?-?( long long int, long long int );
     2045int?+?( int, int ),
     2046        ?-?( int, int );
     2047unsigned int?+?( unsigned int, unsigned int ),
     2048        ?-?( unsigned int, unsigned int );
     2049long int?+?( long int, long int ),
     2050        ?-?( long int, long int );
     2051long unsigned int?+?( long unsigned int, long unsigned int ),
     2052        ?-?( long unsigned int, long unsigned int );
     2053long long int?+?( long long int, long long int ),
     2054        ?-?( long long int, long long int );
    15682055long long unsigned int ?+?( long long unsigned int, long long unsigned int ),
    15692056        ?-?( long long unsigned int, long long unsigned int );
    1570 float?+?( float, float ), ?-?( float, float );
    1571 double?+?( double, double ), ?-?( double, double );
    1572 long double?+?( long double, long double ), ?-?( long double, long double );
    1573 _Complex float?+?( _Complex float, float ), ?-?( _Complex float, float ),
    1574         ?+?( float, _Complex float ), ?-?( float, _Complex float ),
    1575         ?+?( _Complex float, _Complex float ), ?-?( _Complex float, _Complex float );
    1576 _Complex double?+?( _Complex double, double ), ?-?( _Complex double, double ),
    1577         ?+?( double, _Complex double ), ?-?( double, _Complex double ),
    1578         ?+?( _Complex double, _Complex double ), ?-?( _Complex double, _Complex double );
    1579 _Complex long double?+?( _Complex long double, long double ), ?-?( _Complex long double, long double ),
    1580         ?+?( long double, _Complex long double ), ?-?( long double, _Complex long double ),
    1581         ?+?( _Complex long double, _Complex long double ), ?-?( _Complex long double, _Complex long double );
    1582 
    1583 forall( otype T ) T * ?+?( T *, ptrdiff_t ), * ?+?( ptrdiff_t, T * ), * ?-?( T *, ptrdiff_t );
    1584 forall( otype T ) _Atomic T * ?+?( _Atomic T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic T * ),
     2057float?+?( float, float ),
     2058        ?-?( float, float );
     2059double?+?( double, double ),
     2060        ?-?( double, double );
     2061long double?+?( long double, long double ),
     2062        ?-?( long double, long double );
     2063_Complex float?+?( _Complex float, float ),
     2064        ?-?( _Complex float, float ),
     2065        ?+?( float, _Complex float ),
     2066        ?-?( float, _Complex float ),
     2067        ?+?( _Complex float, _Complex float ),
     2068        ?-?( _Complex float, _Complex float );
     2069_Complex double?+?( _Complex double, double ),
     2070        ?-?( _Complex double, double ),
     2071        ?+?( double, _Complex double ),
     2072        ?-?( double, _Complex double ),
     2073        ?+?( _Complex double, _Complex double ),
     2074        ?-?( _Complex double, _Complex double );
     2075_Complex long double?+?( _Complex long double, long double ),
     2076        ?-?( _Complex long double, long double ),
     2077        ?+?( long double, _Complex long double ),
     2078        ?-?( long double, _Complex long double ),
     2079        ?+?( _Complex long double, _Complex long double ),
     2080        ?-?( _Complex long double, _Complex long double );
     2081
     2082forall( type T ) T
     2083        * ?+?( T *, ptrdiff_t ),
     2084        * ?+?( ptrdiff_t, T * ),
     2085        * ?-?( T *, ptrdiff_t );
     2086
     2087forall( type T ) _Atomic T
     2088        * ?+?( _Atomic T *, ptrdiff_t ),
     2089        * ?+?( ptrdiff_t, _Atomic T * ),
    15852090        * ?-?( _Atomic T *, ptrdiff_t );
    1586 forall( otype T ) const T * ?+?( const T *, ptrdiff_t ), * ?+?( ptrdiff_t, const T * ),
     2091
     2092forall( type T ) const T
     2093        * ?+?( const T *, ptrdiff_t ),
     2094        * ?+?( ptrdiff_t, const T * ),
    15872095        * ?-?( const T *, ptrdiff_t );
    1588 forall( otype T ) restrict T * ?+?( restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict T * ),
     2096
     2097forall( type T ) restrict T
     2098        * ?+?( restrict T *, ptrdiff_t ),
     2099        * ?+?( ptrdiff_t, restrict T * ),
    15892100        * ?-?( restrict T *, ptrdiff_t );
    1590 forall( otype T ) volatile T * ?+?( volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, volatile T * ),
     2101
     2102forall( type T ) volatile T
     2103        * ?+?( volatile T *, ptrdiff_t ),
     2104        * ?+?( ptrdiff_t, volatile T * ),
    15912105        * ?-?( volatile T *, ptrdiff_t );
    1592 forall( otype T ) _Atomic const T * ?+?( _Atomic const T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic const T * ),
     2106
     2107forall( type T ) _Atomic const T
     2108        * ?+?( _Atomic const T *, ptrdiff_t ),
     2109        * ?+?( ptrdiff_t, _Atomic const T * ),
    15932110        * ?-?( _Atomic const T *, ptrdiff_t );
    1594 forall( otype T ) _Atomic restrict T * ?+?( _Atomic restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic restrict T * ),
     2111
     2112forall( type T ) _Atomic restrict T
     2113        * ?+?( _Atomic restrict T *, ptrdiff_t ),
     2114        * ?+?( ptrdiff_t, _Atomic restrict T * ),
    15952115        * ?-?( _Atomic restrict T *, ptrdiff_t );
    1596 forall( otype T ) _Atomic volatile T * ?+?( _Atomic volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic volatile T * ),
     2116
     2117forall( type T ) _Atomic volatile T
     2118        * ?+?( _Atomic volatile T *, ptrdiff_t ),
     2119        * ?+?( ptrdiff_t, _Atomic volatile T * ),
    15972120        * ?-?( _Atomic volatile T *, ptrdiff_t );
    1598 forall( otype T ) const restrict T * ?+?( const restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, const restrict T * ),
     2121
     2122forall( type T ) const restrict T
     2123        * ?+?( const restrict T *, ptrdiff_t ),
     2124        * ?+?( ptrdiff_t, const restrict T * ),
    15992125        * ?-?( const restrict T *, ptrdiff_t );
    1600 forall( otype T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, const volatile T * ),
     2126
     2127forall( type T ) const volatile T
     2128        * ?+?( const volatile T *, ptrdiff_t ),
     2129        * ?+?( ptrdiff_t, const volatile T * ),
    16012130        * ?-?( const volatile T *, ptrdiff_t );
    1602 forall( otype T ) restrict volatile T * ?+?( restrict volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict volatile T * ),
     2131
     2132forall( type T ) restrict volatile T
     2133        * ?+?( restrict volatile T *, ptrdiff_t ),
     2134        * ?+?( ptrdiff_t, restrict volatile T * ),
    16032135        * ?-?( restrict volatile T *, ptrdiff_t );
    1604 forall( otype T ) _Atomic const restrict T * ?+?( _Atomic const restrict T *, ptrdiff_t ),
     2136
     2137forall( type T ) _Atomic const restrict T
     2138        * ?+?( _Atomic const restrict T *, ptrdiff_t ),
    16052139        * ?+?( ptrdiff_t, _Atomic const restrict T * ),
    16062140        * ?-?( _Atomic const restrict T *, ptrdiff_t );
    1607 forall( otype T ) ptrdiff_t
     2141
     2142forall( type T ) ptrdiff_t
    16082143        * ?-?( const restrict volatile T *, const restrict volatile T * ),
    16092144        * ?-?( _Atomic const restrict volatile T *, _Atomic const restrict volatile T * );
    16102145\end{lstlisting}
    1611 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2146For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2147rank of \lstinline$int$ there exist
    16122148% Don't use predefined: keep this out of prelude.cf.
    16132149\begin{lstlisting}
     
    16162152
    16172153\semantics
    1618 The interpretations of additive expressions are the interpretations of the corresponding function calls.
    1619 
    1620 \begin{rationale}
    1621 \lstinline$ptrdiff_t$ is an implementation-defined identifier defined in \lstinline$<stddef.h>$ that is synonymous with a signed integral type that is large enough to hold the difference between two pointers.
    1622 It seems reasonable to use it for pointer addition as well. (This is technically a difference between \CFA and C, which only specifies that pointer addition uses an \emph{integral} argument.) Hence it is also used for subscripting, which is defined in terms of pointer addition.
    1623 The {\c11} standard uses \lstinline$size_t$ in several cases where a library function takes an argument that is used as a subscript, but \lstinline$size_t$ is unsuitable here because it is an unsigned type.
     2154The interpretations of additive expressions are the interpretations of the corresponding function
     2155calls.
     2156
     2157\begin{rationale}
     2158\lstinline$ptrdiff_t$ is an implementation-defined identifier defined in \lstinline$<stddef.h>$ that
     2159is synonymous with a signed integral type that is large enough to hold the difference between two
     2160pointers. It seems reasonable to use it for pointer addition as well. (This is technically a
     2161difference between \CFA and C, which only specifies that pointer addition uses an \emph{integral}
     2162argument.) Hence it is also used for subscripting, which is defined in terms of pointer addition.
     2163The {\c11} standard uses \lstinline$size_t$ in several cases where a library function takes an
     2164argument that is used as a subscript, but \lstinline$size_t$ is unsuitable here because it is an
     2165unsigned type.
    16242166\end{rationale}
    16252167
     
    16422184\predefined
    16432185\begin{lstlisting}
    1644 int ?<<?( int, int ), ?>>?( int, int );
    1645 unsigned int ?<<?( unsigned int, int ), ?>>?( unsigned int, int );
    1646 long int ?<<?( long int, int ), ?>>?( long int, int );
    1647 long unsigned int ?<<?( long unsigned int, int ), ?>>?( long unsigned int, int );
    1648 long long int ?<<?( long long int, int ), ?>>?( long long int, int );
    1649 long long unsigned int ?<<?( long long unsigned int, int ), ?>>?( long long unsigned int, int);
    1650 \end{lstlisting}
    1651 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2186int ?<<?( int, int ),
     2187         ?>>?( int, int );
     2188unsigned int ?<<?( unsigned int, int ),
     2189         ?>>?( unsigned int, int );
     2190long int ?<<?( long int, int ),
     2191         ?>>?( long int, int );
     2192long unsigned int ?<<?( long unsigned int, int ),
     2193         ?>>?( long unsigned int, int );
     2194long long int ?<<?( long long int, int ),
     2195         ?>>?( long long int, int );
     2196long long unsigned int ?<<?( long long unsigned int, int ),
     2197         ?>>?( long long unsigned int, int);
     2198\end{lstlisting}
     2199For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2200rank of \lstinline$int$ there exist
    16522201% Don't use predefined: keep this out of prelude.cf.
    16532202\begin{lstlisting}
     
    16562205
    16572206\begin{rationale}
    1658 The bitwise shift operators break the usual pattern: they do not convert both operands to a common type.
    1659 The right operand only undergoes \Index{integer promotion}.
     2207The bitwise shift operators break the usual pattern: they do not convert both operands to a common
     2208type. The right operand only undergoes \Index{integer promotion}.
    16602209\end{rationale}
    16612210
    16622211\semantics
    1663 The interpretations of a bitwise shift expression are the interpretations of the corresponding function calls.
     2212The interpretations of a bitwise shift expression are the interpretations of the corresponding
     2213function calls.
    16642214
    16652215
     
    16852235\predefined
    16862236\begin{lstlisting}
    1687 int ?<?( int, int ), ?<=?( int, int ),
    1688         ?>?( int, int ), ?>=?( int, int );
    1689 int ?<?( unsigned int, unsigned int ), ?<=?( unsigned int, unsigned int ),
    1690         ?>?( unsigned int, unsigned int ), ?>=?( unsigned int, unsigned int );
    1691 int ?<?( long int, long int ), ?<=?( long int, long int ),
    1692         ?>?( long int, long int ), ?>=?( long int, long int );
    1693 int ?<?( long unsigned int, long unsigned ), ?<=?( long unsigned int, long unsigned ),
    1694         ?>?( long unsigned int, long unsigned ), ?>=?( long unsigned int, long unsigned );
    1695 int ?<?( long long int, long long int ), ?<=?( long long int, long long int ),
    1696         ?>?( long long int, long long int ), ?>=?( long long int, long long int );
    1697 int ?<?( long long unsigned int, long long unsigned ), ?<=?( long long unsigned int, long long unsigned ),
    1698         ?>?( long long unsigned int, long long unsigned ), ?>=?( long long unsigned int, long long unsigned );
    1699 int ?<?( float, float ), ?<=?( float, float ),
    1700         ?>?( float, float ), ?>=?( float, float );
    1701 int ?<?( double, double ), ?<=?( double, double ),
    1702         ?>?( double, double ), ?>=?( double, double );
    1703 int ?<?( long double, long double ), ?<=?( long double, long double ),
    1704         ?>?( long double, long double ), ?>=?( long double, long double );
    1705 forall( dtype DT ) int ?<?( const restrict volatile DT *, const restrict volatile DT * ),
     2237int ?<?( int, int ),
     2238        ?<=?( int, int ),
     2239        ?>?( int, int ),
     2240        ?>=?( int, int );
     2241int ?<?( unsigned int, unsigned int ),
     2242        ?<=?( unsigned int, unsigned int ),
     2243        ?>?( unsigned int, unsigned int ),
     2244        ?>=?( unsigned int, unsigned int );
     2245int ?<?( long int, long int ),
     2246        ?<=?( long int, long int ),
     2247        ?>?( long int, long int ),
     2248        ?>=?( long int, long int );
     2249int ?<?( long unsigned int, long unsigned ),
     2250        ?<=?( long unsigned int, long unsigned ),
     2251        ?>?( long unsigned int, long unsigned ),
     2252        ?>=?( long unsigned int, long unsigned );
     2253int ?<?( long long int, long long int ),
     2254        ?<=?( long long int, long long int ),
     2255        ?>?( long long int, long long int ),
     2256        ?>=?( long long int, long long int );
     2257int ?<?( long long unsigned int, long long unsigned ),
     2258        ?<=?( long long unsigned int, long long unsigned ),
     2259        ?>?( long long unsigned int, long long unsigned ),
     2260        ?>=?( long long unsigned int, long long unsigned );
     2261int ?<?( float, float ),
     2262        ?<=?( float, float ),
     2263        ?>?( float, float ),
     2264        ?>=?( float, float );
     2265int ?<?( double, double ),
     2266        ?<=?( double, double ),
     2267        ?>?( double, double ),
     2268        ?>=?( double, double );
     2269int ?<?( long double, long double ),
     2270        ?<=?( long double, long double ),
     2271        ?>?( long double, long double ),
     2272        ?>=?( long double, long double );
     2273
     2274forall( dtype DT ) int
     2275        ?<?( const restrict volatile DT *, const restrict volatile DT * ),
    17062276        ?<?( _Atomic const restrict volatile DT *, _Atomic const restrict volatile DT * ),
    17072277        ?<=?( const restrict volatile DT *, const restrict volatile DT * ),
     
    17122282        ?>=?( _Atomic const restrict volatile DT *, _Atomic const restrict volatile DT * );
    17132283\end{lstlisting}
    1714 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2284For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2285rank of \lstinline$int$ there exist
    17152286% Don't use predefined: keep this out of prelude.cf.
    17162287\begin{lstlisting}
     
    17222293
    17232294\semantics
    1724 The interpretations of a relational expression are the interpretations of the corresponding function call.
     2295The interpretations of a relational expression are the interpretations of the corresponding function
     2296call.
    17252297
    17262298
     
    17422314\predefined
    17432315\begin{lstlisting}
    1744 int ?==?( int, int ), ?!=?( int, int ),
    1745         ?==?( unsigned int, unsigned int ), ?!=?( unsigned int, unsigned int ),
    1746         ?==?( long int, long int ), ?!=?( long int, long int ),
    1747         ?==?( long unsigned int, long unsigned int ), ?!=?( long unsigned int, long unsigned int ),
    1748         ?==?( long long int, long long int ), ?!=?( long long int, long long int ),
    1749         ?==?( long long unsigned int, long long unsigned int ), ?!=?( long long unsigned int, long long unsigned int ),
    1750         ?==?( float, float ), ?!=?( float, float ),
    1751         ?==?( _Complex float, float ), ?!=?( _Complex float, float ),
    1752         ?==?( float, _Complex float ), ?!=?( float, _Complex float ),
    1753         ?==?( _Complex float, _Complex float ), ?!=?( _Complex float, _Complex float ),
    1754         ?==?( double, double ), ?!=?( double, double ),
    1755         ?==?( _Complex double, double ), ?!=?( _Complex double, double ),
    1756         ?==?( double, _Complex double ), ?!=?( double, _Complex double ),
    1757         ?==?( _Complex double, _Complex double ), ?!=?( _Complex double, _Complex double ),
    1758         ?==?( long double, long double ), ?!=?( long double, long double ),
    1759         ?==?( _Complex long double, long double ), ?!=?( _Complex long double, long double ),
    1760         ?==?( long double, _Complex long double ), ?!=?( long double, _Complex long double ),
    1761         ?==?( _Complex long double, _Complex long double ), ?!=?( _Complex long double, _Complex long double );
     2316int ?==?( int, int ),
     2317        ?!=?( int, int ),
     2318        ?==?( unsigned int, unsigned int ),
     2319        ?!=?( unsigned int, unsigned int ),
     2320        ?==?( long int, long int ),
     2321        ?!=?( long int, long int ),
     2322        ?==?( long unsigned int, long unsigned int ),
     2323        ?!=?( long unsigned int, long unsigned int ),
     2324        ?==?( long long int, long long int ),
     2325        ?!=?( long long int, long long int ),
     2326        ?==?( long long unsigned int, long long unsigned int ),
     2327        ?!=?( long long unsigned int, long long unsigned int ),
     2328        ?==?( float, float ),
     2329        ?!=?( float, float ),
     2330        ?==?( _Complex float, float ),
     2331        ?!=?( _Complex float, float ),
     2332        ?==?( float, _Complex float ),
     2333        ?!=?( float, _Complex float ),
     2334        ?==?( _Complex float, _Complex float ),
     2335        ?!=?( _Complex float, _Complex float ),
     2336        ?==?( double, double ),
     2337        ?!=?( double, double ),
     2338        ?==?( _Complex double, double ),
     2339        ?!=?( _Complex double, double ),
     2340        ?==?( double, _Complex double ),
     2341        ?!=?( double, _Complex double ),
     2342        ?==?( _Complex double, _Complex double ),
     2343        ?!=?( _Complex double, _Complex double ),
     2344        ?==?( long double, long double ),
     2345        ?!=?( long double, long double ),
     2346        ?==?( _Complex long double, long double ),
     2347        ?!=?( _Complex long double, long double ),
     2348        ?==?( long double, _Complex long double ),
     2349        ?!=?( long double, _Complex long double ),
     2350        ?==?( _Complex long double, _Complex long double ),
     2351        ?!=?( _Complex long double, _Complex long double );
     2352
    17622353forall( dtype DT ) int
    17632354        ?==?( const restrict volatile DT *, const restrict volatile DT * ),
     
    17842375        ?==?( forall( dtype DT2) const DT2*, _Atomic const restrict volatile DT * ),
    17852376        ?!=?( forall( dtype DT2) const DT2*, _Atomic const restrict volatile DT * );
     2377
    17862378forall( ftype FT ) int
    1787         ?==?( FT *, FT * ), ?!=?( FT *, FT * ),
    1788         ?==?( FT *, forall( ftype FT2) FT2 * ), ?!=?( FT *, forall( ftype FT2) FT2 * ),
    1789         ?==?( forall( ftype FT2) FT2*, FT * ), ?!=?( forall( ftype FT2) FT2*, FT * ),
    1790         ?==?( forall( ftype FT2) FT2*, forall( ftype FT3) FT3 * ), ?!=?( forall( ftype FT2) FT2*, forall( ftype FT3) FT3 * );
    1791 \end{lstlisting}
    1792 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2379        ?==?( FT *, FT * ),
     2380        ?!=?( FT *, FT * ),
     2381        ?==?( FT *, forall( ftype FT2) FT2 * ),
     2382        ?!=?( FT *, forall( ftype FT2) FT2 * ),
     2383        ?==?( forall( ftype FT2) FT2*, FT * ),
     2384        ?!=?( forall( ftype FT2) FT2*, FT * ),
     2385        ?==?( forall( ftype FT2) FT2*, forall( ftype FT3) FT3 * ),
     2386        ?!=?( forall( ftype FT2) FT2*, forall( ftype FT3) FT3 * );
     2387\end{lstlisting}
     2388For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2389rank of \lstinline$int$ there exist
    17932390% Don't use predefined: keep this out of prelude.cf.
    17942391\begin{lstlisting}
     
    17982395
    17992396\begin{rationale}
    1800 The polymorphic equality operations come in three styles: comparisons between pointers of compatible types, between pointers to \lstinline$void$ and pointers to object types or incomplete types, and between the \Index{null pointer} constant and pointers to any type.
    1801 In the last case, a special constraint rule for null pointer constant operands has been replaced by a consequence of the \CFA type system.
     2397The polymorphic equality operations come in three styles: comparisons between pointers of compatible
     2398types, between pointers to \lstinline$void$ and pointers to object types or incomplete types, and
     2399between the \Index{null pointer} constant and pointers to any type. In the last case, a special
     2400constraint rule for null pointer constant operands has been replaced by a consequence of the \CFA
     2401type system.
    18022402\end{rationale}
    18032403
    18042404\semantics
    1805 The interpretations of an equality expression are the interpretations of the corresponding function call.
     2405The interpretations of an equality expression are the interpretations of the corresponding function
     2406call.
    18062407
    18072408\begin{sloppypar}
    1808 The result of an equality comparison between two pointers to predefined functions or predefined values is implementation-defined.
     2409The result of an equality comparison between two pointers to predefined functions or predefined
     2410values is implementation-defined.
    18092411\end{sloppypar}
    18102412\begin{rationale}
    1811 The implementation-defined status of equality comparisons allows implementations to use one library routine to implement many predefined functions.
    1812 These optimization are particularly important when the predefined functions are polymorphic, as is the case for most pointer operations
     2413The implementation-defined status of equality comparisons allows implementations to use one library
     2414routine to implement many predefined functions. These optimization are particularly important when
     2415the predefined functions are polymorphic, as is the case for most pointer operations
    18132416\end{rationale}
    18142417
     
    18362439long long unsigned int ?&?( long long unsigned int, long long unsigned int );
    18372440\end{lstlisting}
    1838 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2441For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2442rank of \lstinline$int$ there exist
    18392443% Don't use predefined: keep this out of prelude.cf.
    18402444\begin{lstlisting}
     
    18432447
    18442448\semantics
    1845 The interpretations of a bitwise AND expression are the interpretations of the corresponding function call.
     2449The interpretations of a bitwise AND expression are the interpretations of the corresponding
     2450function call.
    18462451
    18472452
     
    18682473long long unsigned int ?^?( long long unsigned int, long long unsigned int );
    18692474\end{lstlisting}
    1870 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2475For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2476rank of \lstinline$int$ there exist
    18712477% Don't use predefined: keep this out of prelude.cf.
    18722478\begin{lstlisting}
     
    18752481
    18762482\semantics
    1877 The interpretations of a bitwise exclusive OR expression are the interpretations of the corresponding function call.
     2483The interpretations of a bitwise exclusive OR expression are the interpretations of the
     2484corresponding function call.
    18782485
    18792486
     
    19002507long long unsigned int ?|?( long long unsigned int, long long unsigned int );
    19012508\end{lstlisting}
    1902 For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the rank of \lstinline$int$ there exist
     2509For every extended integer type \lstinline$X$ with \Index{integer conversion rank} greater than the
     2510rank of \lstinline$int$ there exist
    19032511% Don't use predefined: keep this out of prelude.cf.
    19042512\begin{lstlisting}
     
    19072515
    19082516\semantics
    1909 The interpretations of a bitwise inclusive OR expression are the interpretations of the corresponding function call.
     2517The interpretations of a bitwise inclusive OR expression are the interpretations of the
     2518corresponding function call.
    19102519
    19112520
     
    19192528
    19202529\semantics The operands of the expression ``\lstinline$a && b$'' are treated as
    1921 ``\lstinline$(int)((a)!=0)$'' and ``\lstinline$(int)((b)!=0)$'', which shall both be unambiguous.
    1922 The expression has only one interpretation, which is of type \lstinline$int$.
    1923 \begin{rationale}
    1924 When the operands of a logical expression are values of built-in types, and ``\lstinline$!=$'' has not been redefined for those types, the compiler can optimize away the function calls.
     2530``\lstinline$(int)((a)!=0)$'' and ``\lstinline$(int)((b)!=0)$'', which shall both be
     2531unambiguous. The expression has only one interpretation, which is of type \lstinline$int$.
     2532\begin{rationale}
     2533When the operands of a logical expression are values of built-in types, and ``\lstinline$!=$'' has
     2534not been redefined for those types, the compiler can optimize away the function calls.
    19252535
    19262536A common C idiom omits comparisons to \lstinline$0$ in the controlling expressions of loops and
    1927 \lstinline$if$ statements.
    1928 For instance, the loop below iterates as long as \lstinline$rp$ points at a \lstinline$Rational$ value that is non-zero.
    1929 
    1930 \begin{lstlisting}
    1931 extern otype Rational;@\use{Rational}@
     2537\lstinline$if$ statements. For instance, the loop below iterates as long as \lstinline$rp$ points
     2538at a \lstinline$Rational$ value that is non-zero.
     2539
     2540\begin{lstlisting}
     2541extern type Rational;@\use{Rational}@
    19322542extern const Rational 0;@\use{0}@
    19332543extern int ?!=?( Rational, Rational );
    19342544Rational *rp;
     2545
    19352546while ( rp && *rp ) { ... }
    19362547\end{lstlisting}
    1937 The logical expression calls the \lstinline$Rational$ inequality operator, passing it \lstinline$*rp$ and the \lstinline$Rational 0$, and getting a 1 or 0 as a result.
    1938 In contrast, {\CC} would apply a programmer-defined \lstinline$Rational$-to-\lstinline$int$ conversion to \lstinline$*rp$ in the equivalent situation.
    1939 The conversion to \lstinline$int$ would produce a general integer value, which is unfortunate, and possibly dangerous if the conversion was not written with this situation in mind.
     2548The logical expression calls the \lstinline$Rational$ inequality operator, passing
     2549it \lstinline$*rp$ and the \lstinline$Rational 0$, and getting a 1 or 0 as a result. In
     2550contrast, {\CC} would apply a programmer-defined \lstinline$Rational$-to-\lstinline$int$
     2551conversion to \lstinline$*rp$ in the equivalent situation. The conversion to \lstinline$int$ would
     2552produce a general integer value, which is unfortunate, and possibly dangerous if the conversion was
     2553not written with this situation in mind.
    19402554\end{rationale}
    19412555
     
    19512565\semantics
    19522566
    1953 The operands of the expression ``\lstinline$a || b$'' are treated as ``\lstinline$(int)((a)!=0)$'' and ``\lstinline$(int)((b))!=0)$'', which shall both be unambiguous.
    1954 The expression has only one interpretation, which is of type \lstinline$int$.
     2567The operands of the expression ``\lstinline$a || b$'' are treated as ``\lstinline$(int)((a)!=0)$''
     2568and ``\lstinline$(int)((b))!=0)$'', which shall both be unambiguous. The expression has only one
     2569interpretation, which is of type \lstinline$int$.
    19552570
    19562571
     
    19652580
    19662581\semantics
    1967 In the conditional expression\use{?:} ``\lstinline$a?b:c$'', if the second and third operands both have an interpretation with \lstinline$void$ type, then the expression has an interpretation with type \lstinline$void$, equivalent to
     2582In the conditional expression\use{?:} ``\lstinline$a?b:c$'', if the second and
     2583third operands both have an interpretation with \lstinline$void$ type, then the expression has an
     2584interpretation with type \lstinline$void$, equivalent to
    19682585\begin{lstlisting}
    19692586( int)(( a)!=0) ? ( void)( b) : ( void)( c)
    19702587\end{lstlisting}
    19712588
    1972 If the second and third operands both have interpretations with non-\lstinline$void$ types, the expression is treated as if it were the call ``\lstinline$cond((a)!=0, b, c)$'', with \lstinline$cond$ declared as
    1973 \begin{lstlisting}
    1974 forall( otype T ) T cond( int, T, T );
    1975 forall( dtype D ) void * cond( int, D *, void * ), * cond( int, void *, D * );
    1976 forall( dtype D ) _atomic void * cond(
    1977         int, _Atomic D *, _Atomic void * ), * cond( int, _Atomic void *, _Atomic D * );
    1978 forall( dtype D ) const void * cond(
    1979         int, const D *, const void * ), * cond( int, const void *, const D * );
    1980 forall( dtype D ) restrict void * cond(
    1981         int, restrict D *, restrict void * ), * cond( int, restrict void *, restrict D * );
    1982 forall( dtype D ) volatile void * cond(
    1983         int, volatile D *, volatile void * ), * cond( int, volatile void *, volatile D * );
    1984 forall( dtype D ) _Atomic const void * cond(
    1985         int, _Atomic const D *, _Atomic const void * ), * cond( int, _Atomic const void *, _Atomic const D * );
    1986 forall( dtype D ) _Atomic restrict void * cond(
    1987         int, _Atomic restrict D *, _Atomic restrict void * ), * cond( int, _Atomic restrict void *, _Atomic restrict D * );
    1988 forall( dtype D ) _Atomic volatile void * cond(
    1989         int, _Atomic volatile D *, _Atomic volatile void * ), * cond( int, _Atomic volatile void *, _Atomic volatile D * );
    1990 forall( dtype D ) const restrict void * cond(
    1991         int, const restrict D *, const restrict void * ), * cond( int, const restrict void *, const restrict D * );
    1992 forall( dtype D ) const volatile void * cond(
    1993         int, const volatile D *, const volatile void * ), * cond( int, const volatile void *, const volatile D * );
    1994 forall( dtype D ) restrict volatile void * cond(
    1995         int, restrict volatile D *, restrict volatile void * ), * cond( int, restrict volatile void *, restrict volatile D * );
    1996 forall( dtype D ) _Atomic const restrict void * cond(
    1997         int, _Atomic const restrict D *, _Atomic const restrict void * ),
     2589If the second and third operands both have interpretations with non-\lstinline$void$ types, the
     2590expression is treated as if it were the call ``\lstinline$cond((a)!=0, b, c)$'',
     2591with \lstinline$cond$ declared as
     2592\begin{lstlisting}
     2593forall( type T ) T cond( int, T, T );
     2594 
     2595forall( dtype D ) void
     2596        * cond( int, D *, void * ),
     2597        * cond( int, void *, D * );
     2598       
     2599forall( dtype D ) _atomic void
     2600        * cond( int, _Atomic D *, _Atomic void * ),
     2601        * cond( int, _Atomic void *, _Atomic D * );
     2602
     2603forall( dtype D ) const void
     2604        * cond( int, const D *, const void * ),
     2605        * cond( int, const void *, const D * );
     2606
     2607forall( dtype D ) restrict void
     2608        * cond( int, restrict D *, restrict void * ),
     2609        * cond( int, restrict void *, restrict D * );
     2610
     2611forall( dtype D ) volatile void
     2612        * cond( int, volatile D *, volatile void * ),
     2613        * cond( int, volatile void *, volatile D * );
     2614
     2615forall( dtype D ) _Atomic const void
     2616        * cond( int, _Atomic const D *, _Atomic const void * ),
     2617        * cond( int, _Atomic const void *, _Atomic const D * );
     2618
     2619forall( dtype D ) _Atomic restrict void
     2620        * cond( int, _Atomic restrict D *, _Atomic restrict void * ),
     2621        * cond( int, _Atomic restrict void *, _Atomic restrict D * );
     2622
     2623forall( dtype D ) _Atomic volatile void
     2624        * cond( int, _Atomic volatile D *, _Atomic volatile void * ),
     2625        * cond( int, _Atomic volatile void *, _Atomic volatile D * );
     2626
     2627forall( dtype D ) const restrict void
     2628        * cond( int, const restrict D *, const restrict void * ),
     2629        * cond( int, const restrict void *, const restrict D * );
     2630
     2631forall( dtype D ) const volatile void
     2632        * cond( int, const volatile D *, const volatile void * ),
     2633        * cond( int, const volatile void *, const volatile D * );
     2634
     2635forall( dtype D ) restrict volatile void
     2636        * cond( int, restrict volatile D *, restrict volatile void * ),
     2637        * cond( int, restrict volatile void *, restrict volatile D * );
     2638
     2639forall( dtype D ) _Atomic const restrict void
     2640        * cond( int, _Atomic const restrict D *, _Atomic const restrict void * ),
    19982641        * cond( int, _Atomic const restrict void *, _Atomic const restrict D * );
    1999 forall( dtype D ) _Atomic const volatile void * cond(
    2000         int, _Atomic const volatile D *, _Atomic const volatile void * ),
     2642
     2643forall( dtype D ) _Atomic const volatile void
     2644        * cond( int, _Atomic const volatile D *, _Atomic const volatile void * ),
    20012645        * cond( int, _Atomic const volatile void *, _Atomic const volatile D * );
    2002 forall( dtype D ) _Atomic restrict volatile void * cond(
    2003         int, _Atomic restrict volatile D *, _Atomic restrict volatile void * ),
    2004         * cond( int, _Atomic restrict volatile void *, _Atomic restrict volatile D * );
    2005 forall( dtype D ) const restrict volatile void * cond(
    2006         int, const restrict volatile D *, const restrict volatile void * ),
    2007         * cond( int, const restrict volatile void *, const restrict volatile D * );
    2008 forall( dtype D ) _Atomic const restrict volatile void * cond(
    2009         int, _Atomic const restrict volatile D *, _Atomic const restrict volatile void * ),
    2010         * cond( int, _Atomic const restrict volatile void *, _Atomic const restrict volatile D * );
    2011 \end{lstlisting}
    2012 
    2013 \begin{rationale}
    2014 The object of the above is to apply the \Index{usual arithmetic conversion}s when the second and third operands have arithmetic type, and to combine the qualifiers of the second and third operands if they are pointers.
     2646
     2647forall( dtype D ) _Atomic restrict volatile void
     2648        * cond( int, _Atomic restrict volatile D *,
     2649         _Atomic restrict volatile void * ),
     2650        * cond( int, _Atomic restrict volatile void *,
     2651         _Atomic restrict volatile D * );
     2652
     2653forall( dtype D ) const restrict volatile void
     2654        * cond( int, const restrict volatile D *,
     2655         const restrict volatile void * ),
     2656        * cond( int, const restrict volatile void *,
     2657         const restrict volatile D * );
     2658
     2659forall( dtype D ) _Atomic const restrict volatile void
     2660        * cond( int, _Atomic const restrict volatile D *,
     2661         _Atomic const restrict volatile void * ),
     2662        * cond( int, _Atomic const restrict volatile void *,
     2663         _Atomic const restrict volatile D * );
     2664\end{lstlisting}
     2665
     2666\begin{rationale}
     2667The object of the above is to apply the \Index{usual arithmetic conversion}s when the second and
     2668third operands have arithmetic type, and to combine the qualifiers of the second and third operands
     2669if they are pointers.
    20152670\end{rationale}
    20162671
     
    20302685rand() ? cip : vip;
    20312686\end{lstlisting}
    2032 The expression has type \lstinline$const volatile int *$, with safe conversions applied to the second and third operands to add \lstinline$volatile$ and \lstinline$const$ qualifiers, respectively.
     2687The expression has type \lstinline$const volatile int *$, with safe conversions applied to the second
     2688and third operands to add \lstinline$volatile$ and \lstinline$const$ qualifiers, respectively.
    20332689
    20342690\begin{lstlisting}
     
    20522708
    20532709\rewriterules
    2054 Let ``\(\leftarrow\)'' be any of the assignment operators.
    2055 Then
     2710Let ``\(\leftarrow\)'' be any of the assignment operators. Then
    20562711\use{?=?}\use{?*=?}\use{?/=?}\use{?%=?}\use{?+=?}\use{?-=?}
    20572712\use{?>>=?}\use{?&=?}\use{?^=?}\use{?"|=?}%use{?<<=?}
     
    20612716
    20622717\semantics
    2063 Each interpretation of the left operand of an assignment expression is considered separately.
    2064 For each interpretation that is a bit-field or is declared with the \lstinline$register$ storage class specifier, the expression has one valid interpretation, with the type of the left operand.
    2065 The right operand is cast to that type, and the assignment expression is ambiguous if either operand is.
    2066 For the remaining interpretations, the expression is rewritten, and the interpretations of the assignment expression are the interpretations of the corresponding function call.
    2067 Finally, all interpretations of the expression produced for the different interpretations of the left operand are combined to produce the interpretations of the expression as a whole;
    2068 where interpretations have compatible result types, the best interpretations are selected in the manner described for function call expressions.
     2718Each interpretation of the left operand of an assignment expression is considered separately. For
     2719each interpretation that is a bit-field or is declared with the \lstinline$register$ storage class
     2720specifier, the expression has one valid interpretation, with the type of the left operand. The
     2721right operand is cast to that type, and the assignment expression is ambiguous if either operand is.
     2722For the remaining interpretations, the expression is rewritten, and the interpretations of the
     2723assignment expression are the interpretations of the corresponding function call. Finally, all
     2724interpretations of the expression produced for the different interpretations of the left operand are
     2725combined to produce the interpretations of the expression as a whole; where interpretations have
     2726compatible result types, the best interpretations are selected in the manner described for function
     2727call expressions.
    20692728
    20702729
     
    21312790        ?=?( volatile _Complex long double *, _Complex long double ),
    21322791        ?=?( _Atomic volatile _Complex long double *, _Atomic _Complex long double );
     2792
    21332793forall( ftype FT ) FT
    21342794        * ?=?( FT * volatile *, FT * ),
    21352795        * ?=?( FT * volatile *, forall( ftype F ) F * );
     2796
    21362797forall( ftype FT ) FT const
    21372798        * ?=?( FT const * volatile *, FT const * ),
    21382799        * ?=?( FT const * volatile *, forall( ftype F ) F * );
     2800
    21392801forall( ftype FT ) FT volatile
    21402802        * ?=?( FT volatile * volatile *, FT * ),
    21412803        * ?=?( FT volatile * volatile *, forall( ftype F ) F * );
     2804
    21422805forall( ftype FT ) FT const
    21432806        * ?=?( FT const volatile * volatile *, FT const * ),
    21442807        * ?=?( FT const volatile * volatile *, forall( ftype F ) F * );
     2808
    21452809forall( dtype DT ) DT
    21462810        * ?=?( DT * restrict volatile *, DT * ),
     
    21502814        * ?=?( DT * _Atomic restrict volatile *, void * ),
    21512815        * ?=?( DT * _Atomic restrict volatile *, forall( dtype D ) D * );
     2816
    21522817forall( dtype DT ) DT _Atomic
    21532818        * ?=?( _Atomic DT * restrict volatile *, DT _Atomic * ),
     
    21572822        * ?=?( _Atomic DT * _Atomic restrict volatile *, void * ),
    21582823        * ?=?( _Atomic DT * _Atomic restrict volatile *, forall( dtype D ) D * );
     2824
    21592825forall( dtype DT ) DT const
    21602826        * ?=?( DT const * restrict volatile *, DT const * ),
     
    21642830        * ?=?( DT const * _Atomic restrict volatile *, void const * ),
    21652831        * ?=?( DT const * _Atomic restrict volatile *, forall( dtype D ) D * );
     2832
    21662833forall( dtype DT ) DT restrict
    21672834        * ?=?( restrict DT * restrict volatile *, DT restrict * ),
     
    21712838        * ?=?( restrict DT * _Atomic restrict volatile *, void * ),
    21722839        * ?=?( restrict DT * _Atomic restrict volatile *, forall( dtype D ) D * );
     2840
    21732841forall( dtype DT ) DT volatile
    21742842        * ?=?( DT volatile * restrict volatile *, DT volatile * ),
     
    21782846        * ?=?( DT volatile * _Atomic restrict volatile *, void volatile * ),
    21792847        * ?=?( DT volatile * _Atomic restrict volatile *, forall( dtype D ) D * );
     2848
    21802849forall( dtype DT ) DT _Atomic const
    21812850        * ?=?( DT _Atomic const * restrict volatile *, DT _Atomic const * ),
     
    21852854        * ?=?( DT _Atomic const * _Atomic restrict volatile *, void const * ),
    21862855        * ?=?( DT _Atomic const * _Atomic restrict volatile *, forall( dtype D ) D * );
     2856
    21872857forall( dtype DT ) DT _Atomic restrict
    21882858        * ?=?( _Atomic restrict DT * restrict volatile *, DT _Atomic restrict * ),
     
    21922862        * ?=?( _Atomic restrict DT * _Atomic restrict volatile *, void * ),
    21932863        * ?=?( _Atomic restrict DT * _Atomic restrict volatile *, forall( dtype D ) D * );
     2864
    21942865forall( dtype DT ) DT _Atomic volatile
    21952866        * ?=?( DT _Atomic volatile * restrict volatile *, DT _Atomic volatile * ),
     
    21992870        * ?=?( DT _Atomic volatile * _Atomic restrict volatile *, void volatile * ),
    22002871        * ?=?( DT _Atomic volatile * _Atomic restrict volatile *, forall( dtype D ) D * );
     2872
    22012873forall( dtype DT ) DT const restrict
    22022874        * ?=?( DT const restrict * restrict volatile *, DT const restrict * ),
     
    22062878        * ?=?( DT const restrict * _Atomic restrict volatile *, void const * ),
    22072879        * ?=?( DT const restrict * _Atomic restrict volatile *, forall( dtype D ) D * );
     2880
    22082881forall( dtype DT ) DT const volatile
    22092882        * ?=?( DT const volatile * restrict volatile *, DT const volatile * ),
     
    22132886        * ?=?( DT const volatile * _Atomic restrict volatile *, void const volatile * ),
    22142887        * ?=?( DT const volatile * _Atomic restrict volatile *, forall( dtype D ) D * );
     2888
    22152889forall( dtype DT ) DT restrict volatile
    22162890        * ?=?( DT restrict volatile * restrict volatile *, DT restrict volatile * ),
     
    22202894        * ?=?( DT restrict volatile * _Atomic restrict volatile *, void volatile * ),
    22212895        * ?=?( DT restrict volatile * _Atomic restrict volatile *, forall( dtype D ) D * );
     2896
    22222897forall( dtype DT ) DT _Atomic const restrict
    22232898        * ?=?( DT _Atomic const restrict * restrict volatile *,
     
    22332908        * ?=?( DT _Atomic const restrict * _Atomic restrict volatile *,
    22342909         forall( dtype D ) D * );
     2910
    22352911forall( dtype DT ) DT _Atomic const volatile
    22362912        * ?=?( DT _Atomic const volatile * restrict volatile *,
     
    22462922        * ?=?( DT _Atomic const volatile * _Atomic restrict volatile *,
    22472923         forall( dtype D ) D * );
     2924
    22482925forall( dtype DT ) DT _Atomic restrict volatile
    22492926        * ?=?( DT _Atomic restrict volatile * restrict volatile *,
     
    22592936        * ?=?( DT _Atomic restrict volatile * _Atomic restrict volatile *,
    22602937         forall( dtype D ) D * );
     2938
    22612939forall( dtype DT ) DT const restrict volatile
    22622940        * ?=?( DT const restrict volatile * restrict volatile *,
     
    22722950        * ?=?( DT const restrict volatile * _Atomic restrict volatile *,
    22732951         forall( dtype D ) D * );
     2952
    22742953forall( dtype DT ) DT _Atomic const restrict volatile
    22752954        * ?=?( DT _Atomic const restrict volatile * restrict volatile *,
     
    22852964        * ?=?( DT _Atomic const restrict volatile * _Atomic restrict volatile *,
    22862965         forall( dtype D ) D * );
     2966
    22872967forall( dtype DT ) void
    22882968        * ?=?( void * restrict volatile *, DT * );
     2969
    22892970forall( dtype DT ) void const
    22902971        * ?=?( void const * restrict volatile *, DT const * );
     2972
    22912973forall( dtype DT ) void volatile
    22922974        * ?=?( void volatile * restrict volatile *, DT volatile * );
     2975
    22932976forall( dtype DT ) void const volatile
    22942977        * ?=?( void const volatile * restrict volatile *, DT const volatile * );
    22952978\end{lstlisting}
    22962979\begin{rationale}
    2297 The pattern of overloadings for simple assignment resembles that of pointer increment and decrement, except that the polymorphic pointer assignment functions declare a \lstinline$dtype$ parameter, instead of a \lstinline$type$ parameter, because the left operand may be a pointer to an incomplete type.
     2980The pattern of overloadings for simple assignment resembles that of pointer increment and decrement,
     2981except that the polymorphic pointer assignment functions declare a \lstinline$dtype$ parameter,
     2982instead of a \lstinline$type$ parameter, because the left operand may be a pointer to an incomplete
     2983type.
    22982984\end{rationale}
    22992985
     
    23203006
    23213007\semantics
    2322 The structure assignment functions provide member-wise assignment;
    2323 each non-array member and each element of each array member of the right argument is assigned to the corresponding member or element of the left argument using the assignment function defined for its type.
    2324 All other assignment functions have the same effect as the corresponding C assignment expression.
    2325 \begin{rationale}
    2326 Note that, by default, union assignment\index{deficiencies!union assignment} uses C semantics---that is, bitwise copy---even if some of the union members have programmer-defined assignment functions.
     3008The structure assignment functions provide member-wise assignment; each non-array member and each
     3009element of each array member of the right argument is assigned to the corresponding member or
     3010element of the left argument using the assignment function defined for its type. All other
     3011assignment functions have the same effect as the corresponding C assignment expression.
     3012\begin{rationale}
     3013Note that, by default, union assignment\index{deficiencies!union assignment} uses C semantics---that
     3014is, bitwise copy---even if some of the union members have programmer-defined assignment functions.
    23273015\end{rationale}
    23283016
     
    23323020\predefined
    23333021\begin{lstlisting}
    2334 forall( otype T ) T
     3022forall( type T ) T
    23353023        * ?+=?( T * restrict volatile *, ptrdiff_t ),
    23363024        * ?-=?( T * restrict volatile *, ptrdiff_t ),
    23373025        * ?+=?( T * _Atomic restrict volatile *, ptrdiff_t ),
    23383026        * ?-=?( T * _Atomic restrict volatile *, ptrdiff_t );
    2339 forall( otype T ) T _Atomic
     3027
     3028forall( type T ) T _Atomic
    23403029        * ?+=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    23413030        * ?-=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    23423031        * ?+=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t ),
    23433032        * ?-=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t );
    2344 forall( otype T ) T const
     3033
     3034forall( type T ) T const
    23453035        * ?+=?( T const * restrict volatile *, ptrdiff_t ),
    23463036        * ?-=?( T const * restrict volatile *, ptrdiff_t ),
    23473037        * ?+=?( T const * _Atomic restrict volatile *, ptrdiff_t ),
    23483038        * ?-=?( T const * _Atomic restrict volatile *, ptrdiff_t );
    2349 forall( otype T ) T restrict
     3039
     3040forall( type T ) T restrict
    23503041        * ?+=?( T restrict * restrict volatile *, ptrdiff_t ),
    23513042        * ?-=?( T restrict * restrict volatile *, ptrdiff_t ),
    23523043        * ?+=?( T restrict * _Atomic restrict volatile *, ptrdiff_t ),
    23533044        * ?-=?( T restrict * _Atomic restrict volatile *, ptrdiff_t );
    2354 forall( otype T ) T volatile
     3045
     3046forall( type T ) T volatile
    23553047        * ?+=?( T volatile * restrict volatile *, ptrdiff_t ),
    23563048        * ?-=?( T volatile * restrict volatile *, ptrdiff_t ),
    23573049        * ?+=?( T volatile * _Atomic restrict volatile *, ptrdiff_t ),
    23583050        * ?-=?( T volatile * _Atomic restrict volatile *, ptrdiff_t );
    2359 forall( otype T ) T _Atomic const
     3051
     3052forall( type T ) T _Atomic const
    23603053        * ?+=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    23613054        * ?-=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    23623055        * ?+=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t ),
    23633056        * ?-=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t );
    2364 forall( otype T ) T _Atomic restrict
     3057
     3058forall( type T ) T _Atomic restrict
    23653059        * ?+=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    23663060        * ?-=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    23673061        * ?+=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t ),
    23683062        * ?-=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t );
    2369 forall( otype T ) T _Atomic volatile
     3063
     3064forall( type T ) T _Atomic volatile
    23703065        * ?+=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    23713066        * ?-=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    23723067        * ?+=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t ),
    23733068        * ?-=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t );
    2374 forall( otype T ) T const restrict
     3069
     3070forall( type T ) T const restrict
    23753071        * ?+=?( T const restrict * restrict volatile *, ptrdiff_t ),
    23763072        * ?-=?( T const restrict * restrict volatile *, ptrdiff_t ),
    23773073        * ?+=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    23783074        * ?-=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2379 forall( otype T ) T const volatile
     3075
     3076forall( type T ) T const volatile
    23803077        * ?+=?( T const volatile * restrict volatile *, ptrdiff_t ),
    23813078        * ?-=?( T const volatile * restrict volatile *, ptrdiff_t ),
    23823079        * ?+=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    23833080        * ?-=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2384 forall( otype T ) T restrict volatile
     3081
     3082forall( type T ) T restrict volatile
    23853083        * ?+=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    23863084        * ?-=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    23873085        * ?+=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    23883086        * ?-=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2389 forall( otype T ) T _Atomic const restrict
     3087
     3088forall( type T ) T _Atomic const restrict
    23903089        * ?+=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    23913090        * ?-=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    23923091        * ?+=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    23933092        * ?-=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2394 forall( otype T ) T _Atomic const volatile
     3093
     3094forall( type T ) T _Atomic const volatile
    23953095        * ?+=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    23963096        * ?-=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    23973097        * ?+=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    23983098        * ?-=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2399 forall( otype T ) T _Atomic restrict volatile
     3099
     3100forall( type T ) T _Atomic restrict volatile
    24003101        * ?+=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    24013102        * ?-=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    24023103        * ?+=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24033104        * ?-=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2404 forall( otype T ) T const restrict volatile
     3105
     3106forall( type T ) T const restrict volatile
    24053107        * ?+=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    24063108        * ?-=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    24073109        * ?+=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24083110        * ?-=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2409 forall( otype T ) T _Atomic const restrict volatile
     3111
     3112forall( type T ) T _Atomic const restrict volatile
    24103113        * ?+=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
    24113114        * ?-=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
     
    26183321\semantics
    26193322In the comma expression ``\lstinline$a, b$'', the first operand is interpreted as
    2620 ``\lstinline$( void )(a)$'', which shall be unambiguous\index{ambiguous interpretation}.
    2621 The interpretations of the expression are the interpretations of the second operand.
     3323``\lstinline$( void )(a)$'', which shall be unambiguous\index{ambiguous interpretation}. The
     3324interpretations of the expression are the interpretations of the second operand.
    26223325
    26233326
     
    26343337
    26353338\constraints
    2636 If an identifier has \Index{no linkage}, there shall be no more than one declaration of the identifier ( in a declarator or type specifier ) with compatible types in the same scope and in the same name space, except that:
     3339If an identifier has \Index{no linkage}, there shall be no more than one declaration of the
     3340identifier ( in a declarator or type specifier ) with compatible types in the same scope and in the
     3341same name space, except that:
    26373342\begin{itemize}
    2638 \item a typedef name may be redefined to denote the same type as it currently does, provided that type is not a variably modified type;
    2639 \item tags may be redeclared as specified in section 6.7.2.3 of the {\c11} standard.
     3343\item
     3344a typedef name may be redefined to denote the same type as it currently does, provided that type is
     3345not a variably modified type;
     3346\item
     3347tags may be redeclared as specified in section 6.7.2.3 of the {\c11} standard.
    26403348\end{itemize}
    26413349\begin{rationale}
    2642 This constraint adds the phrase ``with compatible types'' to the {\c11} constraint, to allow overloading.
    2643 \end{rationale}
    2644 
    2645 An identifier declared by a type declaration shall not be redeclared as a parameter in a function definition whose declarator includes an identifier list.
    2646 \begin{rationale}
    2647 This restriction echos {\c11}'s ban on the redeclaration of typedef names as parameters.
    2648 This avoids an ambiguity between old-style function declarations and new-style function prototypes:
     3350This constraint adds the phrase ``with compatible types'' to the {\c11} constraint, to allow
     3351overloading.
     3352\end{rationale}
     3353
     3354An identifier declared by a type declaration shall not be redeclared as a parameter in a function
     3355definition whose declarator includes an identifier list.
     3356\begin{rationale}
     3357This restriction echos {\c11}'s ban on the redeclaration of typedef names as parameters. This
     3358avoids an ambiguity between old-style function declarations and new-style function prototypes:
    26493359\begin{lstlisting}
    26503360void f( Complex,        // ... 3000 characters ...
    26513361void g( Complex,        // ... 3000 characters ...
    2652 int Complex;
    2653 { ... }
    2654 \end{lstlisting}
    2655 Without the rule, \lstinline$Complex$ would be a type in the first case, and a parameter name in the second.
     3362int Complex; { ... }
     3363\end{lstlisting}
     3364Without the rule, \lstinline$Complex$ would be a type in the first case, and a parameter name in the
     3365second.
    26563366\end{rationale}
    26573367
     
    26723382
    26733383\semantics
    2674 \CFA extends the {\c11} definition of \define{anonymous structure} to include structure specifiers with tags, and extends the {\c11} definition of \define{anonymous union} to include union specifiers with tags.
     3384\CFA extends the {\c11} definition of \define{anonymous structure} to include structure
     3385specifiers with tags, and extends the {\c11} definition of \define{anonymous union} to include union
     3386specifiers with tags.
    26753387\begin{rationale}
    26763388This extension imitates an extension in the Plan 9 C compiler \cite{Thompson90new}.
     
    26893401cp.x = 0;
    26903402cp.color = RED;
     3403
    26913404struct literal {@\impl{literal}@
    26923405        enum { NUMBER, STRING } tag;
    26933406        union {
    2694                 double n;
    2695                 char *s;
     3407         double n;
     3408         char *s;
    26963409        };
    26973410};
     
    27153428\begin{comment}
    27163429\constraints
    2717 If the \nonterm{declaration-specifiers} of a declaration that contains a \nonterm{forall-specifier} declares a structure or union tag, the types of the members of the structure or union shall not use any of the type identifiers declared by the \nonterm{type-parameter-list}.
    2718 \begin{rationale}
    2719 This sort of declaration is illegal because the scope of the type identifiers ends at the end of the declaration, but the scope of the structure tag does not.
    2720 \begin{lstlisting}
    2721 forall( otype T ) struct Pair { T a, b;
    2722 } mkPair( T, T ); // illegal
    2723 \end{lstlisting}
    2724 If an instance of \lstinline$struct Pair$ was declared later in the current scope, what would the members' type be?
     3430If the \nonterm{declaration-specifiers} of a declaration that contains a \nonterm{forall-specifier}
     3431declares a structure or union tag, the types of the members of the structure or union shall not use
     3432any of the type identifiers declared by the \nonterm{type-parameter-list}.
     3433\begin{rationale}
     3434This sort of declaration is illegal because the scope of the type identifiers ends at the end of the
     3435declaration, but the scope of the structure tag does not.
     3436\begin{lstlisting}
     3437forall( type T ) struct Pair { T a, b; } mkPair( T, T ); // illegal
     3438\end{lstlisting}
     3439If an instance of \lstinline$struct Pair$ was declared later in the current scope, what would the
     3440members' type be?
    27253441\end{rationale}
    27263442\end{comment}
    27273443
    27283444\semantics
    2729 The \nonterm{type-parameter-list}s and assertions of the \nonterm{forall-specifier}s declare type identifiers, function and object identifiers with \Index{no linkage}.
     3445The \nonterm{type-parameter-list}s and assertions of the \nonterm{forall-specifier}s declare type
     3446identifiers, function and object identifiers with \Index{no linkage}.
    27303447
    27313448If, in the declaration ``\lstinline$T D$'', \lstinline$T$ contains \nonterm{forall-specifier}s and
     
    27333450\begin{lstlisting}
    27343451D( @\normalsize\nonterm{parameter-type-list}@ )
    2735 \end{lstlisting} then a type identifier declared by one of the \nonterm{forall-specifier}s is an \define{inferred parameter} of the function declarator if and only if it is not an inferred parameter of a function declarator in \lstinline$D$, and it is used in the type of a parameter in the following
     3452\end{lstlisting}
     3453then a type identifier declared by one of the \nonterm{forall-specifier}s is an \define{inferred
     3454parameter} of the function declarator if and only if it is not an inferred parameter of a function
     3455declarator in \lstinline$D$, and it is used in the type of a parameter in the following
    27363456\nonterm{type-parameter-list} or it and an inferred parameter are used as arguments of a
    2737 \Index{specification} in one of the \nonterm{forall-specifier}s.
    2738 The identifiers declared by assertions that use an inferred parameter of a function declarator are \Index{assertion parameter}s of that function declarator.
     3457\Index{specification} in one of the \nonterm{forall-specifier}s. The identifiers declared by
     3458assertions that use an inferred parameter of a function declarator are \Index{assertion parameter}s
     3459of that function declarator.
    27393460
    27403461\begin{comment}
    27413462\begin{rationale}
    2742 Since every inferred parameter is used by some parameter, inference can be understood as a single bottom-up pass over the expression tree, that only needs to apply local reasoning at each node.
     3463Since every inferred parameter is used by some parameter, inference can be understood as a single
     3464bottom-up pass over the expression tree, that only needs to apply local reasoning at each node.
    27433465
    27443466If this restriction were lifted, it would be possible to write
    27453467\begin{lstlisting}
    2746 forall( otype T ) T * alloc( void );@\use{alloc}@ int *p = alloc();
     3468forall( type T ) T * alloc( void );@\use{alloc}@
     3469int *p = alloc();
    27473470\end{lstlisting}
    27483471Here \lstinline$alloc()$ would receive \lstinline$int$ as an inferred argument, and return an
    2749 \lstinline$int *$.
    2750 In general, if a call to \lstinline$alloc()$ is a subexpression of an expression involving polymorphic functions and overloaded identifiers, there could be considerable distance between the call and the subexpression that causes \lstinline$T$ to be bound.
     3472\lstinline$int *$. In general, if a call to \lstinline$alloc()$ is a subexpression of an expression
     3473involving polymorphic functions and overloaded identifiers, there could be considerable distance
     3474between the call and the subexpression that causes \lstinline$T$ to be bound.
    27513475
    27523476With the current restriction, \lstinline$alloc()$ must be given an argument that determines
    27533477\lstinline$T$:
    27543478\begin{lstlisting}
    2755 forall( otype T ) T * alloc( T initial_value );@\use{alloc}@
     3479forall( type T ) T * alloc( T initial_value );@\use{alloc}@
    27563480\end{lstlisting}
    27573481\end{rationale}
    27583482\end{comment}
    27593483
    2760 If a function declarator is part of a function definition, its inferred parameters and assertion parameters have \Index{block scope};
    2761 otherwise, identifiers declared by assertions have a
     3484If a function declarator is part of a function definition, its inferred parameters and assertion
     3485parameters have \Index{block scope}; otherwise, identifiers declared by assertions have a
    27623486\define{declaration scope}, which terminates at the end of the \nonterm{declaration}.
    27633487
    27643488A function type that has at least one inferred parameter is a \define{polymorphic function} type.
    2765 Function types with no inferred parameters are \define{monomorphic function} types.
    2766 One function type is \define{less polymorphic} than another if it has fewer inferred parameters, or if it has the same number of inferred parameters and fewer of its explicit parameters have types that depend on an inferred parameter.
    2767 
    2768 The names of inferred parameters and the order of identifiers in forall specifiers are not relevant to polymorphic function type compatibility.
    2769 Let $f$ and $g$ be two polymorphic function types with the same number of inferred parameters, and let $f_i$ and $g_i$ be the inferred parameters of $f$ and $g$ in their order of occurance in the function types' \nonterm{parameter-type-list}s.
    2770 Let $f'$ be $f$ with every occurrence of $f_i$ replaced by $g_i$, for all $i$.
    2771 Then $f$ and $g$ are
    2772 \Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same identifier and compatible type, and vice versa.
     3489Function types with no inferred parameters are \define{monomorphic function} types. One function
     3490type is \define{less polymorphic} than another if it has fewer inferred parameters, or if it has the
     3491same number of inferred parameters and fewer of its explicit parameters have types that depend on an
     3492inferred parameter.
     3493
     3494The names of inferred parameters and the order of identifiers in forall specifiers are not relevant
     3495to polymorphic function type compatibility. Let $f$ and $g$ be two polymorphic function types with
     3496the same number of inferred parameters, and let $f_i$ and $g_i$ be the inferred parameters of $f$
     3497and $g$ in their order of occurance in the function types' \nonterm{parameter-type-list}s. Let $f'$
     3498be $f$ with every occurrence of $f_i$ replaced by $g_i$, for all $i$. Then $f$ and $g$ are
     3499\Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if
     3500for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same
     3501identifier and compatible type, and vice versa.
    27733502
    27743503\examples
     
    27763505\begin{lstlisting}
    27773506int fi( int );
    2778 forall( otype T ) T fT( T );
     3507forall( type T ) T fT( T );
    27793508\end{lstlisting}
    27803509\lstinline$fi()$ takes an \lstinline$int$ and returns an \lstinline$int$. \lstinline$fT()$ takes a
     
    27823511\begin{lstlisting}
    27833512int (*pfi )( int ) = fi;
    2784 forall( otype T ) T (*pfT )( T ) = fT;
    2785 \end{lstlisting}
    2786 \lstinline$pfi$ and \lstinline$pfT$ are pointers to functions. \lstinline$pfT$ is not polymorphic, but the function it points at is.
     3513forall( type T ) T (*pfT )( T ) = fT;
     3514\end{lstlisting}
     3515\lstinline$pfi$ and \lstinline$pfT$ are pointers to functions. \lstinline$pfT$ is not
     3516polymorphic, but the function it points at is.
    27873517\begin{lstlisting}
    27883518int (*fvpfi( void ))( int ) {
    27893519        return pfi;
    27903520}
    2791 forall( otype T ) T (*fvpfT( void ))( T ) {
     3521forall( type T ) T (*fvpfT( void ))( T ) {
    27923522        return pfT;
    27933523}
    27943524\end{lstlisting}
    2795 \lstinline$fvpfi()$ and \lstinline$fvpfT()$ are functions taking no arguments and returning pointers to functions. \lstinline$fvpfT()$ is monomorphic, but the function that its return value points at is polymorphic.
    2796 \begin{lstlisting}
    2797 forall( otype T ) int ( *fTpfi( T ) )( int );
    2798 forall( otype T ) T ( *fTpfT( T ) )( T );
    2799 forall( otype T, otype U ) U ( *fTpfU( T ) )( U );
    2800 \end{lstlisting}
    2801 \lstinline$fTpfi()$ is a polymorphic function that returns a pointer to a monomorphic function taking an integer and returning an integer.
    2802 It could return \lstinline$pfi$. \lstinline$fTpfT()$ is subtle: it is a polymorphic function returning a \emph{monomorphic} function taking and returning
    2803 \lstinline$T$, where \lstinline$T$ is an inferred parameter of \lstinline$fTpfT()$.
    2804 For instance, in the expression ``\lstinline$fTpfT(17)$'', \lstinline$T$ is inferred to be \lstinline$int$, and the returned value would have type \lstinline$int ( * )( int )$. ``\lstinline$fTpfT(17)(13)$'' and
     3525\lstinline$fvpfi()$ and \lstinline$fvpfT()$ are functions taking no arguments and returning pointers
     3526to functions. \lstinline$fvpfT()$ is monomorphic, but the function that its return value points
     3527at is polymorphic.
     3528\begin{lstlisting}
     3529forall( type T ) int ( *fTpfi( T ) )( int );
     3530forall( type T ) T ( *fTpfT( T ) )( T );
     3531forall( type T, type U ) U ( *fTpfU( T ) )( U );
     3532\end{lstlisting}
     3533\lstinline$fTpfi()$ is a polymorphic function that returns a pointer to a monomorphic function
     3534taking an integer and returning an integer. It could return \lstinline$pfi$. \lstinline$fTpfT()$
     3535is subtle: it is a polymorphic function returning a \emph{monomorphic} function taking and returning
     3536\lstinline$T$, where \lstinline$T$ is an inferred parameter of \lstinline$fTpfT()$. For instance,
     3537in the expression ``\lstinline$fTpfT(17)$'', \lstinline$T$ is inferred to be \lstinline$int$, and
     3538the returned value would have type \lstinline$int ( * )( int )$. ``\lstinline$fTpfT(17)(13)$'' and
    28053539``\lstinline$fTpfT("yes")("no")$'' are legal, but ``\lstinline$fTpfT(17)("no")$'' is illegal.
    2806 \lstinline$fTpfU()$ is polymorphic ( in type \lstinline$T$), and returns a pointer to a function that is polymorphic ( in type \lstinline$U$). ``\lstinline$f5(17)("no")$'' is a legal expression of type
     3540\lstinline$fTpfU()$ is polymorphic ( in type \lstinline$T$), and returns a pointer to a function that
     3541is polymorphic ( in type \lstinline$U$). ``\lstinline$f5(17)("no")$'' is a legal expression of type
    28073542\lstinline$char *$.
    28083543\begin{lstlisting}
    2809 forall( otype T, otype U, otype V ) U * f( T *, U, V * const );
    2810 forall( otype U, otype V, otype W ) U * g( V *, U, W * const );
    2811 \end{lstlisting}
    2812 The functions \lstinline$f()$ and \lstinline$g()$ have compatible types.
    2813 Let \(f\) and \(g\) be their types;
    2814 then \(f_1\) = \lstinline$T$, \(f_2\) = \lstinline$U$, \(f_3\) = \lstinline$V$, \(g_1\)
    2815 = \lstinline$V$, \(g_2\) = \lstinline$U$, and \(g_3\) = \lstinline$W$.
    2816 Replacing every \(f_i\) by \(g_i\) in \(f\) gives
    2817 \begin{lstlisting}
    2818 forall( otype V, otype U, otype W ) U * f( V *, U, W * const );
    2819 \end{lstlisting} which has a return type and parameter list that is compatible with \(g\).
    2820 \begin{rationale}
    2821 The word ``\lstinline$type$'' in a forall specifier is redundant at the moment, but I want to leave room for inferred parameters of ordinary types in case parameterized types get added one day.
     3544forall( type T, type U, type V ) U * f( T *, U, V * const );
     3545forall( type U, type V, type W ) U * g( V *, U, W * const );
     3546\end{lstlisting}
     3547The functions \lstinline$f()$ and \lstinline$g()$ have compatible types. Let \(f\) and \(g\) be
     3548their types; then \(f_1\) = \lstinline$T$, \(f_2\) = \lstinline$U$, \(f_3\) = \lstinline$V$, \(g_1\)
     3549= \lstinline$V$, \(g_2\) = \lstinline$U$, and \(g_3\) = \lstinline$W$. Replacing every \(f_i\)
     3550by \(g_i\) in \(f\) gives
     3551\begin{lstlisting}
     3552forall( type V, type U, type W ) U * f( V *, U, W * const );
     3553\end{lstlisting}
     3554which has a return type and parameter list that is compatible with \(g\).
     3555\begin{rationale}
     3556The word ``\lstinline$type$'' in a forall specifier is redundant at the moment, but I want to leave
     3557room for inferred parameters of ordinary types in case parameterized types get added one day.
    28223558
    28233559Even without parameterized types, I might try to allow
    28243560\begin{lstlisting}
    28253561forall( int n ) int sum( int vector[n] );
    2826 \end{lstlisting} but C currently rewrites array parameters as pointer parameters, so the effects of such a change require more thought.
    2827 \end{rationale}
    2828 
    2829 \begin{rationale}
    2830 A polymorphic declaration must do two things: it must introduce type parameters, and it must apply assertions to those types.
    2831 Adding this to existing C declaration syntax and semantics was delicate, and not entirely successful.
    2832 
    2833 C depends on declaration-before-use, so a forall specifier must introduce type names before they can be used in the declaration specifiers.
    2834 This could be done by making the forall specifier part of the declaration specifiers, or by making it a new introductory clause of declarations.
    2835 
    2836 Assertions are also part of polymorphic function types, because it must be clear which functions have access to the assertion parameters declared by the assertions.
    2837 All attempts to put assertions inside an introductory clause produced complex semantics and confusing code.
    2838 Building them into the declaration specifiers could be done by placing them in the function's parameter list, or in a forall specifier that is a declaration specifier.
    2839 Assertions are also used with type parameters of specifications, and by type declarations.
    2840 For consistency's sake it seems best to attach assertions to the type declarations in forall specifiers, which means that forall specifiers must be declaration specifiers.
     3562\end{lstlisting}
     3563but C currently rewrites array parameters as pointer parameters, so the effects of such a change
     3564require more thought.
     3565\end{rationale}
     3566
     3567\begin{rationale}
     3568A polymorphic declaration must do two things: it must introduce type parameters, and it must apply
     3569assertions to those types. Adding this to existing C declaration syntax and semantics was delicate,
     3570and not entirely successful.
     3571
     3572C depends on declaration-before-use, so a forall specifier must introduce type names before they can
     3573be used in the declaration specifiers. This could be done by making the forall specifier part of
     3574the declaration specifiers, or by making it a new introductory clause of declarations.
     3575
     3576Assertions are also part of polymorphic function types, because it must be clear which functions
     3577have access to the assertion parameters declared by the assertions. All attempts to put assertions
     3578inside an introductory clause produced complex semantics and confusing code. Building them into the
     3579declaration specifiers could be done by placing them in the function's parameter list, or in a
     3580forall specifier that is a declaration specifier. Assertions are also used with type parameters of
     3581specifications, and by type declarations. For consistency's sake it seems best to attach assertions
     3582to the type declarations in forall specifiers, which means that forall specifiers must be
     3583declaration specifiers.
    28413584\end{rationale}
    28423585%HERE
     
    28523595
    28533596\constraints
    2854 \lstinline$restrict$\index{register@{\lstinline$restrict$}} Types other than type parameters and pointer types whose referenced type is an object type shall not be restrict-qualified.
     3597\lstinline$restrict$\index{register@{\lstinline$restrict$}} Types other than type parameters and
     3598pointer types whose referenced type is an object type shall not be restrict-qualified.
    28553599
    28563600\semantics
    2857 An object's type may be a restrict-qualified type parameter. \lstinline$restrict$ does not establish any special semantics in that case.
    2858 
    2859 \begin{rationale}
    2860 \CFA loosens the constraint on the restrict qualifier so that restrict-qualified pointers may be passed to polymorphic functions.
    2861 \end{rationale}
    2862 
    2863 \lstinline$lvalue$ may be used to qualify the return type of a function type.
    2864 Let \lstinline$T$ be an unqualified version of a type;
    2865 then the result of calling a function with return type
     3601An object's type may be a restrict-qualified type parameter. \lstinline$restrict$ does not
     3602establish any special semantics in that case.
     3603
     3604\begin{rationale}
     3605\CFA loosens the constraint on the restrict qualifier so that restrict-qualified pointers may be
     3606passed to polymorphic functions.
     3607\end{rationale}
     3608
     3609\lstinline$lvalue$ may be used to qualify the return type of a function type. Let \lstinline$T$ be
     3610an unqualified version of a type; then the result of calling a function with return type
    28663611\lstinline$lvalue T$ is a \Index{modifiable lvalue} of type \lstinline$T$.
    2867 \lstinline$const$\use{const} and \lstinline$volatile$\use{volatile} qualifiers may also be added to indicate that the function result is a constant or volatile lvalue.
    2868 \begin{rationale}
    2869 The \lstinline$const$ and \lstinline$volatile$ qualifiers can only be sensibly used to qualify the return type of a function if the \lstinline$lvalue$ qualifier is also used.
    2870 \end{rationale}
    2871 
    2872 An {lvalue}-qualified type may be used in a \Index{cast expression} if the operand is an lvalue;
    2873 the result of the expression is an lvalue.
    2874 
    2875 \begin{rationale}
    2876 \lstinline$lvalue$ provides some of the functionality of {\CC}'s ``\lstinline$T&$'' ( reference to object of type \lstinline$T$) type.
    2877 Reference types have four uses in {\CC}.
     3612\lstinline$const$\use{const} and \lstinline$volatile$\use{volatile} qualifiers may also be added to
     3613indicate that the function result is a constant or volatile lvalue.
     3614\begin{rationale}
     3615The \lstinline$const$ and \lstinline$volatile$ qualifiers can only be sensibly used to qualify the
     3616return type of a function if the \lstinline$lvalue$ qualifier is also used.
     3617\end{rationale}
     3618
     3619An {lvalue}-qualified type may be used in a \Index{cast expression} if the operand is an lvalue; the
     3620result of the expression is an lvalue.
     3621
     3622\begin{rationale}
     3623\lstinline$lvalue$ provides some of the functionality of {\CC}'s ``\lstinline$T&$'' ( reference to
     3624object of type \lstinline$T$) type. Reference types have four uses in {\CC}.
    28783625\begin{itemize}
    28793626\item
     
    28823629
    28833630\item
    2884 A reference can be used to define an alias for a complicated lvalue expression, as a way of getting some of the functionality of the Pascal \lstinline$with$ statement.
    2885 The following {\CC} code gives an example.
     3631A reference can be used to define an alias for a complicated lvalue expression, as a way of getting
     3632some of the functionality of the Pascal \lstinline$with$ statement. The following {\CC} code gives
     3633an example.
    28863634\begin{lstlisting}
    28873635{
     
    28933641
    28943642\item
    2895 A reference parameter can be used to allow a function to modify an argument without forcing the caller to pass the address of the argument.
    2896 This is most useful for user-defined assignment operators.
    2897 In {\CC}, plain assignment is done by a function called ``\lstinline$operator=$'', and the two expressions
     3643A reference parameter can be used to allow a function to modify an argument without forcing the
     3644caller to pass the address of the argument. This is most useful for user-defined assignment
     3645operators. In {\CC}, plain assignment is done by a function called ``\lstinline$operator=$'', and
     3646the two expressions
    28983647\begin{lstlisting}
    28993648a = b;
    29003649operator=( a, b );
    2901 \end{lstlisting} are equivalent.
    2902 If \lstinline$a$ and \lstinline$b$ are of type \lstinline$T$, then the first parameter of \lstinline$operator=$ must have type ``\lstinline$T&$''.
    2903 It cannot have type
     3650\end{lstlisting}
     3651are equivalent. If \lstinline$a$ and \lstinline$b$ are of type \lstinline$T$, then the first
     3652parameter of \lstinline$operator=$ must have type ``\lstinline$T&$''. It cannot have type
    29043653\lstinline$T$, because then assignment couldn't alter the variable, and it can't have type
    29053654``\lstinline$T *$'', because the assignment would have to be written ``\lstinline$&a = b;$''.
    29063655
    2907 In the case of user-defined operators, this could just as well be handled by using pointer types and by changing the rewrite rules so that ``\lstinline$a = b;$'' is equivalent to
    2908 ``\lstinline$operator=(&( a), b )$''.
    2909 Reference parameters of ``normal'' functions are Bad Things, because they remove a useful property of C function calls: an argument can only be modified by a function if it is preceded by ``\lstinline$&$''.
     3656In the case of user-defined operators, this could just as well be handled by using pointer types and
     3657by changing the rewrite rules so that ``\lstinline$a = b;$'' is equivalent to
     3658``\lstinline$operator=(&( a), b )$''. Reference parameters of ``normal'' functions are Bad Things,
     3659because they remove a useful property of C function calls: an argument can only be modified by a
     3660function if it is preceded by ``\lstinline$&$''.
    29103661
    29113662\item
     
    29173668void fiddle( const Thing & );
    29183669\end{lstlisting}
    2919 If the second form is used, then constructors and destructors are not invoked to create a temporary variable at the call site ( and it is bad style for the caller to make any assumptions about such things), and within \lstinline$fiddle$ the parameter is subject to the usual problems caused by aliases.
    2920 The reference form might be chosen for efficiency's sake if \lstinline$Thing$s are too large or their constructors or destructors are too expensive.
    2921 An implementation may switch between them without causing trouble for well-behaved clients.
    2922 This leaves the implementor to define ``too large'' and ``too expensive''.
     3670If the second form is used, then constructors and destructors are not invoked to create a temporary
     3671variable at the call site ( and it is bad style for the caller to make any assumptions about such
     3672things), and within \lstinline$fiddle$ the parameter is subject to the usual problems caused by
     3673aliases. The reference form might be chosen for efficiency's sake if \lstinline$Thing$s are too
     3674large or their constructors or destructors are too expensive. An implementation may switch between
     3675them without causing trouble for well-behaved clients. This leaves the implementor to define ``too
     3676large'' and ``too expensive''.
    29233677
    29243678I propose to push this job onto the compiler by allowing it to implement
    29253679\begin{lstlisting}
    29263680void fiddle( const volatile Thing );
    2927 \end{lstlisting} with call-by-reference.
    2928 Since it knows all about the size of \lstinline$Thing$s and the parameter passing mechanism, it should be able to come up with a better definition of ``too large'', and may be able to make a good guess at ``too expensive''.
     3681\end{lstlisting}
     3682with call-by-reference. Since it knows all about the size of \lstinline$Thing$s and the parameter
     3683passing mechanism, it should be able to come up with a better definition of ``too large'', and may
     3684be able to make a good guess at ``too expensive''.
    29293685\end{itemize}
    29303686
    2931 In summary, since references are only really necessary for returning lvalues, I'll only provide lvalue functions.
     3687In summary, since references are only really necessary for returning lvalues, I'll only provide
     3688lvalue functions.
    29323689\end{rationale}
    29333690
     
    29363693\subsection{Initialization}
    29373694
    2938 An expression that is used as an \nonterm{initializer} is treated as being cast to the type of the object being initialized.
    2939 An expression used in an \nonterm{initializer-list} is treated as being cast to the type of the aggregate member that it initializes.
    2940 In either case the cast must have a single unambiguous \Index{interpretation}.
     3695An expression that is used as an \nonterm{initializer} is treated as being cast to the type of the
     3696object being initialized. An expression used in an \nonterm{initializer-list} is treated as being
     3697cast to the type of the aggregate member that it initializes. In either case the cast must have a
     3698single unambiguous \Index{interpretation}.
    29413699
    29423700
     
    29593717\end{syntax}
    29603718\begin{rationale}
    2961 The declarations allowed in a specification are much the same as those allowed in a structure, except that bit fields are not allowed, and \Index{incomplete type}s and function types are allowed.
     3719The declarations allowed in a specification are much the same as those allowed in a structure,
     3720except that bit fields are not allowed, and \Index{incomplete type}s and function types are allowed.
    29623721\end{rationale}
    29633722
    29643723\semantics
    2965 A \define{specification definition} defines a name for a \define{specification}: a parameterized collection of object and function declarations.
     3724A \define{specification definition} defines a name for a \define{specification}: a parameterized
     3725collection of object and function declarations.
    29663726
    29673727The declarations in a specification consist of the declarations in the
    29683728\nonterm{spec-declaration-list} and declarations produced by any assertions in the
    2969 \nonterm{spec-parameter-list}.
    2970 If the collection contains two declarations that declare the same identifier and have compatible types, they are combined into one declaration with the composite type constructed from the two types.
     3729\nonterm{spec-parameter-list}. If the collection contains two declarations that declare the same
     3730identifier and have compatible types, they are combined into one declaration with the composite type
     3731constructed from the two types.
    29713732
    29723733
     
    29863747
    29873748\constraints
    2988 The \nonterm{identifier} in an assertion that is not a \nonterm{spec-declaration} shall be the name of a specification.
    2989 The \nonterm{type-name-list} shall contain one \nonterm{type-name} argument for each \nonterm{type-parameter} in that specification's \nonterm{spec-parameter-list}.
    2990 If the
    2991 \nonterm{type-parameter} uses type-class \lstinline$type$\use{type}, the argument shall be the type name of an \Index{object type};
    2992 if it uses \lstinline$dtype$, the argument shall be the type name of an object type or an \Index{incomplete type};
    2993 and if it uses \lstinline$ftype$, the argument shall be the type name of a \Index{function type}.
     3749The \nonterm{identifier} in an assertion that is not a \nonterm{spec-declaration} shall be the name
     3750of a specification. The \nonterm{type-name-list} shall contain one \nonterm{type-name} argument for
     3751each \nonterm{type-parameter} in that specification's \nonterm{spec-parameter-list}. If the
     3752\nonterm{type-parameter} uses type-class \lstinline$type$\use{type}, the argument shall be the type
     3753name of an \Index{object type}; if it uses \lstinline$dtype$, the argument shall be the type name of
     3754an object type or an \Index{incomplete type}; and if it uses \lstinline$ftype$, the argument shall
     3755be the type name of a \Index{function type}.
    29943756
    29953757\semantics
     
    29973759\define{assertion parameters}.
    29983760
    2999 The assertion parameters produced by an assertion that applies the name of a specification to type arguments are found by taking the declarations specified in the specification and treating each of the specification's parameters as a synonym for the corresponding \nonterm{type-name} argument.
    3000 
    3001 The collection of assertion parameters produced by the \nonterm{assertion-list} are found by combining the declarations produced by each assertion.
    3002 If the collection contains two declarations that declare the same identifier and have compatible types, they are combined into one declaration with the \Index{composite type} constructed from the two types.
     3761The assertion parameters produced by an assertion that applies the name of a specification to type
     3762arguments are found by taking the declarations specified in the specification and treating each of
     3763the specification's parameters as a synonym for the corresponding \nonterm{type-name} argument.
     3764
     3765The collection of assertion parameters produced by the \nonterm{assertion-list} are found by
     3766combining the declarations produced by each assertion. If the collection contains two declarations
     3767that declare the same identifier and have compatible types, they are combined into one declaration
     3768with the \Index{composite type} constructed from the two types.
    30033769
    30043770\examples
    30053771\begin{lstlisting}
    3006 forall( otype T | T ?*?( T, T ))@\use{?*?}@
     3772forall( type T | T ?*?( T, T ))@\use{?*?}@
    30073773T square( T val ) {@\impl{square}@
    30083774        return val + val;
    30093775}
    3010 trait summable( otype T ) {@\impl{summable}@
     3776
     3777context summable( type T ) {@\impl{summable}@
    30113778        T ?+=?( T *, T );@\use{?+=?}@
    30123779        const T 0;@\use{0}@
    30133780};
    3014 trait list_of( otype List, otype Element ) {@\impl{list_of}@
     3781context list_of( type List, type Element ) {@\impl{list_of}@
    30153782        Element car( List );
    30163783        List cdr( List );
     
    30193786        int is_nil( List );
    30203787};
    3021 trait sum_list( otype List, otype Element | summable( Element ) | list_of( List, Element ) ) {};
    3022 \end{lstlisting}
    3023 \lstinline$sum_list$ contains seven declarations, which describe a list whose elements can be added up.
    3024 The assertion ``\lstinline$|sum_list( i_list, int )$''\use{sum_list} produces the assertion parameters
     3788context sum_list( type List, type Element | summable( Element ) | list_of( List, Element ) ) {};
     3789\end{lstlisting}
     3790\lstinline$sum_list$ contains seven declarations, which describe a list whose elements can be added
     3791up. The assertion ``\lstinline$|sum_list( i_list, int )$''\use{sum_list} produces the assertion
     3792parameters
    30253793\begin{lstlisting}
    30263794int ?+=?( int *, int );
     
    30573825
    30583826\constraints
    3059 If a type declaration has block scope, and the declared identifier has external or internal linkage, the declaration shall have no initializer for the identifier.
     3827If a type declaration has block scope, and the declared identifier has external or internal linkage,
     3828the declaration shall have no initializer for the identifier.
    30603829
    30613830\semantics
    3062 A \nonterm{type-parameter} or a \nonterm{type-declarator} declares an identifier to be a \Index{type name} for a type incompatible with all other types.
    3063 
    3064 An identifier declared by a \nonterm{type-parameter} has \Index{no linkage}.
    3065 Identifiers declared with type-class \lstinline$type$\use{type} are \Index{object type}s;
    3066 those declared with type-class
    3067 \lstinline$dtype$\use{dtype} are \Index{incomplete type}s;
    3068 and those declared with type-class
    3069 \lstinline$ftype$\use{ftype} are \Index{function type}s.
    3070 The identifier has \Index{block scope} that terminates at the end of the \nonterm{spec-declaration-list} or polymorphic function that contains the \nonterm{type-parameter}.
    3071 
    3072 A \nonterm{type-declarator} with an \Index{initializer} is a \define{type definition}.  The declared identifier is an \Index{incomplete type} within the initializer, and an \Index{object type} after the end of the initializer.
    3073 The type in the initializer is called the \define{implementation
    3074   type}.
    3075 Within the scope of the declaration, \Index{implicit conversion}s can be performed between the defined type and the implementation type, and between pointers to the defined type and pointers to the implementation type.
    3076 
    3077 A type declaration without an \Index{initializer} and without a \Index{storage-class specifier} or with storage-class specifier \lstinline$static$\use{static} defines an \Index{incomplete type}.
    3078 If a
    3079 \Index{translation unit} or \Index{block} contains one or more such declarations for an identifier, it must contain exactly one definition of the identifier ( but not in an enclosed block, which would define a new type known only within that block).
     3831A \nonterm{type-parameter} or a \nonterm{type-declarator} declares an identifier to be a \Index{type
     3832name} for a type incompatible with all other types.
     3833
     3834An identifier declared by a \nonterm{type-parameter} has \Index{no linkage}. Identifiers declared
     3835with type-class \lstinline$type$\use{type} are \Index{object type}s; those declared with type-class
     3836\lstinline$dtype$\use{dtype} are \Index{incomplete type}s; and those declared with type-class
     3837\lstinline$ftype$\use{ftype} are \Index{function type}s. The identifier has \Index{block scope} that
     3838terminates at the end of the \nonterm{spec-declaration-list} or polymorphic function that contains
     3839the \nonterm{type-parameter}.
     3840
     3841A \nonterm{type-declarator} with an \Index{initializer} is a \define{type definition}.  The declared
     3842identifier is an \Index{incomplete type} within the initializer, and an \Index{object type} after
     3843the end of the initializer. The type in the initializer is called the \define{implementation
     3844  type}. Within the scope of the declaration, \Index{implicit conversion}s can be performed between
     3845the defined type and the implementation type, and between pointers to the defined type and pointers
     3846to the implementation type.
     3847
     3848A type declaration without an \Index{initializer} and without a \Index{storage-class specifier} or
     3849with storage-class specifier \lstinline$static$\use{static} defines an \Index{incomplete type}. If a
     3850\Index{translation unit} or \Index{block} contains one or more such declarations for an identifier,
     3851it must contain exactly one definition of the identifier ( but not in an enclosed block, which would
     3852define a new type known only within that block).
    30803853\begin{rationale}
    30813854Incomplete type declarations allow compact mutually-recursive types.
    30823855\begin{lstlisting}
    3083 otype t1; // incomplete type declaration
    3084 otype t2 = struct { t1 * p; ... };
    3085 otype t1 = struct { t2 * p; ... };
    3086 \end{lstlisting}
    3087 Without them, mutual recursion could be handled by declaring mutually recursive structures, then initializing the types to those structures.
     3856type t1; // Incomplete type declaration.
     3857type t2 = struct { t1 * p; ... };
     3858type t1 = struct { t2 * p; ... };
     3859\end{lstlisting}
     3860Without them, mutual recursion could be handled by declaring mutually recursive structures, then
     3861initializing the types to those structures.
    30883862\begin{lstlisting}
    30893863struct s1;
    3090 otype t2 = struct s2 { struct s1 * p; ... };
    3091 otype t1 = struct s1 { struct s2 * p; ... };
    3092 \end{lstlisting}
    3093 This introduces extra names, and may force the programmer to cast between the types and their implementations.
     3864type t2 = struct s2 { struct s1 * p; ... };
     3865type t1 = struct s1 { struct s2 * p; ... };
     3866\end{lstlisting}
     3867This introduces extra names, and may force the programmer to cast between the types and their
     3868implementations.
    30943869\end{rationale}
    30953870
    30963871A type declaration without an initializer and with \Index{storage-class specifier}
    3097 \lstinline$extern$\use{extern} is an \define{opaque type declaration}.
    3098 Opaque types are
    3099 \Index{object type}s.
    3100 An opaque type is not a \nonterm{constant-expression};
    3101 neither is a structure or union that has a member whose type is not a \nonterm{constant-expression}.  Every other
    3102 \Index{object type} is a \nonterm{constant-expression}.
    3103 Objects with static storage duration shall be declared with a type that is a \nonterm{constant-expression}.
    3104 \begin{rationale}
    3105 Type declarations can declare identifiers with external linkage, whereas typedef declarations declare identifiers that only exist within a translation unit.
    3106 These opaque types can be used in declarations, but the implementation of the type is not visible.
    3107 
    3108 Static objects can not have opaque types because space for them would have to be allocated at program start-up.
    3109 This is a deficiency\index{deficiencies!static opaque objects}, but I don't want to deal with ``module initialization'' code just now.
    3110 \end{rationale}
    3111 
    3112 An \Index{incomplete type} which is not a qualified version\index{qualified type} of a type is a value of \Index{type-class} \lstinline$dtype$.
    3113 An object type\index{object types} which is not a qualified version of a type is a value of type-classes \lstinline$type$ and \lstinline$dtype$.
    3114 A
     3872\lstinline$extern$\use{extern} is an \define{opaque type declaration}. Opaque types are
     3873\Index{object type}s. An opaque type is not a \nonterm{constant-expression}; neither is a structure
     3874or union that has a member whose type is not a \nonterm{constant-expression}.  Every other
     3875\Index{object type} is a \nonterm{constant-expression}. Objects with static storage duration shall
     3876be declared with a type that is a \nonterm{constant-expression}.
     3877\begin{rationale}
     3878Type declarations can declare identifiers with external linkage, whereas typedef declarations
     3879declare identifiers that only exist within a translation unit. These opaque types can be used in
     3880declarations, but the implementation of the type is not visible.
     3881
     3882Static objects can not have opaque types because space for them would have to be allocated at
     3883program start-up. This is a deficiency\index{deficiencies!static opaque objects}, but I don't want
     3884to deal with ``module initialization'' code just now.
     3885\end{rationale}
     3886
     3887An \Index{incomplete type} which is not a qualified version\index{qualified type} of a type is a
     3888value of \Index{type-class} \lstinline$dtype$. An object type\index{object types} which is not a
     3889qualified version of a type is a value of type-classes \lstinline$type$ and \lstinline$dtype$. A
    31153890\Index{function type} is a value of type-class \lstinline$ftype$.
    31163891\begin{rationale}
    3117 Syntactically, a type value is a \nonterm{type-name}, which is a declaration for an object which omits the identifier being declared.
    3118 
    3119 Object types are precisely the types that can be instantiated.
    3120 Type qualifiers are not included in type values because the compiler needs the information they provide at compile time to detect illegal statements or to produce efficient machine instructions.
    3121 For instance, the code that a compiler must generate to manipulate an object that has volatile-qualified type may be different from the code to manipulate an ordinary object.
    3122 
    3123 Type qualifiers are a weak point of C's type system.
    3124 Consider the standard library function
    3125 \lstinline$strchr()$ which, given a string and a character, returns a pointer to the first occurrence of the character in the string.
     3892Syntactically, a type value is a \nonterm{type-name}, which is a declaration for an object which
     3893omits the identifier being declared.
     3894
     3895Object types are precisely the types that can be instantiated. Type qualifiers are not included in
     3896type values because the compiler needs the information they provide at compile time to detect
     3897illegal statements or to produce efficient machine instructions. For instance, the code that a
     3898compiler must generate to manipulate an object that has volatile-qualified type may be different
     3899from the code to manipulate an ordinary object.
     3900
     3901Type qualifiers are a weak point of C's type system. Consider the standard library function
     3902\lstinline$strchr()$ which, given a string and a character, returns a pointer to the first
     3903occurrence of the character in the string.
    31263904\begin{lstlisting}
    31273905char *strchr( const char *s, int c ) {@\impl{strchr}@
    31283906        char real_c = c; // done because c was declared as int.
    31293907        for ( ; *s != real_c; s++ )
    3130                 if ( *s == '\0' ) return NULL;
     3908         if ( *s == '\0' ) return NULL;
    31313909        return ( char * )s;
    31323910}
    31333911\end{lstlisting}
    3134 The parameter \lstinline$s$ must be \lstinline$const char *$, because \lstinline$strchr()$ might be used to search a constant string, but the return type must be \lstinline$char *$, because the result might be used to modify a non-constant string.
    3135 Hence the body must perform a cast, and ( even worse)
    3136 \lstinline$strchr()$ provides a type-safe way to attempt to modify constant strings.
    3137 What is needed is some way to say that \lstinline$s$'s type might contain qualifiers, and the result type has exactly the same qualifiers.
    3138 Polymorphic functions do not provide a fix for this deficiency\index{deficiencies!pointers to qualified types}, because type qualifiers are not part of type values.
    3139 Instead, overloading can be used to define \lstinline$strchr()$ for each combination of qualifiers.
    3140 \end{rationale}
    3141 
    3142 \begin{rationale}
    3143 Since \Index{incomplete type}s are not type values, they can not be used as the initializer in a type declaration, or as the type of a structure or union member.
    3144 This prevents the declaration of types that contain each other.
    3145 \begin{lstlisting}
    3146 otype t1;
    3147 otype t2 = t1; // illegal: incomplete type t1
    3148 otype t1 = t2;
    3149 \end{lstlisting}
    3150 
    3151 The initializer in a file-scope declaration must be a constant expression.
    3152 This means type declarations can not build on opaque types, which is a deficiency\index{deficiencies!nesting opaque
     3912The parameter \lstinline$s$ must be \lstinline$const char *$, because \lstinline$strchr()$ might be
     3913used to search a constant string, but the return type must be \lstinline$char *$, because the result
     3914might be used to modify a non-constant string. Hence the body must perform a cast, and ( even worse)
     3915\lstinline$strchr()$ provides a type-safe way to attempt to modify constant strings. What is needed
     3916is some way to say that \lstinline$s$'s type might contain qualifiers, and the result type has
     3917exactly the same qualifiers. Polymorphic functions do not provide a fix for this
     3918deficiency\index{deficiencies!pointers to qualified types}, because type qualifiers are not part of
     3919type values. Instead, overloading can be used to define \lstinline$strchr()$ for each combination
     3920of qualifiers.
     3921\end{rationale}
     3922
     3923\begin{rationale}
     3924Since \Index{incomplete type}s are not type values, they can not be used as the initializer in a
     3925type declaration, or as the type of a structure or union member. This prevents the declaration of
     3926types that contain each other.
     3927\begin{lstlisting}
     3928type t1;
     3929type t2 = t1; // illegal: incomplete type t1.
     3930type t1 = t2;
     3931\end{lstlisting}
     3932
     3933The initializer in a file-scope declaration must be a constant expression. This means type
     3934declarations can not build on opaque types, which is a deficiency\index{deficiencies!nesting opaque
    31533935 types}.
    31543936\begin{lstlisting}
    3155 extern otype Huge; // extended-precision integer type
    3156 otype Rational = struct {
     3937extern type Huge; // extended-precision integer type.
     3938type Rational = struct {
    31573939        Huge numerator, denominator;    // illegal
    31583940};
     
    31623944\end{lstlisting}
    31633945Without this restriction, \CFA might require ``module initialization'' code ( since
    3164 \lstinline$Rational$ has external linkage, it must be created before any other translation unit instantiates it), and would force an ordering on the initialization of the translation unit that defines \lstinline$Huge$ and the translation that declares \lstinline$Rational$.
    3165 
    3166 A benefit of the restriction is that it prevents the declaration in separate translation units of types that contain each other, which would be hard to prevent otherwise.
     3946\lstinline$Rational$ has external linkage, it must be created before any other translation unit
     3947instantiates it), and would force an ordering on the initialization of the translation unit that
     3948defines \lstinline$Huge$ and the translation that declares \lstinline$Rational$.
     3949
     3950A benefit of the restriction is that it prevents the declaration in separate translation units of
     3951types that contain each other, which would be hard to prevent otherwise.
    31673952\begin{lstlisting}
    31683953//  File a.c:
     
    31773962\begin{rationale}
    31783963Since a \nonterm{type-declaration} is a \nonterm{declaration} and not a
    3179 \nonterm{struct-declaration}, type declarations can not be structure members.
    3180 The form of
     3964\nonterm{struct-declaration}, type declarations can not be structure members. The form of
    31813965\nonterm{type-declaration} forbids arrays of, pointers to, and functions returning \lstinline$type$.
    3182 Hence the syntax of \nonterm{type-specifier} does not have to be extended to allow type-valued expressions.
    3183 It also side-steps the problem of type-valued expressions producing different values in different declarations.
    3184 
    3185 Since a type declaration is not a \nonterm{parameter-declaration}, functions can not have explicit type parameters.
    3186 This may be too restrictive, but it attempts to make compilation simpler.
    3187 Recall that when traditional C scanners read in an identifier, they look it up in the symbol table to determine whether or not it is a typedef name, and return a ``type'' or ``identifier'' token depending on what they find.
    3188 A type parameter would add a type name to the current scope.
    3189 The scope manipulations involved in parsing the declaration of a function that takes function pointer parameters and returns a function pointer may just be too complicated.
    3190 
    3191 Explicit type parameters don't seem to be very useful, anyway, because their scope would not include the return type of the function.
    3192 Consider the following attempt to define a type-safe memory allocation function.
     3966Hence the syntax of \nonterm{type-specifier} does not have to be extended to allow type-valued
     3967expressions. It also side-steps the problem of type-valued expressions producing different values
     3968in different declarations.
     3969
     3970Since a type declaration is not a \nonterm{parameter-declaration}, functions can not have explicit
     3971type parameters. This may be too restrictive, but it attempts to make compilation simpler. Recall
     3972that when traditional C scanners read in an identifier, they look it up in the symbol table to
     3973determine whether or not it is a typedef name, and return a ``type'' or ``identifier'' token
     3974depending on what they find. A type parameter would add a type name to the current scope. The
     3975scope manipulations involved in parsing the declaration of a function that takes function pointer
     3976parameters and returns a function pointer may just be too complicated.
     3977
     3978Explicit type parameters don't seem to be very useful, anyway, because their scope would not include
     3979the return type of the function. Consider the following attempt to define a type-safe memory
     3980allocation function.
    31933981\begin{lstlisting}
    31943982#include <stdlib.h>
    3195 T * new( otype T ) { return ( T * )malloc( sizeof( T) ); };
    3196 @\ldots@ int * ip = new( int );
    3197 \end{lstlisting}
    3198 This looks sensible, but \CFA's declaration-before-use rules mean that ``\lstinline$T$'' in the function body refers to the parameter, but the ``\lstinline$T$'' in the return type refers to the meaning of \lstinline$T$ in the scope that contains \lstinline$new$;
    3199 it could be undefined, or a type name, or a function or variable name.
    3200 Nothing good can result from such a situation.
     3983T * new( type T ) { return ( T * )malloc( sizeof( T) ); };
     3984@\ldots@
     3985int * ip = new( int );
     3986\end{lstlisting}
     3987This looks sensible, but \CFA's declaration-before-use rules mean that ``\lstinline$T$'' in the
     3988function body refers to the parameter, but the ``\lstinline$T$'' in the return type refers to the
     3989meaning of \lstinline$T$ in the scope that contains \lstinline$new$; it could be undefined, or a
     3990type name, or a function or variable name. Nothing good can result from such a situation.
    32013991\end{rationale}
    32023992
     
    32043994Since type declarations create new types, instances of types are always passed by value.
    32053995\begin{lstlisting}
    3206 otype A1 = int[2];
     3996type A1 = int[2];
    32073997void f1( A1 a ) { a[0] = 0; };
    3208 otypedef int A2[2];
     3998typedef int A2[2];
    32093999void f2( A2 a ) { a[0] = 0; };
    32104000A1 v1;
     
    32134003f2( v2 );
    32144004\end{lstlisting}
    3215 \lstinline$V1$ is passed by value, so \lstinline$f1()$'s assignment to \lstinline$a[0]$ does not modify v1.  \lstinline$V2$ is converted to a pointer, so \lstinline$f2()$ modifies \lstinline$v2[0]$.
     4005\lstinline$V1$ is passed by value, so \lstinline$f1()$'s assignment to \lstinline$a[0]$ does not
     4006modify v1.  \lstinline$V2$ is converted to a pointer, so \lstinline$f2()$ modifies
     4007\lstinline$v2[0]$.
    32164008
    32174009A translation unit containing the declarations
    32184010\begin{lstlisting}
    3219 extern type Complex;@\use{Complex}@ // opaque type declaration
     4011extern type Complex;@\use{Complex}@ // opaque type declaration.
    32204012extern float abs( Complex );@\use{abs}@
    3221 \end{lstlisting} can contain declarations of complex numbers, which can be passed to \lstinline$abs$.
    3222 Some other translation unit must implement \lstinline$Complex$ and \lstinline$abs$.
    3223 That unit might contain the declarations
    3224 \begin{lstlisting}
    3225 otype Complex = struct { float re, im; };@\impl{Complex}@
     4013\end{lstlisting}
     4014can contain declarations of complex numbers, which can be passed to \lstinline$abs$. Some other
     4015translation unit must implement \lstinline$Complex$ and \lstinline$abs$. That unit might contain
     4016the declarations
     4017\begin{lstlisting}
     4018type Complex = struct { float re, im; };@\impl{Complex}@
    32264019Complex cplx_i = { 0.0, 1.0 };@\impl{cplx_i}@
    32274020float abs( Complex c ) {@\impl{abs( Complex )}@
     
    32294022}
    32304023\end{lstlisting}
    3231 Note that \lstinline$c$ is implicitly converted to a \lstinline$struct$ so that its components can be retrieved.
    3232 
    3233 \begin{lstlisting}
    3234 otype Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
     4024Note that \lstinline$c$ is implicitly converted to a \lstinline$struct$ so that its components can
     4025be retrieved.
     4026
     4027\begin{lstlisting}
     4028type Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
    32354029Time_of_day ?+?( Time_of_day t1, int seconds ) {@\impl{?+?}@
    32364030        return (( int)t1 + seconds ) % 86400;
     
    32404034
    32414035\begin{rationale}
    3242 Within the scope of a type definition, an instance of the type can be viewed as having that type or as having the implementation type.
    3243 In the \lstinline$Time_of_day$ example, the difference is important.
    3244 Different languages have treated the distinction between the abstraction and the implementation in different ways.
     4036Within the scope of a type definition, an instance of the type can be viewed as having that type or
     4037as having the implementation type. In the \lstinline$Time_of_day$ example, the difference is
     4038important. Different languages have treated the distinction between the abstraction and the
     4039implementation in different ways.
    32454040\begin{itemize}
    32464041\item
    3247 Inside a Clu cluster \cite{CLU}, the declaration of an instance states which view applies.
    3248 Two primitives called \lstinline$up$ and \lstinline$down$ can be used to convert between the views.
    3249 \item
    3250 The Simula class \cite{SIMULA87} is essentially a record type.
    3251 Since 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.
    3252 In {\CC}
    3253 \cite{C++}, operations on class instances include assignment and ``\lstinline$&$'', which can be overloaded.
    3254 A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used.
    3255 \item
    3256 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.
    3257 The derived subprograms are clones of the existing subprograms with the old type replaced by the derived type.
    3258 Literals and aggregates of the old type are also cloned.
     4042Inside a Clu cluster \cite{clu}, the declaration of an instance states which view applies. Two
     4043primitives called \lstinline$up$ and \lstinline$down$ can be used to convert between the views.
     4044\item
     4045The Simula class \cite{Simula87} is essentially a record type. Since the only operations on a
     4046record are member selection and assignment, which can not be overloaded, there is never any
     4047ambiguity as to whether the abstraction or the implementation view is being used. In {\CC}
     4048\cite{c++}, operations on class instances include assignment and ``\lstinline$&$'', which can be
     4049overloaded. A ``scope resolution'' operator can be used inside the class to specify whether the
     4050abstract or implementation version of the operation should be used.
     4051\item
     4052An Ada derived type definition \cite{ada} creates a new type from an old type, and also implicitly
     4053declares derived subprograms that correspond to the existing subprograms that use the old type as a
     4054parameter type or result type. The derived subprograms are clones of the existing subprograms with
     4055the old type replaced by the derived type. Literals and aggregates of the old type are also cloned.
    32594056In other words, the abstract view provides exactly the same operations as the implementation view.
    32604057This allows the abstract view to be used in all cases.
    32614058
    3262 The derived subprograms can be replaced by programmer-specified subprograms.
    3263 This is an exception to the normal scope rules, which forbid duplicate definitions of a subprogram in a scope.
    3264 In this case, explicit conversions between the derived type and the old type can be used.
     4059The derived subprograms can be replaced by programmer-specified subprograms. This is an exception
     4060to the normal scope rules, which forbid duplicate definitions of a subprogram in a scope. In this
     4061case, explicit conversions between the derived type and the old type can be used.
    32654062\end{itemize}
    3266 \CFA's rules are like Clu's, except that implicit conversions and conversion costs allow it to do away with most uses of \lstinline$up$ and \lstinline$down$.
     4063\CFA's rules are like Clu's, except that implicit conversions and
     4064conversion costs allow it to do away with most uses of \lstinline$up$ and \lstinline$down$.
    32674065\end{rationale}
    32684066
     
    32724070A declaration\index{type declaration} of a type identifier \lstinline$T$ with type-class
    32734071\lstinline$type$ implicitly declares a \define{default assignment} function
    3274 \lstinline$T ?=?( T *, T )$\use{?=?}, with the same \Index{scope} and \Index{linkage} as the identifier \lstinline$T$.
    3275 \begin{rationale}
    3276 Assignment is central to C's imperative programming style, and every existing C object type has assignment defined for it ( except for array types, which are treated as pointer types for purposes of assignment).
    3277 Without this rule, nearly every inferred type parameter would need an accompanying assignment assertion parameter.
    3278 If a type parameter should not have an assignment operation,
    3279 \lstinline$dtype$ should be used.
    3280 If a type should not have assignment defined, the user can define an assignment function that causes a run-time error, or provide an external declaration but no definition and thus cause a link-time error.
    3281 \end{rationale}
    3282 
    3283 A definition\index{type definition} of a type identifier \lstinline$T$ with \Index{implementation type} \lstinline$I$ and type-class \lstinline$type$ implicitly defines a default assignment function.
    3284 A definition\index{type definition} of a type identifier \lstinline$T$ with implementation type \lstinline$I$ and an assertion list implicitly defines \define{default function}s and
    3285 \define{default object}s as declared by the assertion declarations.
    3286 The default objects and functions have the same \Index{scope} and \Index{linkage} as the identifier \lstinline$T$.
    3287 Their values are determined as follows:
     4072\lstinline$T ?=?( T *, T )$\use{?=?}, with the same \Index{scope} and \Index{linkage} as the
     4073identifier \lstinline$T$.
     4074\begin{rationale}
     4075Assignment is central to C's imperative programming style, and every existing C object type has
     4076assignment defined for it ( except for array types, which are treated as pointer types for purposes
     4077of assignment). Without this rule, nearly every inferred type parameter would need an accompanying
     4078assignment assertion parameter. If a type parameter should not have an assignment operation,
     4079\lstinline$dtype$ should be used. If a type should not have assignment defined, the user can define
     4080an assignment function that causes a run-time error, or provide an external declaration but no
     4081definition and thus cause a link-time error.
     4082\end{rationale}
     4083
     4084A definition\index{type definition} of a type identifier \lstinline$T$ with \Index{implementation
     4085type} \lstinline$I$ and type-class \lstinline$type$ implicitly defines a default assignment
     4086function. A definition\index{type definition} of a type identifier \lstinline$T$ with implementation
     4087type \lstinline$I$ and an assertion list implicitly defines \define{default function}s and
     4088\define{default object}s as declared by the assertion declarations. The default objects and
     4089functions have the same \Index{scope} and \Index{linkage} as the identifier \lstinline$T$. Their
     4090values are determined as follows:
    32884091\begin{itemize}
    32894092\item
    3290 If at the definition of \lstinline$T$ there is visible a declaration of an object with the same name as the default object, and if the type of that object with all occurrence of \lstinline$I$ replaced by \lstinline$T$ is compatible with the type of the default object, then the default object is initialized with that object.
    3291 Otherwise the scope of the declaration of \lstinline$T$ must contain a definition of the default object.
     4093If at the definition of \lstinline$T$ there is visible a declaration of an object with the same name
     4094as the default object, and if the type of that object with all occurrence of \lstinline$I$ replaced
     4095by \lstinline$T$ is compatible with the type of the default object, then the default object is
     4096initialized with that object. Otherwise the scope of the declaration of \lstinline$T$ must contain
     4097a definition of the default object.
    32924098
    32934099\item
    3294 If at the definition of \lstinline$T$ there is visible a declaration of a function with the same name as the default function, and if the type of that function with all occurrence of \lstinline$I$ replaced by \lstinline$T$ is compatible with the type of the default function, then the default function calls that function after converting its arguments and returns the converted result.
    3295 
    3296 Otherwise, if \lstinline$I$ contains exactly one anonymous member\index{anonymous member} such that at the definition of \lstinline$T$ there is visible a declaration of a function with the same name as the default function, and the type of that function with all occurrences of the anonymous member's type in its parameter list replaced by \lstinline$T$ is compatible with the type of the default function, then the default function calls that function after converting its arguments and returns the result.
    3297 
    3298 Otherwise the scope of the declaration of \lstinline$T$ must contain a definition of the default function.
     4100If at the definition of \lstinline$T$ there is visible a declaration of a function with the same
     4101name as the default function, and if the type of that function with all occurrence of \lstinline$I$
     4102replaced by \lstinline$T$ is compatible with the type of the default function, then the default
     4103function calls that function after converting its arguments and returns the converted result.
     4104
     4105Otherwise, if \lstinline$I$ contains exactly one anonymous member\index{anonymous member} such that
     4106at the definition of \lstinline$T$ there is visible a declaration of a function with the same name
     4107as the default function, and the type of that function with all occurrences of the anonymous
     4108member's type in its parameter list replaced by \lstinline$T$ is compatible with the type of the
     4109default function, then the default function calls that function after converting its arguments and
     4110returns the result.
     4111
     4112Otherwise the scope of the declaration of \lstinline$T$ must contain a definition of the default
     4113function.
    32994114\end{itemize}
    33004115\begin{rationale}
    3301 Note that a pointer to a default function will not compare as equal to a pointer to the inherited function.
    3302 \end{rationale}
    3303 
    3304 A function or object with the same type and name as a default function or object that is declared within the scope of the definition of \lstinline$T$ replaces the default function or object.
     4116Note that a pointer to a default function will not compare as equal to a pointer to the inherited
     4117function.
     4118\end{rationale}
     4119
     4120A function or object with the same type and name as a default function or object that is declared
     4121within the scope of the definition of \lstinline$T$ replaces the default function or object.
    33054122
    33064123\examples
    33074124\begin{lstlisting}
    3308 trait s( otype T ) {
     4125context s( type T ) {
    33094126        T a, b;
    3310 } struct impl { int left, right; } a = { 0, 0 };
    3311 otype Pair | s( Pair ) = struct impl;
     4127}
     4128struct impl { int left, right; } a = { 0, 0 };
     4129type Pair | s( Pair ) = struct impl;
    33124130Pair b = { 1, 1 };
    33134131\end{lstlisting}
    33144132The definition of \lstinline$Pair$ implicitly defines two objects \lstinline$a$ and \lstinline$b$.
    3315 \lstinline$Pair a$ inherits its value from the \lstinline$struct impl a$.
    3316 The definition of
    3317 \lstinline$Pair b$ is compulsory because there is no \lstinline$struct impl b$ to construct a value from.
    3318 \begin{lstlisting}
    3319 trait ss( otype T ) {
     4133\lstinline$Pair a$ inherits its value from the \lstinline$struct impl a$. The definition of
     4134\lstinline$Pair b$ is compulsory because there is no \lstinline$struct impl b$ to construct a value
     4135from.
     4136\begin{lstlisting}
     4137context ss( type T ) {
    33204138        T clone( T );
    33214139        void munge( T * );
    33224140}
    3323 otype Whatsit | ss( Whatsit );@\use{Whatsit}@
    3324 otype Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
     4141type Whatsit | ss( Whatsit );@\use{Whatsit}@
     4142type Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
    33254143        Whatsit; // anonymous member
    33264144        int extra;
     
    33344152void munge( Doodad * );
    33354153\end{lstlisting}
    3336 The assignment function inherits \lstinline$struct doodad$'s assignment function because the types match when \lstinline$struct doodad$ is replaced by \lstinline$Doodad$ throughout.
     4154The assignment function inherits \lstinline$struct doodad$'s assignment function because the types
     4155match when \lstinline$struct doodad$ is replaced by \lstinline$Doodad$ throughout.
    33374156\lstinline$munge()$ inherits \lstinline$Whatsit$'s \lstinline$munge()$ because the types match when
    3338 \lstinline$Whatsit$ is replaced by \lstinline$Doodad$ in the parameter list. \lstinline$clone()$ does \emph{not} inherit \lstinline$Whatsit$'s \lstinline$clone()$: replacement in the parameter list yields ``\lstinline$Whatsit clone( Doodad )$'', which is not compatible with
    3339 \lstinline$Doodad$'s \lstinline$clone()$'s type.
    3340 Hence the definition of
     4157\lstinline$Whatsit$ is replaced by \lstinline$Doodad$ in the parameter list. \lstinline$clone()$
     4158does \emph{not} inherit \lstinline$Whatsit$'s \lstinline$clone()$: replacement in the parameter
     4159list yields ``\lstinline$Whatsit clone( Doodad )$'', which is not compatible with
     4160\lstinline$Doodad$'s \lstinline$clone()$'s type. Hence the definition of
    33414161``\lstinline$Doodad clone( Doodad )$'' is necessary.
    33424162
    33434163Default functions and objects are subject to the normal scope rules.
    33444164\begin{lstlisting}
    3345 otype T = @\ldots@;
     4165type T = @\ldots@;
    33464166T a_T = @\ldots@;               // Default assignment used.
    33474167T ?=?( T *, T );
     
    33534173
    33544174\begin{rationale}
    3355 The \emph{class} construct of object-oriented programming languages performs three independent functions.
    3356 It \emph{encapsulates} a data structure;
    3357 it defines a \emph{subtype} relationship, whereby instances of one class may be used in contexts that require instances of another;
    3358 and it allows one class to \emph{inherit} the implementation of another.
    3359 
    3360 In \CFA, encapsulation is provided by opaque types and the scope rules, and subtyping is provided by specifications and assertions.
    3361 Inheritance is provided by default functions and objects.
     4175The \emph{class} construct of object-oriented programming languages performs three independent
     4176functions. It \emph{encapsulates} a data structure; it defines a \emph{subtype} relationship, whereby
     4177instances of one class may be used in contexts that require instances of another; and it allows one
     4178class to \emph{inherit} the implementation of another.
     4179
     4180In \CFA, encapsulation is provided by opaque types and the scope rules, and subtyping is provided
     4181by specifications and assertions. Inheritance is provided by default functions and objects.
    33624182\end{rationale}
    33634183
     
    33704190\end{syntax}
    33714191
    3372 Many statements contain expressions, which may have more than one interpretation.
    3373 The following sections describe how the \CFA translator selects an interpretation.
    3374 In all cases the result of the selection shall be a single unambiguous \Index{interpretation}.
     4192Many statements contain expressions, which may have more than one interpretation. The following
     4193sections describe how the \CFA translator selects an interpretation. In all cases the result of the
     4194selection shall be a single unambiguous \Index{interpretation}.
    33754195
    33764196
     
    34194239switch ( E ) ...
    34204240choose ( E ) ...
    3421 \end{lstlisting} may have more than one interpretation, but it shall have only one interpretation with an integral type.
     4241\end{lstlisting}
     4242may have more than one interpretation, but it shall have only one interpretation with an integral type.
    34224243An \Index{integer promotion} is performed on the expression if necessary.
    34234244The constant expressions in \lstinline$case$ statements with the switch are converted to the promoted type.
     
    34634284while ( E ) ...
    34644285do ... while ( E );
    3465 \end{lstlisting} is treated as ``\lstinline$( int )((E)!=0)$''.
     4286\end{lstlisting}
     4287is treated as ``\lstinline$( int )((E)!=0)$''.
    34664288
    34674289The statement
    34684290\begin{lstlisting}
    34694291for ( a; b; c ) @\ldots@
    3470 \end{lstlisting} is treated as
     4292\end{lstlisting}
     4293is treated as
    34714294\begin{lstlisting}
    34724295for ( ( void )( a ); ( int )(( b )!=0); ( void )( c ) ) ...
     
    35904413
    35914414The implementation shall define the macro names \lstinline$__LINE__$, \lstinline$__FILE__$,
    3592 \lstinline$__DATE__$, and \lstinline$__TIME__$, as in the {\c11} standard.
    3593 It shall not define the macro name \lstinline$__STDC__$.
    3594 
    3595 In addition, the implementation shall define the macro name \lstinline$__CFORALL__$ to be the decimal constant 1.
     4415\lstinline$__DATE__$, and \lstinline$__TIME__$, as in the {\c11} standard. It shall not define the
     4416macro name \lstinline$__STDC__$.
     4417
     4418In addition, the implementation shall define the macro name \lstinline$__CFORALL__$ to be the
     4419decimal constant 1.
    35964420
    35974421
     
    36034427
    36044428\section{C types}
    3605 This section gives example specifications for some groups of types that are important in the C language, in terms of the predefined operations that can be applied to those types.
     4429This section gives example specifications for some groups of types that are important in the C
     4430language, in terms of the predefined operations that can be applied to those types.
    36064431
    36074432
    36084433\subsection{Scalar, arithmetic, and integral types}
    36094434
    3610 The pointer, integral, and floating-point types are all \define{scalar types}.
    3611 All of these types can be logically negated and compared.
    3612 The assertion ``\lstinline$scalar( Complex )$'' should be read as ``type \lstinline$Complex$ is scalar''.
    3613 \begin{lstlisting}
    3614 trait scalar( otype T ) {@\impl{scalar}@
     4435The pointer, integral, and floating-point types are all \define{scalar types}. All of these types
     4436can be logically negated and compared. The assertion ``\lstinline$scalar( Complex )$'' should be read
     4437as ``type \lstinline$Complex$ is scalar''.
     4438\begin{lstlisting}
     4439context scalar( type T ) {@\impl{scalar}@
    36154440        int !?( T );
    36164441        int ?<?( T, T ), ?<=?( T, T ), ?==?( T, T ), ?>=?( T, T ), ?>?( T, T ), ?!=?( T, T );
     
    36184443\end{lstlisting}
    36194444
    3620 The integral and floating-point types are \define{arithmetic types}, which support the basic arithmetic operators.
    3621 The use of an assertion in the \nonterm{spec-parameter-list} declares that, in order to be arithmetic, a type must also be scalar ( and hence that scalar operations are available ).
    3622 This is equivalent to inheritance of specifications.
    3623 \begin{lstlisting}
    3624 trait arithmetic( otype T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
     4445The integral and floating-point types are \define{arithmetic types}, which support the basic
     4446arithmetic operators. The use of an assertion in the \nonterm{spec-parameter-list} declares that,
     4447in order to be arithmetic, a type must also be scalar ( and hence that scalar operations are
     4448available ). This is equivalent to inheritance of specifications.
     4449\begin{lstlisting}
     4450context arithmetic( type T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
    36254451        T +?( T ), -?( T );
    36264452        T ?*?( T, T ), ?/?( T, T ), ?+?( T, T ), ?-?( T, T );
     
    36314457\define{integral types}.
    36324458\begin{lstlisting}
    3633 trait integral( otype T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
     4459context integral( type T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
    36344460        T ~?( T );
    36354461        T ?&?( T, T ), ?|?( T, T ), ?^?( T, T );
     
    36454471The only operation that can be applied to all modifiable lvalues is simple assignment.
    36464472\begin{lstlisting}
    3647 trait m_lvalue( otype T ) {@\impl{m_lvalue}@
     4473context m_lvalue( type T ) {@\impl{m_lvalue}@
    36484474        T ?=?( T *, T );
    36494475};
     
    36514477
    36524478Modifiable scalar lvalues are scalars and are modifiable lvalues, and assertions in the
    3653 \nonterm{spec-parameter-list} reflect those relationships.
    3654 This is equivalent to multiple inheritance of specifications.
    3655 Scalars can also be incremented and decremented.
    3656 \begin{lstlisting}
    3657 trait m_l_scalar( otype T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
     4479\nonterm{spec-parameter-list} reflect those relationships. This is equivalent to multiple
     4480inheritance of specifications. Scalars can also be incremented and decremented.
     4481\begin{lstlisting}
     4482context m_l_scalar( type T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
    36584483        T ?++( T * ), ?--( T * );@\use{scalar}@@\use{m_lvalue}@
    36594484        T ++?( T * ), --?( T * );
     
    36614486\end{lstlisting}
    36624487
    3663 Modifiable arithmetic lvalues are both modifiable scalar lvalues and arithmetic.
    3664 Note that this results in the ``inheritance'' of \lstinline$scalar$ along both paths.
    3665 \begin{lstlisting}
    3666 trait m_l_arithmetic( otype T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
     4488Modifiable arithmetic lvalues are both modifiable scalar lvalues and arithmetic. Note that this
     4489results in the ``inheritance'' of \lstinline$scalar$ along both paths.
     4490\begin{lstlisting}
     4491context m_l_arithmetic( type T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
    36674492        T ?/=?( T *, T ), ?*=?( T *, T );@\use{m_l_scalar}@@\use{arithmetic}@
    36684493        T ?+=?( T *, T ), ?-=?( T *, T );
    36694494};
    3670 trait m_l_integral( otype T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
     4495
     4496context m_l_integral( type T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
    36714497        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );@\use{m_l_arithmetic}@
    36724498        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );@\use{integral}@
     
    36774503\subsection{Pointer and array types}
    36784504
    3679 Array types can barely be said to exist in {\c11}, since in most cases an array name is treated as a constant pointer to the first element of the array, and the subscript expression
     4505Array types can barely be said to exist in {\c11}, since in most cases an array name is treated as a
     4506constant pointer to the first element of the array, and the subscript expression
    36804507``\lstinline$a[i]$'' is equivalent to the dereferencing expression ``\lstinline$(*( a+( i )))$''.
    36814508Technically, pointer arithmetic and pointer comparisons other than ``\lstinline$==$'' and
    3682 ``\lstinline$!=$'' are only defined for pointers to array elements, but the type system does not enforce those restrictions.
    3683 Consequently, there is no need for a separate ``array type'' specification.
    3684 
    3685 Pointer types are scalar types.
    3686 Like other scalar types, they have ``\lstinline$+$'' and
     4509``\lstinline$!=$'' are only defined for pointers to array elements, but the type system does not
     4510enforce those restrictions. Consequently, there is no need for a separate ``array type''
     4511specification.
     4512
     4513Pointer types are scalar types. Like other scalar types, they have ``\lstinline$+$'' and
    36874514``\lstinline$-$'' operators, but the types do not match the types of the operations in
    36884515\lstinline$arithmetic$, so these operators cannot be consolidated in \lstinline$scalar$.
    36894516\begin{lstlisting}
    3690 trait pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
     4517context pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
    36914518        P ?+?( P, long int ), ?+?( long int, P ), ?-?( P, long int );
    36924519        ptrdiff_t ?-?( P, P );
    36934520};
    3694 trait m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
     4521
     4522context m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
    36954523        P ?+=?( P *, long int ), ?-=?( P *, long int );
    36964524        P ?=?( P *, void * );
     
    36994527\end{lstlisting}
    37004528
    3701 Specifications that define the dereference operator ( or subscript operator ) require two parameters, one for the pointer type and one for the pointed-at ( or element ) type.
    3702 Different specifications are needed for each set of \Index{type qualifier}s, because qualifiers are not included in types.
    3703 The assertion ``\lstinline$|ptr_to( Safe_pointer, int )$'' should be read as
     4529Specifications that define the dereference operator ( or subscript operator ) require two
     4530parameters, one for the pointer type and one for the pointed-at ( or element ) type. Different
     4531specifications are needed for each set of \Index{type qualifier}s, because qualifiers are not
     4532included in types. The assertion ``\lstinline$|ptr_to( Safe_pointer, int )$'' should be read as
    37044533``\lstinline$Safe_pointer$ acts like a pointer to \lstinline$int$''.
    37054534\begin{lstlisting}
    3706 trait ptr_to( otype P | pointer( P ), otype T ) {@\impl{ptr_to}@@\use{pointer}@
    3707         lvalue T *?( P );
    3708         lvalue T ?[?]( P, long int );
     4535context ptr_to( type P | pointer( P ), type T ) {@\impl{ptr_to}@@\use{pointer}@
     4536        lvalue T *?( P ); lvalue T ?[?]( P, long int );
    37094537};
    3710 trait ptr_to_const( otype P | pointer( P ), otype T ) {@\impl{ptr_to_const}@
    3711         const lvalue T *?( P );
    3712         const lvalue T ?[?]( P, long int );@\use{pointer}@
     4538
     4539context ptr_to_const( type P | pointer( P ), type T ) {@\impl{ptr_to_const}@
     4540        const lvalue T *?( P ); const lvalue T ?[?]( P, long int );@\use{pointer}@
    37134541};
    3714 trait ptr_to_volatile( otype P | pointer( P ), otype T ) }@\impl{ptr_to_volatile}@
    3715         volatile lvalue T *?( P );
    3716         volatile lvalue T ?[?]( P, long int );@\use{pointer}@
     4542
     4543context ptr_to_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_volatile}@
     4544        volatile lvalue T *?( P ); volatile lvalue T ?[?]( P, long int );@\use{pointer}@
    37174545};
    3718 trait ptr_to_const_volatile( otype P | pointer( P ), otype T ) }@\impl{ptr_to_const_volatile}@
     4546\end{lstlisting}
     4547\begin{lstlisting}
     4548context ptr_to_const_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_const_volatile}@
    37194549        const volatile lvalue T *?( P );@\use{pointer}@
    37204550        const volatile lvalue T ?[?]( P, long int );
     
    37224552\end{lstlisting}
    37234553
    3724 Assignment to pointers is more complicated than is the case with other types, because the target's type can have extra type qualifiers in the pointed-at type: a ``\lstinline$T *$'' can be assigned to a ``\lstinline$const T *$'', a ``\lstinline$volatile T *$'', and a ``\lstinline$const volatile T *$''.
     4554Assignment to pointers is more complicated than is the case with other types, because the target's
     4555type can have extra type qualifiers in the pointed-at type: a ``\lstinline$T *$'' can be assigned to
     4556a ``\lstinline$const T *$'', a ``\lstinline$volatile T *$'', and a ``\lstinline$const volatile T *$''.
    37254557Again, the pointed-at type is passed in, so that assertions can connect these specifications to the
    37264558``\lstinline$ptr_to$'' specifications.
    37274559\begin{lstlisting}
    3728 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}@ {
     4560context m_l_ptr_to( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to}@ type T | ptr_to( P, T )@\use{ptr_to}@ {
    37294561        P ?=?( P *, T * );
    37304562        T * ?=?( T **, P );
    37314563};
    3732 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}@) {
     4564
     4565context m_l_ptr_to_const( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_const}@ type T | ptr_to_const( P, T )@\use{ptr_to_const}@) {
    37334566        P ?=?( P *, const T * );
    37344567        const T * ?=?( const T **, P );
    37354568};
    3736 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}@
     4569
     4570context m_l_ptr_to_volatile( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_volatile}@ type T | ptr_to_volatile( P, T )) {@\use{ptr_to_volatile}@
    37374571        P ?=?( P *, volatile T * );
    37384572        volatile T * ?=?( volatile T **, P );
    37394573};
    3740 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}@
    3741                 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}@
     4574
     4575context 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}@
     4576                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}@
    37424577        P ?=?( P *, const volatile T * );
    37434578        const volatile T * ?=?( const volatile T **, P );
     
    37454580\end{lstlisting}
    37464581
    3747 Note the regular manner in which type qualifiers appear in those specifications.
    3748 An alternative specification can make use of the fact that qualification of the pointed-at type is part of a pointer type to capture that regularity.
    3749 \begin{lstlisting}
    3750 trait m_l_ptr_like( type MyP | m_l_pointer( MyP ),@\use{m_l_pointer}@@\impl{m_l_ptr_like}@ type CP | m_l_pointer( CP ) ) {
     4582Note the regular manner in which type qualifiers appear in those specifications. An alternative
     4583specification can make use of the fact that qualification of the pointed-at type is part of a
     4584pointer type to capture that regularity.
     4585\begin{lstlisting}
     4586context m_l_ptr_like( type MyP | m_l_pointer( MyP ),@\use{m_l_pointer}@@\impl{m_l_ptr_like}@ type CP | m_l_pointer( CP ) ) {
    37514587        MyP ?=?( MyP *, CP );
    37524588        CP ?=?( CP *, MyP );
     
    37544590\end{lstlisting}
    37554591The assertion ``\lstinline$| m_l_ptr_like( Safe_ptr, const int * )$'' should be read as
    3756 ``\lstinline$Safe_ptr$ is a pointer type like \lstinline$const int *$''.
    3757 This specification has two defects, compared to the original four: there is no automatic assertion that dereferencing a
     4592``\lstinline$Safe_ptr$ is a pointer type like \lstinline$const int *$''. This specification has two
     4593defects, compared to the original four: there is no automatic assertion that dereferencing a
    37584594\lstinline$MyP$ produces an lvalue of the type that \lstinline$CP$ points at, and the
    3759 ``\lstinline$|m_l_pointer( CP )$'' assertion provides only a weak assurance that the argument passed to \lstinline$CP$ really is a pointer type.
     4595``\lstinline$|m_l_pointer( CP )$'' assertion provides only a weak assurance that the argument passed
     4596to \lstinline$CP$ really is a pointer type.
    37604597
    37614598
    37624599\section{Relationships between operations}
    37634600
    3764 Different operators often have related meanings;
    3765 for instance, in C, ``\lstinline$+$'',
     4601Different operators often have related meanings; for instance, in C, ``\lstinline$+$'',
    37664602``\lstinline$+=$'', and the two versions of ``\lstinline$++$'' perform variations of addition.
    3767 Languages like {\CC} and Ada allow programmers to define operators for new types, but do not require that these relationships be preserved, or even that all of the operators be implemented.
    3768 Completeness and consistency is left to the good taste and discretion of the programmer.
    3769 It is possible to encourage these attributes by providing generic operator functions, or member functions of abstract classes, that are defined in terms of other, related operators.
    3770 
    3771 In \CFA, polymorphic functions provide the equivalent of these generic operators, and specifications explicitly define the minimal implementation that a programmer should provide.
    3772 This section shows a few examples.
     4603Languages like {\CC} and Ada allow programmers to define operators for new types, but do not
     4604require that these relationships be preserved, or even that all of the operators be implemented.
     4605Completeness and consistency is left to the good taste and discretion of the programmer. It is
     4606possible to encourage these attributes by providing generic operator functions, or member functions
     4607of abstract classes, that are defined in terms of other, related operators.
     4608
     4609In \CFA, polymorphic functions provide the equivalent of these generic operators, and
     4610specifications explicitly define the minimal implementation that a programmer should provide. This
     4611section shows a few examples.
    37734612
    37744613
    37754614\subsection{Relational and equality operators}
    37764615
    3777 The different comparison operators have obvious relationships, but there is no obvious subset of the operations to use in the implementation of the others.
    3778 However, it is usually convenient to implement a single comparison function that returns a negative integer, 0, or a positive integer if its first argument is respectively less than, equal to, or greater than its second argument;
    3779 the library function \lstinline$strcmp$ is an example.
    3780 
    3781 C and \CFA have an extra, non-obvious comparison operator: ``\lstinline$!$'', logical negation, returns 1 if its operand compares equal to 0, and 0 otherwise.
    3782 \begin{lstlisting}
    3783 trait comparable( otype T ) {
     4616The different comparison operators have obvious relationships, but there is no obvious subset of the
     4617operations to use in the implementation of the others. However, it is usually convenient to
     4618implement a single comparison function that returns a negative integer, 0, or a positive integer if
     4619its first argument is respectively less than, equal to, or greater than its second argument; the
     4620library function \lstinline$strcmp$ is an example.
     4621
     4622C and \CFA have an extra, non-obvious comparison operator: ``\lstinline$!$'', logical negation,
     4623returns 1 if its operand compares equal to 0, and 0 otherwise.
     4624\begin{lstlisting}
     4625context comparable( type T ) {
    37844626        const T 0;
    37854627        int compare( T, T );
    37864628}
    3787 forall( otype T | comparable( T ) ) int ?<?( T l, T r ) {
     4629
     4630forall( type T | comparable( T ) ) int ?<?( T l, T r ) {
    37884631        return compare( l, r ) < 0;
    37894632}
    37904633// ... similarly for <=, ==, >=, >, and !=.
    3791 forall( otype T | comparable( T ) ) int !?( T operand ) {
     4634
     4635forall( type T | comparable( T ) ) int !?( T operand ) {
    37924636        return !compare( operand, 0 );
    37934637}
     
    37974641\subsection{Arithmetic and integer operations}
    37984642
    3799 A complete arithmetic type would provide the arithmetic operators and the corresponding assignment operators.
    3800 Of these, the assignment operators are more likely to be implemented directly, because it is usually more efficient to alter the contents of an existing object than to create and return a new one.
    3801 Similarly, a complete integral type would provide integral operations based on integral assignment operations.
    3802 \begin{lstlisting}
    3803 trait arith_base( otype T ) {
     4643A complete arithmetic type would provide the arithmetic operators and the corresponding assignment
     4644operators. Of these, the assignment operators are more likely to be implemented directly, because
     4645it is usually more efficient to alter the contents of an existing object than to create and return a
     4646new one. Similarly, a complete integral type would provide integral operations based on integral
     4647assignment operations.
     4648\begin{lstlisting}
     4649context arith_base( type T ) {
    38044650        const T 1;
    38054651        T ?+=?( T *, T ), ?-=?( T *, T ), ?*=?( T *, T ), ?/=?( T *, T );
    38064652}
    3807 forall( otype T | arith_base( T ) ) T ?+?( T l, T r ) {
     4653
     4654forall( type T | arith_base( T ) ) T ?+?( T l, T r ) {
    38084655        return l += r;
    38094656}
    3810 forall( otype T | arith_base( T ) ) T ?++( T * operand ) {
     4657
     4658forall( type T | arith_base( T ) ) T ?++( T * operand ) {
    38114659        T temporary = *operand;
    38124660        *operand += 1;
    38134661        return temporary;
    38144662}
    3815 forall( otype T | arith_base( T ) ) T ++?( T * operand ) {
     4663
     4664forall( type T | arith_base( T ) ) T ++?( T * operand ) {
    38164665        return *operand += 1;
    38174666}
    38184667// ... similarly for -, --, *, and /.
    3819 trait int_base( otype T ) {
     4668
     4669context int_base( type T ) {
    38204670        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );
    38214671        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );
    38224672}
    3823 forall( otype T | int_base( T ) ) T ?&?( T l, T r ) {
     4673
     4674forall( type T | int_base( T ) ) T ?&?( T l, T r ) {
    38244675        return l &= r;
    38254676}
     
    38274678\end{lstlisting}
    38284679
    3829 Note that, although an arithmetic type would certainly provide comparison functions, and an integral type would provide arithmetic operations, there does not have to be any relationship among
    3830 \lstinline$int_base$, \lstinline$arith_base$ and \lstinline$comparable$.
    3831 Note also that these declarations provide guidance and assistance, but they do not define an absolutely minimal set of requirements.
    3832 A truly minimal implementation of an arithmetic type might only provide
     4680Note that, although an arithmetic type would certainly provide comparison functions, and an integral
     4681type would provide arithmetic operations, there does not have to be any relationship among
     4682\lstinline$int_base$, \lstinline$arith_base$ and \lstinline$comparable$. Note also that these
     4683declarations provide guidance and assistance, but they do not define an absolutely minimal set of
     4684requirements. A truly minimal implementation of an arithmetic type might only provide
    38334685\lstinline$0$, \lstinline$1$, and \lstinline$?-=?$, which would be used by polymorphic
    38344686\lstinline$?+=?$, \lstinline$?*=?$, and \lstinline$?/=?$ functions.
     
    38404692Review index entries.
    38414693
    3842 Restrict allowed to qualify anything, or type/dtype parameters, but only affects pointers.
    3843 This gets into \lstinline$noalias$ territory.
    3844 Qualifying anything (``\lstinline$short restrict rs$'') means pointer parameters of \lstinline$?++$, etc, would need restrict qualifiers.
    3845 
    3846 Enumerated types.
    3847 Constants are not ints.
    3848 Overloading.
    3849 Definition should be ``representable as an integer type'', not ``as an int''.
    3850 C11 usual conversions freely convert to and from ordinary integer types via assignment, which works between any integer types.
    3851 Does enum Color ?*?( enum
     4694Restrict allowed to qualify anything, or type/dtype parameters, but only affects pointers. This gets
     4695into \lstinline$noalias$ territory. Qualifying anything (``\lstinline$short restrict rs$'') means
     4696pointer parameters of \lstinline$?++$, etc, would need restrict qualifiers.
     4697
     4698Enumerated types. Constants are not ints. Overloading. Definition should be ``representable as an
     4699integer type'', not ``as an int''. C11 usual conversions freely convert to and from ordinary
     4700integer types via assignment, which works between any integer types. Does enum Color ?*?( enum
    38524701Color, enum Color ) really make sense? ?++ does, but it adds (int)1.
    38534702
    3854 Operators on {,signed,unsigned} char and other small types. ?<? harmless;
    3855 ?*? questionable for chars.
    3856 Generic selections make these choices visible.
    3857 Safe conversion operators? Predefined
     4703Operators on {,signed,unsigned} char and other small types. ?<? harmless; ?*? questionable for
     4704chars. Generic selections make these choices visible. Safe conversion operators? Predefined
    38584705``promotion'' function?
    38594706
    3860 \lstinline$register$ assignment might be handled as assignment to a temporary with copying back and forth, but copying must not be done by assignment.
     4707\lstinline$register$ assignment might be handled as assignment to a temporary with copying back and
     4708forth, but copying must not be done by assignment.
    38614709
    38624710Don't use ptrdiff\_t by name in the predefineds.
    38634711
    3864 Polymorphic objects.
    3865 Polymorphic typedefs and type declarations.
     4712Polymorphic objects. Polymorphic typedefs and type declarations.
    38664713
    38674714
    38684715\bibliographystyle{plain}
    3869 \bibliography{cfa}
     4716\bibliography{refrat}
    38704717
    38714718
    38724719\addcontentsline{toc}{chapter}{\indexname} % add index name to table of contents
    38734720\begin{theindex}
    3874 Italic page numbers give the location of the main entry for the referenced term.
    3875 Plain page numbers denote uses of the indexed term.
    3876 Entries for grammar non-terminals are italicized.
    3877 A typewriter font is used for grammar terminals and program identifiers.
     4721Italic page numbers give the location of the main entry for the referenced term. Plain page numbers
     4722denote uses of the indexed term. Entries for grammar non-terminals are italicized. A typewriter
     4723font is used for grammar terminals and program identifiers.
    38784724\indexspace
    38794725\input{refrat.ind}
Note: See TracChangeset for help on using the changeset viewer.