Changes in / [ae357ec:bed4c63e]


Ignore:
Files:
11 added
18 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    rae357ec rbed4c63e  
    6262\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
    6363
    64 % index macros
    6564\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
    6665\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     
    134133% adjust listings macros
    135134\lstdefinelanguage{CFA}[ANSI]{C}%
    136 {morekeywords={asm,_Alignas,_Alignof,_At,_Atomic,_Bool,catch,catchResume,choose,_Complex,trait,disable,dtype,enable,
    137         fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,lvalue,_Noreturn,otype,restrict,_Static_assert,
    138         _Thread_local,throw,throwResume,try,},
     135{morekeywords={asm,_Alignas,_Alignof,_At,_Atomic,_Bool,catch,catchResume,choose,_Complex,context,disable,dtype,enable,
     136        fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,lvalue,_Noreturn,restrict,_Static_assert,
     137        _Thread_local,throw,throwResume,try,type,},
    139138}%
    140139
     
    281280An instantiation of the generic type is written by specifying the type parameters in parentheses after the name of the generic type generator:
    282281\begin{lstlisting}
    283 forall( otype T | sumable( T ) ) struct pair {
     282forall( type T | sumable( T ) ) struct pair {
    284283        T x;
    285284        T y;
     
    293292Polymorphic 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:
    294293\begin{lstlisting}
    295 forall( otype T ) void swap( pair(T) *p ) {
     294forall( type T ) void swap( pair(T) *p ) {
    296295        T z = p->x;
    297296        p->x = p->y;
     
    303302\subsubsection{Constraints}
    304303
    305 To avoid unduly constraining implementors, the generic type generator definition must be visible at any point where it is instantiated.
    306 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.
     304To avoid unduly constraining implementors, the generic type generator definition must be visible at any point where it is instantiated.  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.
    307305
    308306\examples
    309307\begin{lstlisting}
    310 forall( otype T ) struct A;
    311 
    312 forall( otype T ) struct B {
     308forall( type T ) struct A;
     309
     310forall( type T ) struct B {
    313311        A(T) *a;                        // legal, but cannot instantiate B(T)
    314312};
     
    316314B(T) x;                                 // illegal, *x.a is of an incomplete generic type
    317315 
    318 forall( otype T ) struct A {
     316forall( type T ) struct A {
    319317        B( T ) *b;
    320318};
     
    323321
    324322// box.h:
    325         forall( otype T ) struct box;
    326         forall( otype T ) box( T ) *make_box( T );
    327         forall( otype T ) void use_box( box( T ) *b );
     323        forall( type T ) struct box;
     324        forall( type T ) box( T ) *make_box( T );
     325        forall( type T ) void use_box( box( T ) *b );
    328326       
    329327// main.c:
     
    412410
    413411\subsubsection{Specialization}
    414 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}.
     412A function or value whose type is polymorphic may be implicitly converted to one whose type is
     413\Index{less polymorphic} by binding values to one or more of its \Index{inferred parameter}.
    415414Any value that is legal for the inferred parameter may be used, including other inferred parameters.
    416415
    417 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.
    418 The assertion parameter is bound to that object or function.
     416If, 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
     417  type} with or can be specialized to the type of the assertion parameter.  The assertion parameter is bound to that object or function.
    419418
    420419The 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.
     
    423422The type
    424423\begin{lstlisting}
    425 forall( otype T, otype U ) void (*)( T, U );
     424forall( type T, type U ) void (*)( T, U );
    426425\end{lstlisting}
    427426can be specialized to (among other things)
    428427\begin{lstlisting}
    429 forall( otype T ) void (*)( T, T );             // U bound to T
    430 forall( otype T ) void (*)( T, real );  // U bound to real
    431 forall( otype U ) void (*)( real, U );  // T bound to real
     428forall( type T ) void (*)( T, T );              // U bound to T
     429forall( type T ) void (*)( T, real );   // U bound to real
     430forall( type U ) void (*)( real, U );   // T bound to real
    432431void f( real, real );                                   // both bound to real
    433432\end{lstlisting}
     
    435434The type
    436435\begin{lstlisting}
    437 forall( otype T | T ?+?( T, T ) ) T (*)( T );
     436forall( type T | T ?+?( T, T ) ) T (*)( T );
    438437\end{lstlisting}
    439438can be specialized to (among other things)
     
    495494If \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:
    496495\lstinline$unsigned short$ to \lstinline$int$ to \lstinline$unsigned$.
    497 Otherwise, \lstinline$unsigned short$ is converted directly to \lstinline$unsigned$, and the cost is 1.
     496Otherwise,
     497\lstinline$unsigned short$ is converted directly to \lstinline$unsigned$, and the cost is 1.
    498498
    499499\item
     
    508508        \rhs \lstinline$forall$
    509509        \rhs \lstinline$lvalue$
    510         \rhs \lstinline$trait$
     510        \rhs \lstinline$context$
    511511        \rhs \lstinline$dtype$
    512512        \rhs \lstinline$ftype$
     
    539539A \nonterm{constant-expression} that evaluates to 0 is effectively compatible with every pointer type.
    540540
    541 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.
     541In 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
     5420 as a special case.
    542543However, 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.
    543544Defining special constants for a user-defined type is more efficient than defining a conversion to the type from \lstinline$_Bool$.
     
    835836\predefined
    836837\begin{lstlisting}
    837 forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
    838 forall( otype T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
    839 forall( otype T ) lvalue const T ?[?]( const T *, ptrdiff_t );
    840 forall( otype T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
    841 forall( otype T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
    842 forall( otype T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
    843 forall( otype T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
    844 forall( otype T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
    845 forall( otype T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
    846 forall( otype T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
    847 forall( otype T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
    848 forall( otype T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
    849 forall( otype T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
    850 forall( otype T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
    851 forall( otype T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
    852 forall( otype T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
     838forall( type T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
     839forall( type T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
     840forall( type T ) lvalue const T ?[?]( const T *, ptrdiff_t );
     841forall( type T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
     842forall( type T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
     843forall( type T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
     844forall( type T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
     845forall( type T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
     846forall( type T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
     847forall( type T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
     848forall( type T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
     849forall( type T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
     850forall( type T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
     851forall( type T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
     852forall( type T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
     853forall( type T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
    853854\end{lstlisting}
    854855\semantics
     
    913914\begin{rationale}
    914915One 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}.
    915 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$.
     916For instance, it should be possible to replace a function ``\lstinline$int f( int );$'' with ``\lstinline$forall( type T ) T f( T );$'' without affecting any calls of \lstinline$f$.
    916917
    917918\CFA\index{deficiencies!generalizability} does not fully possess this property, because
     
    927928f = g( d, f );          // (3) (unsafe conversion to float)
    928929\end{lstlisting}
    929 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
     930If \lstinline$g$ was replaced by ``\lstinline$forall( type T ) T g( T, T );$'', the first and second calls would be unaffected, but the third would change: \lstinline$f$ would be converted to
    930931\lstinline$double$, and the result would be a \lstinline$double$.
    931932
    932933Another example is the function ``\lstinline$void h( int *);$''.
    933934This function can be passed a
    934 \lstinline$void *$ argument, but the generalization ``\lstinline$forall( otype T ) void h( T *);$'' can not.
     935\lstinline$void *$ argument, but the generalization ``\lstinline$forall( type T ) void h( T *);$'' can not.
    935936In this case, \lstinline$void$ is not a valid value for \lstinline$T$ because it is not an object type.
    936937If unsafe conversions were allowed, \lstinline$T$ could be inferred to be \emph{any} object type, which is undesirable.
     
    940941A function called ``\lstinline$?()$'' might be part of a numerical differentiation package.
    941942\begin{lstlisting}
    942 extern otype Derivative;
     943extern type Derivative;
    943944extern double ?()( Derivative, double );
    944945extern Derivative derivative_of( double (*f)( double ) );
     
    961962
    962963\begin{lstlisting}
    963 forall( otype T ) T h( T );
     964forall( type T ) T h( T );
    964965double d = h( 1.5 );
    965966\end{lstlisting}
     
    968969
    969970\begin{lstlisting}
    970 forall( otype T, otype U ) void g( T, U );      // (4)
    971 forall( otype T ) void g( T, T );                       // (5)
    972 forall( otype T ) void g( T, long );                    // (6)
     971forall( type T, type U ) void g( T, U );        // (4)
     972forall( type T ) void g( T, T );                        // (5)
     973forall( type T ) void g( T, long );                     // (6)
    973974void g( long, long );                                           // (7)
    974975double d;
     
    990991The fourth call has no interpretation for (5), because its arguments must have compatible type. (4) is chosen because it does not involve unsafe conversions.
    991992\begin{lstlisting}
    992 forall( otype T ) T min( T, T );
     993forall( type T ) T min( T, T );
    993994double max( double, double );
    994 trait min_max( T ) {@\impl{min_max}@
     995context min_max( T ) {@\impl{min_max}@
    995996        T min( T, T );
    996997        T max( T, T );
    997998}
    998 forall( otype U | min_max( U ) ) void shuffle( U, U );
     999forall( type U | min_max( U ) ) void shuffle( U, U );
    9991000shuffle( 9, 10 );
    10001001\end{lstlisting}
     
    10461047long double ?++( volatile long double * ), ?++( _Atomic volatile long double * );
    10471048
    1048 forall( otype T ) T * ?++( T * restrict volatile * ), * ?++( T * _Atomic restrict volatile * );
    1049 forall( otype T ) _Atomic T * ?++( _Atomic T * restrict volatile * ), * ?++( _Atomic T * _Atomic restrict volatile * );
    1050 forall( otype T ) const T * ?++( const T * restrict volatile * ), * ?++( const T * _Atomic restrict volatile * );
    1051 forall( otype T ) volatile T * ?++( volatile T * restrict volatile * ), * ?++( volatile T * _Atomic restrict volatile * );
    1052 forall( otype T ) restrict T * ?++( restrict T * restrict volatile * ), * ?++( restrict T * _Atomic restrict volatile * );
    1053 forall( otype T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
     1049forall( type T ) T * ?++( T * restrict volatile * ), * ?++( T * _Atomic restrict volatile * );
     1050forall( type T ) _Atomic T * ?++( _Atomic T * restrict volatile * ), * ?++( _Atomic T * _Atomic restrict volatile * );
     1051forall( type T ) const T * ?++( const T * restrict volatile * ), * ?++( const T * _Atomic restrict volatile * );
     1052forall( type T ) volatile T * ?++( volatile T * restrict volatile * ), * ?++( volatile T * _Atomic restrict volatile * );
     1053forall( type T ) restrict T * ?++( restrict T * restrict volatile * ), * ?++( restrict T * _Atomic restrict volatile * );
     1054forall( type T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
    10541055        * ?++( _Atomic const T * _Atomic restrict volatile * );
    1055 forall( otype T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
     1056forall( type T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
    10561057        * ?++( _Atomic restrict T * _Atomic restrict volatile * );
    1057 forall( otype T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
     1058forall( type T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
    10581059        * ?++( _Atomic volatile T * _Atomic restrict volatile * );
    1059 forall( otype T ) const restrict T * ?++( const restrict T * restrict volatile * ),
     1060forall( type T ) const restrict T * ?++( const restrict T * restrict volatile * ),
    10601061        * ?++( const restrict T * _Atomic restrict volatile * );
    1061 forall( otype T ) const volatile T * ?++( const volatile T * restrict volatile * ),
     1062forall( type T ) const volatile T * ?++( const volatile T * restrict volatile * ),
    10621063        * ?++( const volatile T * _Atomic restrict volatile * );
    1063 forall( otype T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
     1064forall( type T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
    10641065        * ?++( restrict volatile T * _Atomic restrict volatile * );
    1065 forall( otype T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
     1066forall( type T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
    10661067        * ?++( _Atomic const restrict T * _Atomic restrict volatile * );
    1067 forall( otype T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
     1068forall( type T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
    10681069        * ?++( _Atomic const volatile T * _Atomic restrict volatile * );
    1069 forall( otype T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
     1070forall( type T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
    10701071        * ?++( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1071 forall( otype T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
     1072forall( type T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
    10721073        * ?++( const restrict volatile T * _Atomic restrict volatile * );
    1073 forall( otype T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
     1074forall( type T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
    10741075        * ?++( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    10751076
     
    10901091long double ?--( volatile long double * ), ?--( _Atomic volatile long double * );
    10911092
    1092 forall( otype T ) T * ?--( T * restrict volatile * ), * ?--( T * _Atomic restrict volatile * );
    1093 forall( otype T ) _Atomic T * ?--( _Atomic T * restrict volatile * ), * ?--( _Atomic T * _Atomic restrict volatile * );
    1094 forall( otype T ) const T * ?--( const T * restrict volatile * ), * ?--( const T * _Atomic restrict volatile * );
    1095 forall( otype T ) volatile T * ?--( volatile T * restrict volatile * ), * ?--( volatile T * _Atomic restrict volatile * );
    1096 forall( otype T ) restrict T * ?--( restrict T * restrict volatile * ), * ?--( restrict T * _Atomic restrict volatile * );
    1097 forall( otype T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
     1093forall( type T ) T * ?--( T * restrict volatile * ), * ?--( T * _Atomic restrict volatile * );
     1094forall( type T ) _Atomic T * ?--( _Atomic T * restrict volatile * ), * ?--( _Atomic T * _Atomic restrict volatile * );
     1095forall( type T ) const T * ?--( const T * restrict volatile * ), * ?--( const T * _Atomic restrict volatile * );
     1096forall( type T ) volatile T * ?--( volatile T * restrict volatile * ), * ?--( volatile T * _Atomic restrict volatile * );
     1097forall( type T ) restrict T * ?--( restrict T * restrict volatile * ), * ?--( restrict T * _Atomic restrict volatile * );
     1098forall( type T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
    10981099        * ?--( _Atomic const T * _Atomic restrict volatile * );
    1099 forall( otype T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
     1100forall( type T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
    11001101        * ?--( _Atomic restrict T * _Atomic restrict volatile * );
    1101 forall( otype T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
     1102forall( type T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
    11021103        * ?--( _Atomic volatile T * _Atomic restrict volatile * );
    1103 forall( otype T ) const restrict T * ?--( const restrict T * restrict volatile * ),
     1104forall( type T ) const restrict T * ?--( const restrict T * restrict volatile * ),
    11041105        * ?--( const restrict T * _Atomic restrict volatile * );
    1105 forall( otype T ) const volatile T * ?--( const volatile T * restrict volatile * ),
     1106forall( type T ) const volatile T * ?--( const volatile T * restrict volatile * ),
    11061107        * ?--( const volatile T * _Atomic restrict volatile * );
    1107 forall( otype T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
     1108forall( type T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
    11081109        * ?--( restrict volatile T * _Atomic restrict volatile * );
    1109 forall( otype T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
     1110forall( type T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
    11101111        * ?--( _Atomic const restrict T * _Atomic restrict volatile * );
    1111 forall( otype T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
     1112forall( type T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
    11121113        * ?--( _Atomic const volatile T * _Atomic restrict volatile * );
    1113 forall( otype T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
     1114forall( type T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
    11141115        * ?--( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1115 forall( otype T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
     1116forall( type T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
    11161117        * ?--( const restrict volatile T * _Atomic restrict volatile * );
    1117 forall( otype T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
     1118forall( type T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
    11181119        * ?--( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    11191120\end{lstlisting}
     
    11941195The expression would be valid if \lstinline$?++$ were declared by
    11951196\begin{lstlisting}
    1196 forall( otype T ) T * ?++( T * * );
     1197forall( type T ) T * ?++( T * * );
    11971198\end{lstlisting} with \lstinline$T$ inferred to be \lstinline$char$.
    11981199
     
    12021203Hence the actual predefined function is
    12031204\begin{lstlisting}
    1204 forall( otype T ) T * ?++( T * restrict volatile * );
     1205forall( type T ) T * ?++( T * restrict volatile * );
    12051206\end{lstlisting} which also accepts a \lstinline$char * *$ argument, because of the safe conversions that add
    12061207\lstinline$volatile$ and \lstinline$restrict$ qualifiers. (The parameter is not const-qualified, so constant pointers cannot be incremented.)
     
    12161217\lstinline$char const volatile *$, so a new overloading is needed:
    12171218\begin{lstlisting}
    1218 forall( otype T ) T const volatile * ?++( T const volatile *restrict volatile * );
     1219forall( type T ) T const volatile * ?++( T const volatile *restrict volatile * );
    12191220\end{lstlisting}
    12201221One overloading is needed for each combination of qualifiers in the pointed-at type\index{deficiencies!pointers to qualified types}.
     
    12241225The \lstinline$restrict$ qualifier is handled just like \lstinline$const$ and \lstinline$volatile$ in the previous case:
    12251226\begin{lstlisting}
    1226 forall( otype T ) T restrict * ?++( T restrict *restrict volatile * );
     1227forall( type T ) T restrict * ?++( T restrict *restrict volatile * );
    12271228\end{lstlisting} with \lstinline$T$ inferred to be \lstinline$float *$.
    12281229This 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.
     
    12821283long double ++?( volatile long double * ), ++?( _Atomic volatile long double * );
    12831284
    1284 forall( otype T ) T * ++?( T * restrict volatile * ), * ++?( T * _Atomic restrict volatile * );
    1285 forall( otype T ) _Atomic T * ++?( _Atomic T * restrict volatile * ), * ++?( _Atomic T * _Atomic restrict volatile * );
    1286 forall( otype T ) const T * ++?( const T * restrict volatile * ), * ++?( const T * _Atomic restrict volatile * );
    1287 forall( otype T ) volatile T * ++?( volatile T * restrict volatile * ), * ++?( volatile T * _Atomic restrict volatile * );
    1288 forall( otype T ) restrict T * ++?( restrict T * restrict volatile * ), * ++?( restrict T * _Atomic restrict volatile * );
    1289 forall( otype T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
     1285forall( type T ) T * ++?( T * restrict volatile * ), * ++?( T * _Atomic restrict volatile * );
     1286forall( type T ) _Atomic T * ++?( _Atomic T * restrict volatile * ), * ++?( _Atomic T * _Atomic restrict volatile * );
     1287forall( type T ) const T * ++?( const T * restrict volatile * ), * ++?( const T * _Atomic restrict volatile * );
     1288forall( type T ) volatile T * ++?( volatile T * restrict volatile * ), * ++?( volatile T * _Atomic restrict volatile * );
     1289forall( type T ) restrict T * ++?( restrict T * restrict volatile * ), * ++?( restrict T * _Atomic restrict volatile * );
     1290forall( type T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
    12901291        * ++?( _Atomic const T * _Atomic restrict volatile * );
    1291 forall( otype T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
     1292forall( type T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
    12921293        * ++?( _Atomic volatile T * _Atomic restrict volatile * );
    1293 forall( otype T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
     1294forall( type T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
    12941295        * ++?( _Atomic restrict T * _Atomic restrict volatile * );
    1295 forall( otype T ) const volatile T * ++?( const volatile T * restrict volatile * ),
     1296forall( type T ) const volatile T * ++?( const volatile T * restrict volatile * ),
    12961297        * ++?( const volatile T * _Atomic restrict volatile * );
    1297 forall( otype T ) const restrict T * ++?( const restrict T * restrict volatile * ),
     1298forall( type T ) const restrict T * ++?( const restrict T * restrict volatile * ),
    12981299        * ++?( const restrict T * _Atomic restrict volatile * );
    1299 forall( otype T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
     1300forall( type T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
    13001301        * ++?( restrict volatile T * _Atomic restrict volatile * );
    1301 forall( otype T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
     1302forall( type T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
    13021303        * ++?( _Atomic const volatile T * _Atomic restrict volatile * );
    1303 forall( otype T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
     1304forall( type T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
    13041305        * ++?( _Atomic const restrict T * _Atomic restrict volatile * );
    1305 forall( otype T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
     1306forall( type T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
    13061307        * ++?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1307 forall( otype T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
     1308forall( type T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
    13081309        * ++?( const restrict volatile T * _Atomic restrict volatile * );
    1309 forall( otype T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
     1310forall( type T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
    13101311        * ++?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    13111312
     
    13261327long double --?( volatile long double * ), --?( _Atomic volatile long double * );
    13271328
    1328 forall( otype T ) T * --?( T * restrict volatile * ), * --?( T * _Atomic restrict volatile * );
    1329 forall( otype T ) _Atomic T * --?( _Atomic T * restrict volatile * ), * --?( _Atomic T * _Atomic restrict volatile * );
    1330 forall( otype T ) const T * --?( const T * restrict volatile * ), * --?( const T * _Atomic restrict volatile * );
    1331 forall( otype T ) volatile T * --?( volatile T * restrict volatile * ), * --?( volatile T * _Atomic restrict volatile * );
    1332 forall( otype T ) restrict T * --?( restrict T * restrict volatile * ), * --?( restrict T * _Atomic restrict volatile * );
    1333 forall( otype T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
     1329forall( type T ) T * --?( T * restrict volatile * ), * --?( T * _Atomic restrict volatile * );
     1330forall( type T ) _Atomic T * --?( _Atomic T * restrict volatile * ), * --?( _Atomic T * _Atomic restrict volatile * );
     1331forall( type T ) const T * --?( const T * restrict volatile * ), * --?( const T * _Atomic restrict volatile * );
     1332forall( type T ) volatile T * --?( volatile T * restrict volatile * ), * --?( volatile T * _Atomic restrict volatile * );
     1333forall( type T ) restrict T * --?( restrict T * restrict volatile * ), * --?( restrict T * _Atomic restrict volatile * );
     1334forall( type T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
    13341335        * --?( _Atomic const T * _Atomic restrict volatile * );
    1335 forall( otype T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
     1336forall( type T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
    13361337        * --?( _Atomic volatile T * _Atomic restrict volatile * );
    1337 forall( otype T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
     1338forall( type T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
    13381339        * --?( _Atomic restrict T * _Atomic restrict volatile * );
    1339 forall( otype T ) const volatile T * --?( const volatile T * restrict volatile * ),
     1340forall( type T ) const volatile T * --?( const volatile T * restrict volatile * ),
    13401341        * --?( const volatile T * _Atomic restrict volatile * );
    1341 forall( otype T ) const restrict T * --?( const restrict T * restrict volatile * ),
     1342forall( type T ) const restrict T * --?( const restrict T * restrict volatile * ),
    13421343        * --?( const restrict T * _Atomic restrict volatile * );
    1343 forall( otype T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
     1344forall( type T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
    13441345        * --?( restrict volatile T * _Atomic restrict volatile * );
    1345 forall( otype T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
     1346forall( type T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
    13461347        * --?( _Atomic const volatile T * _Atomic restrict volatile * );
    1347 forall( otype T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
     1348forall( type T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
    13481349        * --?( _Atomic const restrict T * _Atomic restrict volatile * );
    1349 forall( otype T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
     1350forall( type T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
    13501351        * --?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1351 forall( otype T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
     1352forall( type T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
    13521353        * --?( const restrict volatile T * _Atomic restrict volatile * );
    1353 forall( otype T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
     1354forall( type T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
    13541355        * --?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    13551356\end{lstlisting}
     
    13791380\predefined
    13801381\begin{lstlisting}
    1381 forall( otype T ) lvalue T *?( T * );
    1382 forall( otype T ) _Atomic lvalue T *?( _Atomic T * );
    1383 forall( otype T ) const lvalue T *?( const T * );
    1384 forall( otype T ) volatile lvalue T *?( volatile T * );
    1385 forall( otype T ) restrict lvalue T *?( restrict T * );
    1386 forall( otype T ) _Atomic const lvalue T *?( _Atomic const T * );
    1387 forall( otype T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
    1388 forall( otype T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
    1389 forall( otype T ) const volatile lvalue T *?( const volatile T * );
    1390 forall( otype T ) const restrict lvalue T *?( const restrict T * );
    1391 forall( otype T ) restrict volatile lvalue T *?( restrict volatile T * );
    1392 forall( otype T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
    1393 forall( otype T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
    1394 forall( otype T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
    1395 forall( otype T ) const restrict volatile lvalue T *?( const restrict volatile T * );
    1396 forall( otype T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
     1382forall( type T ) lvalue T *?( T * );
     1383forall( type T ) _Atomic lvalue T *?( _Atomic T * );
     1384forall( type T ) const lvalue T *?( const T * );
     1385forall( type T ) volatile lvalue T *?( volatile T * );
     1386forall( type T ) restrict lvalue T *?( restrict T * );
     1387forall( type T ) _Atomic const lvalue T *?( _Atomic const T * );
     1388forall( type T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
     1389forall( type T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
     1390forall( type T ) const volatile lvalue T *?( const volatile T * );
     1391forall( type T ) const restrict lvalue T *?( const restrict T * );
     1392forall( type T ) restrict volatile lvalue T *?( restrict volatile T * );
     1393forall( type T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
     1394forall( type T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
     1395forall( type T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
     1396forall( type T ) const restrict volatile lvalue T *?( const restrict volatile T * );
     1397forall( type T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
    13971398forall( ftype FT ) FT *?( FT * );
    13981399\end{lstlisting}
     
    15091510\begin{rationale}
    15101511\begin{lstlisting}
    1511 otype Pair = struct { int first, second; };
     1512type Pair = struct { int first, second; };
    15121513size_t p_size = sizeof(Pair);           // constant expression
    1513 extern otype Rational;@\use{Rational}@
     1514extern type Rational;@\use{Rational}@
    15141515size_t c_size = sizeof(Rational);       // non-constant expression
    15151516forall(type T) T f(T p1, T p2) {
     
    16351636Consider
    16361637\begin{lstlisting}
    1637 forall( otype T | T ?*?( T, T ) ) T square( T );
     1638forall( type T | T ?*?( T, T ) ) T square( T );
    16381639short s;
    16391640square( s );
     
    16461647A more troubling example is
    16471648\begin{lstlisting}
    1648 forall( otype T | ?*?( T, T ) ) T product( T[], int n );
     1649forall( type T | ?*?( T, T ) ) T product( T[], int n );
    16491650short sa[5];
    16501651product( sa, 5);
     
    17031704        ?+?( _Complex long double, _Complex long double ), ?-?( _Complex long double, _Complex long double );
    17041705
    1705 forall( otype T ) T * ?+?( T *, ptrdiff_t ), * ?+?( ptrdiff_t, T * ), * ?-?( T *, ptrdiff_t );
    1706 forall( otype T ) _Atomic T * ?+?( _Atomic T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic T * ),
     1706forall( type T ) T * ?+?( T *, ptrdiff_t ), * ?+?( ptrdiff_t, T * ), * ?-?( T *, ptrdiff_t );
     1707forall( type T ) _Atomic T * ?+?( _Atomic T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic T * ),
    17071708        * ?-?( _Atomic T *, ptrdiff_t );
    1708 forall( otype T ) const T * ?+?( const T *, ptrdiff_t ), * ?+?( ptrdiff_t, const T * ),
     1709forall( type T ) const T * ?+?( const T *, ptrdiff_t ), * ?+?( ptrdiff_t, const T * ),
    17091710        * ?-?( const T *, ptrdiff_t );
    1710 forall( otype T ) restrict T * ?+?( restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict T * ),
     1711forall( type T ) restrict T * ?+?( restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict T * ),
    17111712        * ?-?( restrict T *, ptrdiff_t );
    1712 forall( otype T ) volatile T * ?+?( volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, volatile T * ),
     1713forall( type T ) volatile T * ?+?( volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, volatile T * ),
    17131714        * ?-?( volatile T *, ptrdiff_t );
    1714 forall( otype T ) _Atomic const T * ?+?( _Atomic const T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic const T * ),
     1715forall( type T ) _Atomic const T * ?+?( _Atomic const T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic const T * ),
    17151716        * ?-?( _Atomic const T *, ptrdiff_t );
    1716 forall( otype T ) _Atomic restrict T * ?+?( _Atomic restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic restrict T * ),
     1717forall( type T ) _Atomic restrict T * ?+?( _Atomic restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic restrict T * ),
    17171718        * ?-?( _Atomic restrict T *, ptrdiff_t );
    1718 forall( otype T ) _Atomic volatile T * ?+?( _Atomic volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic volatile T * ),
     1719forall( type T ) _Atomic volatile T * ?+?( _Atomic volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic volatile T * ),
    17191720        * ?-?( _Atomic volatile T *, ptrdiff_t );
    1720 forall( otype T ) const restrict T * ?+?( const restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, const restrict T * ),
     1721forall( type T ) const restrict T * ?+?( const restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, const restrict T * ),
    17211722        * ?-?( const restrict T *, ptrdiff_t );
    1722 forall( otype T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, const volatile T * ),
     1723forall( type T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, const volatile T * ),
    17231724        * ?-?( const volatile T *, ptrdiff_t );
    1724 forall( otype T ) restrict volatile T * ?+?( restrict volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict volatile T * ),
     1725forall( type T ) restrict volatile T * ?+?( restrict volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict volatile T * ),
    17251726        * ?-?( restrict volatile T *, ptrdiff_t );
    1726 forall( otype T ) _Atomic const restrict T * ?+?( _Atomic const restrict T *, ptrdiff_t ),
     1727forall( type T ) _Atomic const restrict T * ?+?( _Atomic const restrict T *, ptrdiff_t ),
    17271728        * ?+?( ptrdiff_t, _Atomic const restrict T * ),
    17281729        * ?-?( _Atomic const restrict T *, ptrdiff_t );
    1729 forall( otype T ) ptrdiff_t
     1730forall( type T ) ptrdiff_t
    17301731        * ?-?( const restrict volatile T *, const restrict volatile T * ),
    17311732        * ?-?( _Atomic const restrict volatile T *, _Atomic const restrict volatile T * );
     
    20512052
    20522053\begin{lstlisting}
    2053 extern otype Rational;@\use{Rational}@
     2054extern type Rational;@\use{Rational}@
    20542055extern const Rational 0;@\use{0}@
    20552056extern int ?!=?( Rational, Rational );
     
    20942095If 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
    20952096\begin{lstlisting}
    2096 forall( otype T ) T cond( int, T, T );
     2097forall( type T ) T cond( int, T, T );
    20972098forall( dtype D ) void * cond( int, D *, void * ), * cond( int, void *, D * );
    20982099forall( dtype D ) _atomic void * cond(
     
    24542455\predefined
    24552456\begin{lstlisting}
    2456 forall( otype T ) T
     2457forall( type T ) T
    24572458        * ?+=?( T * restrict volatile *, ptrdiff_t ),
    24582459        * ?-=?( T * restrict volatile *, ptrdiff_t ),
    24592460        * ?+=?( T * _Atomic restrict volatile *, ptrdiff_t ),
    24602461        * ?-=?( T * _Atomic restrict volatile *, ptrdiff_t );
    2461 forall( otype T ) T _Atomic
     2462forall( type T ) T _Atomic
    24622463        * ?+=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    24632464        * ?-=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    24642465        * ?+=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t ),
    24652466        * ?-=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t );
    2466 forall( otype T ) T const
     2467forall( type T ) T const
    24672468        * ?+=?( T const * restrict volatile *, ptrdiff_t ),
    24682469        * ?-=?( T const * restrict volatile *, ptrdiff_t ),
    24692470        * ?+=?( T const * _Atomic restrict volatile *, ptrdiff_t ),
    24702471        * ?-=?( T const * _Atomic restrict volatile *, ptrdiff_t );
    2471 forall( otype T ) T restrict
     2472forall( type T ) T restrict
    24722473        * ?+=?( T restrict * restrict volatile *, ptrdiff_t ),
    24732474        * ?-=?( T restrict * restrict volatile *, ptrdiff_t ),
    24742475        * ?+=?( T restrict * _Atomic restrict volatile *, ptrdiff_t ),
    24752476        * ?-=?( T restrict * _Atomic restrict volatile *, ptrdiff_t );
    2476 forall( otype T ) T volatile
     2477forall( type T ) T volatile
    24772478        * ?+=?( T volatile * restrict volatile *, ptrdiff_t ),
    24782479        * ?-=?( T volatile * restrict volatile *, ptrdiff_t ),
    24792480        * ?+=?( T volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24802481        * ?-=?( T volatile * _Atomic restrict volatile *, ptrdiff_t );
    2481 forall( otype T ) T _Atomic const
     2482forall( type T ) T _Atomic const
    24822483        * ?+=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    24832484        * ?-=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    24842485        * ?+=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t ),
    24852486        * ?-=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t );
    2486 forall( otype T ) T _Atomic restrict
     2487forall( type T ) T _Atomic restrict
    24872488        * ?+=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    24882489        * ?-=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    24892490        * ?+=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t ),
    24902491        * ?-=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t );
    2491 forall( otype T ) T _Atomic volatile
     2492forall( type T ) T _Atomic volatile
    24922493        * ?+=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    24932494        * ?-=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    24942495        * ?+=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24952496        * ?-=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t );
    2496 forall( otype T ) T const restrict
     2497forall( type T ) T const restrict
    24972498        * ?+=?( T const restrict * restrict volatile *, ptrdiff_t ),
    24982499        * ?-=?( T const restrict * restrict volatile *, ptrdiff_t ),
    24992500        * ?+=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    25002501        * ?-=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2501 forall( otype T ) T const volatile
     2502forall( type T ) T const volatile
    25022503        * ?+=?( T const volatile * restrict volatile *, ptrdiff_t ),
    25032504        * ?-=?( T const volatile * restrict volatile *, ptrdiff_t ),
    25042505        * ?+=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25052506        * ?-=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2506 forall( otype T ) T restrict volatile
     2507forall( type T ) T restrict volatile
    25072508        * ?+=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    25082509        * ?-=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    25092510        * ?+=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25102511        * ?-=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2511 forall( otype T ) T _Atomic const restrict
     2512forall( type T ) T _Atomic const restrict
    25122513        * ?+=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    25132514        * ?-=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    25142515        * ?+=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    25152516        * ?-=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2516 forall( otype T ) T _Atomic const volatile
     2517forall( type T ) T _Atomic const volatile
    25172518        * ?+=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    25182519        * ?-=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    25192520        * ?+=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25202521        * ?-=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2521 forall( otype T ) T _Atomic restrict volatile
     2522forall( type T ) T _Atomic restrict volatile
    25222523        * ?+=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    25232524        * ?-=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    25242525        * ?+=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25252526        * ?-=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2526 forall( otype T ) T const restrict volatile
     2527forall( type T ) T const restrict volatile
    25272528        * ?+=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    25282529        * ?-=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    25292530        * ?+=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25302531        * ?-=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2531 forall( otype T ) T _Atomic const restrict volatile
     2532forall( type T ) T _Atomic const restrict volatile
    25322533        * ?+=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
    25332534        * ?-=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
     
    28412842This 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.
    28422843\begin{lstlisting}
    2843 forall( otype T ) struct Pair { T a, b;
     2844forall( type T ) struct Pair { T a, b;
    28442845} mkPair( T, T ); // illegal
    28452846\end{lstlisting}
     
    28662867If this restriction were lifted, it would be possible to write
    28672868\begin{lstlisting}
    2868 forall( otype T ) T * alloc( void );@\use{alloc}@ int *p = alloc();
     2869forall( type T ) T * alloc( void );@\use{alloc}@ int *p = alloc();
    28692870\end{lstlisting}
    28702871Here \lstinline$alloc()$ would receive \lstinline$int$ as an inferred argument, and return an
     
    28752876\lstinline$T$:
    28762877\begin{lstlisting}
    2877 forall( otype T ) T * alloc( T initial_value );@\use{alloc}@
     2878forall( type T ) T * alloc( T initial_value );@\use{alloc}@
    28782879\end{lstlisting}
    28792880\end{rationale}
     
    28982899\begin{lstlisting}
    28992900int fi( int );
    2900 forall( otype T ) T fT( T );
     2901forall( type T ) T fT( T );
    29012902\end{lstlisting}
    29022903\lstinline$fi()$ takes an \lstinline$int$ and returns an \lstinline$int$. \lstinline$fT()$ takes a
     
    29042905\begin{lstlisting}
    29052906int (*pfi )( int ) = fi;
    2906 forall( otype T ) T (*pfT )( T ) = fT;
     2907forall( type T ) T (*pfT )( T ) = fT;
    29072908\end{lstlisting}
    29082909\lstinline$pfi$ and \lstinline$pfT$ are pointers to functions. \lstinline$pfT$ is not polymorphic, but the function it points at is.
     
    29112912        return pfi;
    29122913}
    2913 forall( otype T ) T (*fvpfT( void ))( T ) {
     2914forall( type T ) T (*fvpfT( void ))( T ) {
    29142915        return pfT;
    29152916}
     
    29172918\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.
    29182919\begin{lstlisting}
    2919 forall( otype T ) int ( *fTpfi( T ) )( int );
    2920 forall( otype T ) T ( *fTpfT( T ) )( T );
    2921 forall( otype T, otype U ) U ( *fTpfU( T ) )( U );
     2920forall( type T ) int ( *fTpfi( T ) )( int );
     2921forall( type T ) T ( *fTpfT( T ) )( T );
     2922forall( type T, type U ) U ( *fTpfU( T ) )( U );
    29222923\end{lstlisting}
    29232924\lstinline$fTpfi()$ is a polymorphic function that returns a pointer to a monomorphic function taking an integer and returning an integer.
     
    29292930\lstinline$char *$.
    29302931\begin{lstlisting}
    2931 forall( otype T, otype U, otype V ) U * f( T *, U, V * const );
    2932 forall( otype U, otype V, otype W ) U * g( V *, U, W * const );
     2932forall( type T, type U, type V ) U * f( T *, U, V * const );
     2933forall( type U, type V, type W ) U * g( V *, U, W * const );
    29332934\end{lstlisting}
    29342935The functions \lstinline$f()$ and \lstinline$g()$ have compatible types.
     
    29382939Replacing every \(f_i\) by \(g_i\) in \(f\) gives
    29392940\begin{lstlisting}
    2940 forall( otype V, otype U, otype W ) U * f( V *, U, W * const );
     2941forall( type V, type U, type W ) U * f( V *, U, W * const );
    29412942\end{lstlisting} which has a return type and parameter list that is compatible with \(g\).
    29422943\begin{rationale}
     
    31263127\examples
    31273128\begin{lstlisting}
    3128 forall( otype T | T ?*?( T, T ))@\use{?*?}@
     3129forall( type T | T ?*?( T, T ))@\use{?*?}@
    31293130T square( T val ) {@\impl{square}@
    31303131        return val + val;
    31313132}
    3132 trait summable( otype T ) {@\impl{summable}@
     3133context summable( type T ) {@\impl{summable}@
    31333134        T ?+=?( T *, T );@\use{?+=?}@
    31343135        const T 0;@\use{0}@
    31353136};
    3136 trait list_of( otype List, otype Element ) {@\impl{list_of}@
     3137context list_of( type List, type Element ) {@\impl{list_of}@
    31373138        Element car( List );
    31383139        List cdr( List );
     
    31413142        int is_nil( List );
    31423143};
    3143 trait sum_list( otype List, otype Element | summable( Element ) | list_of( List, Element ) ) {};
     3144context sum_list( type List, type Element | summable( Element ) | list_of( List, Element ) ) {};
    31443145\end{lstlisting}
    31453146\lstinline$sum_list$ contains seven declarations, which describe a list whose elements can be added up.
     
    32033204Incomplete type declarations allow compact mutually-recursive types.
    32043205\begin{lstlisting}
    3205 otype t1; // incomplete type declaration
    3206 otype t2 = struct { t1 * p; ... };
    3207 otype t1 = struct { t2 * p; ... };
     3206type t1; // incomplete type declaration
     3207type t2 = struct { t1 * p; ... };
     3208type t1 = struct { t2 * p; ... };
    32083209\end{lstlisting}
    32093210Without them, mutual recursion could be handled by declaring mutually recursive structures, then initializing the types to those structures.
    32103211\begin{lstlisting}
    32113212struct s1;
    3212 otype t2 = struct s2 { struct s1 * p; ... };
    3213 otype t1 = struct s1 { struct s2 * p; ... };
     3213type t2 = struct s2 { struct s1 * p; ... };
     3214type t1 = struct s1 { struct s2 * p; ... };
    32143215\end{lstlisting}
    32153216This introduces extra names, and may force the programmer to cast between the types and their implementations.
     
    32663267This prevents the declaration of types that contain each other.
    32673268\begin{lstlisting}
    3268 otype t1;
    3269 otype t2 = t1; // illegal: incomplete type t1
    3270 otype t1 = t2;
     3269type t1;
     3270type t2 = t1; // illegal: incomplete type t1
     3271type t1 = t2;
    32713272\end{lstlisting}
    32723273
     
    32753276 types}.
    32763277\begin{lstlisting}
    3277 extern otype Huge; // extended-precision integer type
    3278 otype Rational = struct {
     3278extern type Huge; // extended-precision integer type
     3279type Rational = struct {
    32793280        Huge numerator, denominator;    // illegal
    32803281};
     
    33153316\begin{lstlisting}
    33163317#include <stdlib.h>
    3317 T * new( otype T ) { return ( T * )malloc( sizeof( T) ); };
     3318T * new( type T ) { return ( T * )malloc( sizeof( T) ); };
    33183319@\ldots@ int * ip = new( int );
    33193320\end{lstlisting}
     
    33263327Since type declarations create new types, instances of types are always passed by value.
    33273328\begin{lstlisting}
    3328 otype A1 = int[2];
     3329type A1 = int[2];
    33293330void f1( A1 a ) { a[0] = 0; };
    3330 otypedef int A2[2];
     3331typedef int A2[2];
    33313332void f2( A2 a ) { a[0] = 0; };
    33323333A1 v1;
     
    33453346That unit might contain the declarations
    33463347\begin{lstlisting}
    3347 otype Complex = struct { float re, im; };@\impl{Complex}@
     3348type Complex = struct { float re, im; };@\impl{Complex}@
    33483349Complex cplx_i = { 0.0, 1.0 };@\impl{cplx_i}@
    33493350float abs( Complex c ) {@\impl{abs( Complex )}@
     
    33543355
    33553356\begin{lstlisting}
    3356 otype Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
     3357type Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
    33573358Time_of_day ?+?( Time_of_day t1, int seconds ) {@\impl{?+?}@
    33583359        return (( int)t1 + seconds ) % 86400;
     
    34283429\examples
    34293430\begin{lstlisting}
    3430 trait s( otype T ) {
     3431context s( type T ) {
    34313432        T a, b;
    34323433} struct impl { int left, right; } a = { 0, 0 };
    3433 otype Pair | s( Pair ) = struct impl;
     3434type Pair | s( Pair ) = struct impl;
    34343435Pair b = { 1, 1 };
    34353436\end{lstlisting}
     
    34393440\lstinline$Pair b$ is compulsory because there is no \lstinline$struct impl b$ to construct a value from.
    34403441\begin{lstlisting}
    3441 trait ss( otype T ) {
     3442context ss( type T ) {
    34423443        T clone( T );
    34433444        void munge( T * );
    34443445}
    3445 otype Whatsit | ss( Whatsit );@\use{Whatsit}@
    3446 otype Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
     3446type Whatsit | ss( Whatsit );@\use{Whatsit}@
     3447type Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
    34473448        Whatsit; // anonymous member
    34483449        int extra;
     
    34653466Default functions and objects are subject to the normal scope rules.
    34663467\begin{lstlisting}
    3467 otype T = @\ldots@;
     3468type T = @\ldots@;
    34683469T a_T = @\ldots@;               // Default assignment used.
    34693470T ?=?( T *, T );
     
    37343735The assertion ``\lstinline$scalar( Complex )$'' should be read as ``type \lstinline$Complex$ is scalar''.
    37353736\begin{lstlisting}
    3736 trait scalar( otype T ) {@\impl{scalar}@
     3737context scalar( type T ) {@\impl{scalar}@
    37373738        int !?( T );
    37383739        int ?<?( T, T ), ?<=?( T, T ), ?==?( T, T ), ?>=?( T, T ), ?>?( T, T ), ?!=?( T, T );
     
    37443745This is equivalent to inheritance of specifications.
    37453746\begin{lstlisting}
    3746 trait arithmetic( otype T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
     3747context arithmetic( type T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
    37473748        T +?( T ), -?( T );
    37483749        T ?*?( T, T ), ?/?( T, T ), ?+?( T, T ), ?-?( T, T );
     
    37533754\define{integral types}.
    37543755\begin{lstlisting}
    3755 trait integral( otype T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
     3756context integral( type T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
    37563757        T ~?( T );
    37573758        T ?&?( T, T ), ?|?( T, T ), ?^?( T, T );
     
    37673768The only operation that can be applied to all modifiable lvalues is simple assignment.
    37683769\begin{lstlisting}
    3769 trait m_lvalue( otype T ) {@\impl{m_lvalue}@
     3770context m_lvalue( type T ) {@\impl{m_lvalue}@
    37703771        T ?=?( T *, T );
    37713772};
     
    37773778Scalars can also be incremented and decremented.
    37783779\begin{lstlisting}
    3779 trait m_l_scalar( otype T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
     3780context m_l_scalar( type T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
    37803781        T ?++( T * ), ?--( T * );@\use{scalar}@@\use{m_lvalue}@
    37813782        T ++?( T * ), --?( T * );
     
    37863787Note that this results in the ``inheritance'' of \lstinline$scalar$ along both paths.
    37873788\begin{lstlisting}
    3788 trait m_l_arithmetic( otype T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
     3789context m_l_arithmetic( type T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
    37893790        T ?/=?( T *, T ), ?*=?( T *, T );@\use{m_l_scalar}@@\use{arithmetic}@
    37903791        T ?+=?( T *, T ), ?-=?( T *, T );
    37913792};
    3792 trait m_l_integral( otype T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
     3793context m_l_integral( type T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
    37933794        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );@\use{m_l_arithmetic}@
    37943795        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );@\use{integral}@
     
    38103811\lstinline$arithmetic$, so these operators cannot be consolidated in \lstinline$scalar$.
    38113812\begin{lstlisting}
    3812 trait pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
     3813context pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
    38133814        P ?+?( P, long int ), ?+?( long int, P ), ?-?( P, long int );
    38143815        ptrdiff_t ?-?( P, P );
    38153816};
    3816 trait m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
     3817context m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
    38173818        P ?+=?( P *, long int ), ?-=?( P *, long int );
    38183819        P ?=?( P *, void * );
     
    38263827``\lstinline$Safe_pointer$ acts like a pointer to \lstinline$int$''.
    38273828\begin{lstlisting}
    3828 trait ptr_to( type P | pointer( P ), otype T ) {@\impl{ptr_to}@@\use{pointer}@
     3829context ptr_to( type P | pointer( P ), type T ) {@\impl{ptr_to}@@\use{pointer}@
    38293830        lvalue T *?( P );
    38303831        lvalue T ?[?]( P, long int );
    38313832};
    3832 trait ptr_to_const( type P | pointer( P ), otype T ) {@\impl{ptr_to_const}@
     3833context ptr_to_const( type P | pointer( P ), type T ) {@\impl{ptr_to_const}@
    38333834        const lvalue T *?( P );
    38343835        const lvalue T ?[?]( P, long int );@\use{pointer}@
    38353836};
    3836 trait ptr_to_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_volatile}@
     3837context ptr_to_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_volatile}@
    38373838        volatile lvalue T *?( P );
    38383839        volatile lvalue T ?[?]( P, long int );@\use{pointer}@
    38393840};
    3840 trait ptr_to_const_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_const_volatile}@
     3841context ptr_to_const_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_const_volatile}@
    38413842        const volatile lvalue T *?( P );@\use{pointer}@
    38423843        const volatile lvalue T ?[?]( P, long int );
     
    38483849``\lstinline$ptr_to$'' specifications.
    38493850\begin{lstlisting}
    3850 trait m_l_ptr_to( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to}@ otype T | ptr_to( P, T )@\use{ptr_to}@ {
     3851context 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}@ {
    38513852        P ?=?( P *, T * );
    38523853        T * ?=?( T **, P );
    38533854};
    3854 trait m_l_ptr_to_const( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_const}@ otype T | ptr_to_const( P, T )@\use{ptr_to_const}@) {
     3855context 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}@) {
    38553856        P ?=?( P *, const T * );
    38563857        const T * ?=?( const T **, P );
    38573858};
    3858 trait m_l_ptr_to_volatile( type P | m_l_pointer( P ),@\use{m_l_pointer}@@\impl{m_l_ptr_to_volatile}@ otype T | ptr_to_volatile( P, T )) {@\use{ptr_to_volatile}@
     3859context 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}@
    38593860        P ?=?( P *, volatile T * );
    38603861        volatile T * ?=?( volatile T **, P );
    38613862};
    3862 trait 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}@
     3863context 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}@
    38633864                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}@
    38643865        P ?=?( P *, const volatile T * );
     
    38703871An 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.
    38713872\begin{lstlisting}
    3872 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 ) ) {
     3873context 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 ) ) {
    38733874        MyP ?=?( MyP *, CP );
    38743875        CP ?=?( CP *, MyP );
     
    39033904C and \CFA have an extra, non-obvious comparison operator: ``\lstinline$!$'', logical negation, returns 1 if its operand compares equal to 0, and 0 otherwise.
    39043905\begin{lstlisting}
    3905 trait comparable( otype T ) {
     3906context comparable( type T ) {
    39063907        const T 0;
    39073908        int compare( T, T );
    39083909}
    3909 forall( otype T | comparable( T ) ) int ?<?( T l, T r ) {
     3910forall( type T | comparable( T ) ) int ?<?( T l, T r ) {
    39103911        return compare( l, r ) < 0;
    39113912}
    39123913// ... similarly for <=, ==, >=, >, and !=.
    3913 forall( otype T | comparable( T ) ) int !?( T operand ) {
     3914forall( type T | comparable( T ) ) int !?( T operand ) {
    39143915        return !compare( operand, 0 );
    39153916}
     
    39233924Similarly, a complete integral type would provide integral operations based on integral assignment operations.
    39243925\begin{lstlisting}
    3925 trait arith_base( otype T ) {
     3926context arith_base( type T ) {
    39263927        const T 1;
    39273928        T ?+=?( T *, T ), ?-=?( T *, T ), ?*=?( T *, T ), ?/=?( T *, T );
    39283929}
    3929 forall( otype T | arith_base( T ) ) T ?+?( T l, T r ) {
     3930forall( type T | arith_base( T ) ) T ?+?( T l, T r ) {
    39303931        return l += r;
    39313932}
    3932 forall( otype T | arith_base( T ) ) T ?++( T * operand ) {
     3933forall( type T | arith_base( T ) ) T ?++( T * operand ) {
    39333934        T temporary = *operand;
    39343935        *operand += 1;
    39353936        return temporary;
    39363937}
    3937 forall( otype T | arith_base( T ) ) T ++?( T * operand ) {
     3938forall( type T | arith_base( T ) ) T ++?( T * operand ) {
    39383939        return *operand += 1;
    39393940}
    39403941// ... similarly for -, --, *, and /.
    3941 trait int_base( otype T ) {
     3942context int_base( type T ) {
    39423943        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );
    39433944        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );
    39443945}
    3945 forall( otype T | int_base( T ) ) T ?&?( T l, T r ) {
     3946forall( type T | int_base( T ) ) T ?&?( T l, T r ) {
    39463947        return l &= r;
    39473948}
  • src/examples/fstream_test.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Mar  6 20:58:29 2016
    13 // Update Count     : 54
     12// Last Modified On : Wed Mar  2 15:12:21 2016
     13// Update Count     : 51
    1414//
    1515
     
    2828        int i, j, k;
    2929        sin  | &i | &j | &k;
    30         sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k | endl;
     30        sout | "Vous avez entré" | "i:" | i | "j:" | j | "k:" | k | endl;
    3131}
    3232
  • src/examples/huge.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:16:32 2016
    13 // Update Count     : 2
     12// Last Modified On : Wed May 27 18:15:34 2015
     13// Update Count     : 1
    1414//
    1515
    16 int huge( int n, forall( otype T ) T (*f)( T ) ) {
     16int huge( int n, forall( type T ) T (*f)( T ) ) {
    1717        if ( n <= 0 )
    1818                return f( 0 );
  • src/examples/identity.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:15:08 2016
    13 // Update Count     : 13
     12// Last Modified On : Mon Feb 29 23:40:45 2016
     13// Update Count     : 12
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( otype T )
     18forall( type T )
    1919T identity( T t ) {
    2020        return t;
  • src/examples/includes.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 23:28:02 2016
    13 // Update Count     : 328
     12// Last Modified On : Mon Dec 21 13:54:09 2015
     13// Update Count     : 322
    1414//
    1515
     
    4343#include <ctype.h>
    4444#include <curses.h>
    45 #include <demangle.h>
    46 #include <dialog.h>
     45#include <demangle.h>           // enum / contains "type"
     46#include <dialog.h>                     // enum / contains "type"
    4747#include <dirent.h>
    4848#include <dis-asm.h>
     
    5656#include <err.h>
    5757#include <errno.h>
     58#include <error.h>
    5859#if 0
    59 #include <error.h>
    60 #endif
    6160#include <eti.h>
    62 #include <evdns.h>
     61#include <evdns.h>                      // subdirectory event2 contains "type"
    6362#include <event.h>
    64 #include <evhttp.h>
    65 #if 0
     63#include <evhttp.h>                     // enum / subdirectory event2 contains "type"
    6664#include <evrpc.h>
    6765#include <evutil.h>
    6866#include <execinfo.h>
    69 #include <expat.h>
     67#include <expat.h>                      // enum / contains "type" and "context"
    7068#include <expat_config.h>
    7169#include <expat_external.h>
     
    7674#include <fmtmsg.h>
    7775#include <fnmatch.h>
    78 #include <form.h>
     76#include <form.h>                       // contains "type"
    7977#include <fpu_control.h>
    8078#include <fstab.h>
     
    8381#include <ftw.h>
    8482#include <gconv.h>
    85 //#include <gcrypt.h>
     83//#include <gcrypt.h>           // enum / contains "type"
    8684//#include <gcrypt-module.h>
    8785#include <getopt.h>
     
    109107#include <limits.h>
    110108#include <locale.h>
    111 #include <math.h>
     109#include <math.h>                       // contains "type"
    112110#include <ncurses.h>
    113111#include <setjmp.h>
  • src/examples/it_out.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:14:39 2016
    13 // Update Count     : 8
     12// Last Modified On : Wed Mar  2 18:11:00 2016
     13// Update Count     : 5
    1414//
    1515
     
    2121};
    2222
    23 trait writeable( otype T ) {
     23trait writeable( type T ) {
    2424        forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
    2525};
     
    3636};
    3737
    38 trait readable( otype T ) {
     38trait readable( type T ) {
    3939        forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
    4040};
     
    4343forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
    4444
    45 trait iterator( otype iterator_type, otype elt_type ) {
     45trait iterator( type iterator_type, type elt_type ) {
    4646        iterator_type ?++( iterator_type* );
    4747        iterator_type ++?( iterator_type* );
     
    5252};
    5353
    54 forall( otype elt_type | writeable( elt_type ),
    55                 otype iterator_type | iterator( iterator_type, elt_type ),
     54forall( type elt_type | writeable( elt_type ),
     55                type iterator_type | iterator( iterator_type, elt_type ),
    5656                dtype os_type | ostream( os_type ) )
    5757void write_all( iterator_type begin, iterator_type end, os_type *os );
    5858
    59 forall( otype elt_type | writeable( elt_type ),
    60                 otype iterator_type | iterator( iterator_type, elt_type ),
     59forall( type elt_type | writeable( elt_type ),
     60                type iterator_type | iterator( iterator_type, elt_type ),
    6161                dtype os_type | ostream( os_type ) )
    6262void write_all( elt_type begin, iterator_type end, os_type *os ) {
  • src/examples/new.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:13:20 2016
    13 // Update Count     : 4
     12// Last Modified On : Mon Jan 25 23:33:55 2016
     13// Update Count     : 2
    1414//
    1515
    16 forall( otype T )
     16forall( type T )
    1717void f( T *t ) {
    1818        t--;
  • src/examples/prolog.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:09:39 2016
    13 // Update Count     : 5
     12// Last Modified On : Wed Mar  2 18:11:18 2016
     13// Update Count     : 2
    1414//
    1515
    16 #include <fstream>
     16extern "C" { extern int printf( const char *fmt, ... ); }
    1717
    18 void printResult( int x ) { sout | "int" | endl; }
    19 void printResult( double x ) { sout | "double" | endl; }
    20 void printResult( char * x ) { sout | "char*" | endl; }
     18void printResult( int x ) { printf( "int\n" ); }
     19void printResult( double x ) { printf( "double\n" ); }
     20void printResult( char * x ) { printf( "char*\n" ); }
    2121
    2222void is_arithmetic( int x ) {}
     
    2525void is_integer( int x ) {}
    2626
    27 trait ArithmeticType( otype T ) {
     27trait ArithmeticType( type T ) {
    2828        void is_arithmetic( T );
    2929};
    3030
    31 trait IntegralType( otype T | ArithmeticType( T ) ) {
     31trait IntegralType( type T | ArithmeticType( T ) ) {
    3232        void is_integer( T );
    3333};
    3434
    35 forall( otype T | IntegralType( T ) | { void printResult( T ); } )
     35forall( type T | IntegralType( T ) | { void printResult( T ); } )
    3636void hornclause( T param ) {
    3737        printResult( param );
  • src/examples/quad.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:07:02 2016
    13 // Update Count     : 8
     12// Last Modified On : Tue Mar  1 08:24:56 2016
     13// Update Count     : 7
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( otype T | { T ?*?( T, T ); } )
     18forall( type T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
    2121}
    2222
    23 forall( otype U | { U square( U ); } )
     23forall( type U | { U square( U ); } )
    2424U quad( U u ) {
    2525        return square( square( u ) );
  • src/examples/simplePoly.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:06:41 2016
    13 // Update Count     : 3
     12// Last Modified On : Wed May 27 18:31:17 2015
     13// Update Count     : 2
    1414//
    1515
    16 forall( otype T, otype U | { T f( T, U ); } )
     16forall( type T, type U | { T f( T, U ); } )
    1717T q( T t, U u ) {
    1818        return f( t, u );
  • src/examples/simpler.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:06:30 2016
    13 // Update Count     : 2
     12// Last Modified On : Wed May 27 18:31:48 2015
     13// Update Count     : 1
    1414//
    1515
    16 forall( otype T ) T id( T, T );
     16forall( type T ) T id( T, T );
    1717
    1818int main() {
  • src/examples/specialize.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:06:17 2016
    13 // Update Count     : 3
     12// Last Modified On : Wed May 27 18:32:26 2015
     13// Update Count     : 2
    1414//
    1515
     
    3939}
    4040
    41 forall( otype T ) T f( T t )
     41forall( type T ) T f( T t )
    4242{
    4343        printf( "in f; sizeof T is %d\n", sizeof( T ) );
  • src/examples/square.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:05:48 2016
    13 // Update Count     : 27
     12// Last Modified On : Wed Feb 17 12:21:58 2016
     13// Update Count     : 26
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( otype T | { T ?*?( T, T ); } )
     18forall( type T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
  • src/examples/sum.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar  4 15:06:47 2016
    13 // Update Count     : 196
     12// Last Modified On : Wed Mar  2 18:12:01 2016
     13// Update Count     : 194
    1414//
    1515
    1616#include <fstream>
    1717
    18 trait sumable( otype T ) {
     18trait sumable( type T ) {
    1919        const T 0;
    2020        T ?+?( T, T );
     
    2424}; // sumable
    2525
    26 forall( otype T | sumable( T ) )
     26forall( type T | sumable( T ) )
    2727T sum( unsigned int n, T a[] ) {
    2828        T total = 0;                                                                            // instantiate T, select 0
  • src/examples/twice.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:04:58 2016
    13 // Update Count     : 16
     12// Last Modified On : Wed Feb 17 12:23:25 2016
     13// Update Count     : 13
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( otype T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
     18forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
    1919T twice( const T t ) {
    2020        return t + t;
     
    2727        char ?++( char *op ) { char temp = *op; *op += 1; return temp; }
    2828
    29         sout | twice( 'a' ) | ' ' | twice( 1 ) | twice( 3.2 ) | endl;
     29        sout | twice( 'a' ) | ' ' | twice( 1 ) | ' ' | twice( 3.2 ) | endl;
    3030}
    3131
  • src/libcfa/Makefile.am

    rae357ec rbed4c63e  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Mar  2 22:59:23 2016
    14 ## Update Count     : 119
     13## Last Modified On : Wed Feb  3 11:19:35 2016
     14## Update Count     : 117
    1515###############################################################################
    1616
     
    6363libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c}
    6464
    65 cheaders = #  expat
     65cheaders = bfd bfdlink demangle dialog evdns evhttp evrpc expat fcntl form gcrypt math
    6666cfaheaders = limits
    6767include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
  • src/libcfa/Makefile.in

    rae357ec rbed4c63e  
    215215libs = stdlib iostream fstream iterator
    216216libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c}
    217 cheaders = #  expat
     217cheaders = bfd bfdlink demangle dialog evdns evhttp evrpc expat fcntl form gcrypt math
    218218cfaheaders = limits
    219219include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
  • src/libcfa/iostream.c

    rae357ec rbed4c63e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  7 13:51:23 2016
    13 // Update Count     : 227
     12// Last Modified On : Wed Mar  2 18:06:35 2016
     13// Update Count     : 208
    1414//
    1515
     
    133133forall( dtype ostype | ostream( ostype ) )
    134134ostype * ?|?( ostype *os, const char *cp ) {
    135         enum { Open = 1, Close, OpenClose };
    136         static const char mask[256] = {
    137                 // opening delimiters
    138                 ['('] : Open, ['['] : Open, ['{'] : Open,
    139                 ['$'] : Open, [L'£'] : Open, [L'¥'] : Open, [L'¢'] : Open, [L'¿'] : Open, [L'«'] : Open,
    140                 // closing delimiters
    141                 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
    142                 [')'] : Close, [']'] : Close, ['}'] : Close,
    143                 ['%'] : Close, [L'»'] : Close,
    144                 // opening-closing delimiters
    145                 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose,
    146         }; // mask
    147 
    148135        int len = strlen( cp );
    149136        // null string => no separator
    150137  if ( len == 0 ) { sepOff( os ); return os; }
    151         // first character NOT spacing or closing punctuation => add left separator
    152         if ( sepPrt( os ) && isspace( cp[0] ) == 0 && mask[ cp[0] ] != Close && mask[ cp[0] ] != OpenClose ) {
     138        // first character NOT spacing or special punctuation => add left separator
     139        if ( sepPrt( os ) && isspace( cp[0] ) == 0 && cp[0] != '.' && cp[0] != ',' ) {
    153140                prtfmt( os, "%s", sepGet( os ) );
    154141        } // if
    155         // last character IS spacing or opening punctuation => turn off separator for next item
     142        // last character is spacing or special punctuation => turn off separator for next item
    156143        unsigned int posn = len - 1;
    157         if ( isspace( cp[posn] ) || mask[ cp[posn] ] == Open || mask[ cp[posn] ] == OpenClose ) {
     144        if ( isspace( cp[posn] ) || cp[posn] == ':' || cp[posn] == '$' ) {
    158145                sepOff( os );
    159146        } else {
Note: See TracChangeset for help on using the changeset viewer.