Changes in / [bed4c63e:ae357ec]


Ignore:
Files:
11 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    rbed4c63e rae357ec  
    6262\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{-2.0ex \@plus -1ex \@minus -.2ex}{-1em}{\normalfont\normalsize\bfseries}}
    6363
     64% index macros
    6465\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
    6566\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     
    133134% adjust listings macros
    134135\lstdefinelanguage{CFA}[ANSI]{C}%
    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,},
     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,},
    138139}%
    139140
     
    280281An instantiation of the generic type is written by specifying the type parameters in parentheses after the name of the generic type generator:
    281282\begin{lstlisting}
    282 forall( type T | sumable( T ) ) struct pair {
     283forall( otype T | sumable( T ) ) struct pair {
    283284        T x;
    284285        T y;
     
    292293Polymorphic 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:
    293294\begin{lstlisting}
    294 forall( type T ) void swap( pair(T) *p ) {
     295forall( otype T ) void swap( pair(T) *p ) {
    295296        T z = p->x;
    296297        p->x = p->y;
     
    302303\subsubsection{Constraints}
    303304
    304 To 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.
     305To avoid unduly constraining implementors, the generic type generator definition must be visible at any point where it is instantiated.
     306Forward 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.
    305307
    306308\examples
    307309\begin{lstlisting}
    308 forall( type T ) struct A;
    309 
    310 forall( type T ) struct B {
     310forall( otype T ) struct A;
     311
     312forall( otype T ) struct B {
    311313        A(T) *a;                        // legal, but cannot instantiate B(T)
    312314};
     
    314316B(T) x;                                 // illegal, *x.a is of an incomplete generic type
    315317 
    316 forall( type T ) struct A {
     318forall( otype T ) struct A {
    317319        B( T ) *b;
    318320};
     
    321323
    322324// box.h:
    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 );
     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 );
    326328       
    327329// main.c:
     
    410412
    411413\subsubsection{Specialization}
    412 A 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}.
     414A 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}.
    414415Any value that is legal for the inferred parameter may be used, including other inferred parameters.
    415416
    416 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
    417   type} with or can be specialized to the type of the assertion parameter.  The assertion parameter is bound to that object or function.
     417If, 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.
     418The assertion parameter is bound to that object or function.
    418419
    419420The 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.
     
    422423The type
    423424\begin{lstlisting}
    424 forall( type T, type U ) void (*)( T, U );
     425forall( otype T, otype U ) void (*)( T, U );
    425426\end{lstlisting}
    426427can be specialized to (among other things)
    427428\begin{lstlisting}
    428 forall( type T ) void (*)( T, T );              // U bound to T
    429 forall( type T ) void (*)( T, real );   // U bound to real
    430 forall( type U ) void (*)( real, U );   // T bound to real
     429forall( otype T ) void (*)( T, T );             // U bound to T
     430forall( otype T ) void (*)( T, real );  // U bound to real
     431forall( otype U ) void (*)( real, U );  // T bound to real
    431432void f( real, real );                                   // both bound to real
    432433\end{lstlisting}
     
    434435The type
    435436\begin{lstlisting}
    436 forall( type T | T ?+?( T, T ) ) T (*)( T );
     437forall( otype T | T ?+?( T, T ) ) T (*)( T );
    437438\end{lstlisting}
    438439can be specialized to (among other things)
     
    494495If \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:
    495496\lstinline$unsigned short$ to \lstinline$int$ to \lstinline$unsigned$.
    496 Otherwise,
    497 \lstinline$unsigned short$ is converted directly to \lstinline$unsigned$, and the cost is 1.
     497Otherwise, \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$context$
     510        \rhs \lstinline$trait$
    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
    542 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 0 as a special case.
    543542However, 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.
    544543Defining special constants for a user-defined type is more efficient than defining a conversion to the type from \lstinline$_Bool$.
     
    836835\predefined
    837836\begin{lstlisting}
    838 forall( type T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
    839 forall( type T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
    840 forall( type T ) lvalue const T ?[?]( const T *, ptrdiff_t );
    841 forall( type T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
    842 forall( type T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
    843 forall( type T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
    844 forall( type T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
    845 forall( type T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
    846 forall( type T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
    847 forall( type T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
    848 forall( type T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
    849 forall( type T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
    850 forall( type T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
    851 forall( type T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
    852 forall( type T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
    853 forall( type T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
     837forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t );@\use{ptrdiff_t}@
     838forall( otype T ) lvalue _Atomic T ?[?]( _Atomic T *, ptrdiff_t );
     839forall( otype T ) lvalue const T ?[?]( const T *, ptrdiff_t );
     840forall( otype T ) lvalue restrict T ?[?]( restrict T *, ptrdiff_t );
     841forall( otype T ) lvalue volatile T ?[?]( volatile T *, ptrdiff_t );
     842forall( otype T ) lvalue _Atomic const T ?[?]( _Atomic const T *, ptrdiff_t );
     843forall( otype T ) lvalue _Atomic restrict T ?[?]( _Atomic restrict T *, ptrdiff_t );
     844forall( otype T ) lvalue _Atomic volatile T ?[?]( _Atomic volatile T *, ptrdiff_t );
     845forall( otype T ) lvalue const restrict T ?[?]( const restrict T *, ptrdiff_t );
     846forall( otype T ) lvalue const volatile T ?[?]( const volatile T *, ptrdiff_t );
     847forall( otype T ) lvalue restrict volatile T ?[?]( restrict volatile T *, ptrdiff_t );
     848forall( otype T ) lvalue _Atomic const restrict T ?[?]( _Atomic const restrict T *, ptrdiff_t );
     849forall( otype T ) lvalue _Atomic const volatile T ?[?]( _Atomic const volatile T *, ptrdiff_t );
     850forall( otype T ) lvalue _Atomic restrict volatile T ?[?]( _Atomic restrict volatile T *, ptrdiff_t );
     851forall( otype T ) lvalue const restrict volatile T ?[?]( const restrict volatile T *, ptrdiff_t );
     852forall( otype T ) lvalue _Atomic const restrict volatile T ?[?]( _Atomic const restrict volatile T *, ptrdiff_t );
    854853\end{lstlisting}
    855854\semantics
     
    914913\begin{rationale}
    915914One 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}.
    916 For 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$.
     915For 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$.
    917916
    918917\CFA\index{deficiencies!generalizability} does not fully possess this property, because
     
    928927f = g( d, f );          // (3) (unsafe conversion to float)
    929928\end{lstlisting}
    930 If \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
     929If \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
    931930\lstinline$double$, and the result would be a \lstinline$double$.
    932931
    933932Another example is the function ``\lstinline$void h( int *);$''.
    934933This function can be passed a
    935 \lstinline$void *$ argument, but the generalization ``\lstinline$forall( type T ) void h( T *);$'' can not.
     934\lstinline$void *$ argument, but the generalization ``\lstinline$forall( otype T ) void h( T *);$'' can not.
    936935In this case, \lstinline$void$ is not a valid value for \lstinline$T$ because it is not an object type.
    937936If unsafe conversions were allowed, \lstinline$T$ could be inferred to be \emph{any} object type, which is undesirable.
     
    941940A function called ``\lstinline$?()$'' might be part of a numerical differentiation package.
    942941\begin{lstlisting}
    943 extern type Derivative;
     942extern otype Derivative;
    944943extern double ?()( Derivative, double );
    945944extern Derivative derivative_of( double (*f)( double ) );
     
    962961
    963962\begin{lstlisting}
    964 forall( type T ) T h( T );
     963forall( otype T ) T h( T );
    965964double d = h( 1.5 );
    966965\end{lstlisting}
     
    969968
    970969\begin{lstlisting}
    971 forall( type T, type U ) void g( T, U );        // (4)
    972 forall( type T ) void g( T, T );                        // (5)
    973 forall( type T ) void g( T, long );                     // (6)
     970forall( otype T, otype U ) void g( T, U );      // (4)
     971forall( otype T ) void g( T, T );                       // (5)
     972forall( otype T ) void g( T, long );                    // (6)
    974973void g( long, long );                                           // (7)
    975974double d;
     
    991990The fourth call has no interpretation for (5), because its arguments must have compatible type. (4) is chosen because it does not involve unsafe conversions.
    992991\begin{lstlisting}
    993 forall( type T ) T min( T, T );
     992forall( otype T ) T min( T, T );
    994993double max( double, double );
    995 context min_max( T ) {@\impl{min_max}@
     994trait min_max( T ) {@\impl{min_max}@
    996995        T min( T, T );
    997996        T max( T, T );
    998997}
    999 forall( type U | min_max( U ) ) void shuffle( U, U );
     998forall( otype U | min_max( U ) ) void shuffle( U, U );
    1000999shuffle( 9, 10 );
    10011000\end{lstlisting}
     
    10471046long double ?++( volatile long double * ), ?++( _Atomic volatile long double * );
    10481047
    1049 forall( type T ) T * ?++( T * restrict volatile * ), * ?++( T * _Atomic restrict volatile * );
    1050 forall( type T ) _Atomic T * ?++( _Atomic T * restrict volatile * ), * ?++( _Atomic T * _Atomic restrict volatile * );
    1051 forall( type T ) const T * ?++( const T * restrict volatile * ), * ?++( const T * _Atomic restrict volatile * );
    1052 forall( type T ) volatile T * ?++( volatile T * restrict volatile * ), * ?++( volatile T * _Atomic restrict volatile * );
    1053 forall( type T ) restrict T * ?++( restrict T * restrict volatile * ), * ?++( restrict T * _Atomic restrict volatile * );
    1054 forall( type T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
     1048forall( otype T ) T * ?++( T * restrict volatile * ), * ?++( T * _Atomic restrict volatile * );
     1049forall( otype T ) _Atomic T * ?++( _Atomic T * restrict volatile * ), * ?++( _Atomic T * _Atomic restrict volatile * );
     1050forall( otype T ) const T * ?++( const T * restrict volatile * ), * ?++( const T * _Atomic restrict volatile * );
     1051forall( otype T ) volatile T * ?++( volatile T * restrict volatile * ), * ?++( volatile T * _Atomic restrict volatile * );
     1052forall( otype T ) restrict T * ?++( restrict T * restrict volatile * ), * ?++( restrict T * _Atomic restrict volatile * );
     1053forall( otype T ) _Atomic const T * ?++( _Atomic const T * restrict volatile * ),
    10551054        * ?++( _Atomic const T * _Atomic restrict volatile * );
    1056 forall( type T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
     1055forall( otype T ) _Atomic restrict T * ?++( _Atomic restrict T * restrict volatile * ),
    10571056        * ?++( _Atomic restrict T * _Atomic restrict volatile * );
    1058 forall( type T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
     1057forall( otype T ) _Atomic volatile T * ?++( _Atomic volatile T * restrict volatile * ),
    10591058        * ?++( _Atomic volatile T * _Atomic restrict volatile * );
    1060 forall( type T ) const restrict T * ?++( const restrict T * restrict volatile * ),
     1059forall( otype T ) const restrict T * ?++( const restrict T * restrict volatile * ),
    10611060        * ?++( const restrict T * _Atomic restrict volatile * );
    1062 forall( type T ) const volatile T * ?++( const volatile T * restrict volatile * ),
     1061forall( otype T ) const volatile T * ?++( const volatile T * restrict volatile * ),
    10631062        * ?++( const volatile T * _Atomic restrict volatile * );
    1064 forall( type T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
     1063forall( otype T ) restrict volatile T * ?++( restrict volatile T * restrict volatile * ),
    10651064        * ?++( restrict volatile T * _Atomic restrict volatile * );
    1066 forall( type T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
     1065forall( otype T ) _Atomic const restrict T * ?++( _Atomic const restrict T * restrict volatile * ),
    10671066        * ?++( _Atomic const restrict T * _Atomic restrict volatile * );
    1068 forall( type T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
     1067forall( otype T ) _Atomic const volatile T * ?++( _Atomic const volatile T * restrict volatile * ),
    10691068        * ?++( _Atomic const volatile T * _Atomic restrict volatile * );
    1070 forall( type T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
     1069forall( otype T ) _Atomic restrict volatile T * ?++( _Atomic restrict volatile T * restrict volatile * ),
    10711070        * ?++( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1072 forall( type T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
     1071forall( otype T ) const restrict volatile T * ?++( const restrict volatile T * restrict volatile * ),
    10731072        * ?++( const restrict volatile T * _Atomic restrict volatile * );
    1074 forall( type T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
     1073forall( otype T ) _Atomic const restrict volatile T * ?++( _Atomic const restrict volatile T * restrict volatile * ),
    10751074        * ?++( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    10761075
     
    10911090long double ?--( volatile long double * ), ?--( _Atomic volatile long double * );
    10921091
    1093 forall( type T ) T * ?--( T * restrict volatile * ), * ?--( T * _Atomic restrict volatile * );
    1094 forall( type T ) _Atomic T * ?--( _Atomic T * restrict volatile * ), * ?--( _Atomic T * _Atomic restrict volatile * );
    1095 forall( type T ) const T * ?--( const T * restrict volatile * ), * ?--( const T * _Atomic restrict volatile * );
    1096 forall( type T ) volatile T * ?--( volatile T * restrict volatile * ), * ?--( volatile T * _Atomic restrict volatile * );
    1097 forall( type T ) restrict T * ?--( restrict T * restrict volatile * ), * ?--( restrict T * _Atomic restrict volatile * );
    1098 forall( type T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
     1092forall( otype T ) T * ?--( T * restrict volatile * ), * ?--( T * _Atomic restrict volatile * );
     1093forall( otype T ) _Atomic T * ?--( _Atomic T * restrict volatile * ), * ?--( _Atomic T * _Atomic restrict volatile * );
     1094forall( otype T ) const T * ?--( const T * restrict volatile * ), * ?--( const T * _Atomic restrict volatile * );
     1095forall( otype T ) volatile T * ?--( volatile T * restrict volatile * ), * ?--( volatile T * _Atomic restrict volatile * );
     1096forall( otype T ) restrict T * ?--( restrict T * restrict volatile * ), * ?--( restrict T * _Atomic restrict volatile * );
     1097forall( otype T ) _Atomic const T * ?--( _Atomic const T * restrict volatile * ),
    10991098        * ?--( _Atomic const T * _Atomic restrict volatile * );
    1100 forall( type T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
     1099forall( otype T ) _Atomic restrict T * ?--( _Atomic restrict T * restrict volatile * ),
    11011100        * ?--( _Atomic restrict T * _Atomic restrict volatile * );
    1102 forall( type T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
     1101forall( otype T ) _Atomic volatile T * ?--( _Atomic volatile T * restrict volatile * ),
    11031102        * ?--( _Atomic volatile T * _Atomic restrict volatile * );
    1104 forall( type T ) const restrict T * ?--( const restrict T * restrict volatile * ),
     1103forall( otype T ) const restrict T * ?--( const restrict T * restrict volatile * ),
    11051104        * ?--( const restrict T * _Atomic restrict volatile * );
    1106 forall( type T ) const volatile T * ?--( const volatile T * restrict volatile * ),
     1105forall( otype T ) const volatile T * ?--( const volatile T * restrict volatile * ),
    11071106        * ?--( const volatile T * _Atomic restrict volatile * );
    1108 forall( type T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
     1107forall( otype T ) restrict volatile T * ?--( restrict volatile T * restrict volatile * ),
    11091108        * ?--( restrict volatile T * _Atomic restrict volatile * );
    1110 forall( type T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
     1109forall( otype T ) _Atomic const restrict T * ?--( _Atomic const restrict T * restrict volatile * ),
    11111110        * ?--( _Atomic const restrict T * _Atomic restrict volatile * );
    1112 forall( type T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
     1111forall( otype T ) _Atomic const volatile T * ?--( _Atomic const volatile T * restrict volatile * ),
    11131112        * ?--( _Atomic const volatile T * _Atomic restrict volatile * );
    1114 forall( type T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
     1113forall( otype T ) _Atomic restrict volatile T * ?--( _Atomic restrict volatile T * restrict volatile * ),
    11151114        * ?--( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1116 forall( type T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
     1115forall( otype T ) const restrict volatile T * ?--( const restrict volatile T * restrict volatile * ),
    11171116        * ?--( const restrict volatile T * _Atomic restrict volatile * );
    1118 forall( type T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
     1117forall( otype T ) _Atomic const restrict volatile T * ?--( _Atomic const restrict volatile T * restrict volatile * ),
    11191118        * ?--( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    11201119\end{lstlisting}
     
    11951194The expression would be valid if \lstinline$?++$ were declared by
    11961195\begin{lstlisting}
    1197 forall( type T ) T * ?++( T * * );
     1196forall( otype T ) T * ?++( T * * );
    11981197\end{lstlisting} with \lstinline$T$ inferred to be \lstinline$char$.
    11991198
     
    12031202Hence the actual predefined function is
    12041203\begin{lstlisting}
    1205 forall( type T ) T * ?++( T * restrict volatile * );
     1204forall( otype T ) T * ?++( T * restrict volatile * );
    12061205\end{lstlisting} which also accepts a \lstinline$char * *$ argument, because of the safe conversions that add
    12071206\lstinline$volatile$ and \lstinline$restrict$ qualifiers. (The parameter is not const-qualified, so constant pointers cannot be incremented.)
     
    12171216\lstinline$char const volatile *$, so a new overloading is needed:
    12181217\begin{lstlisting}
    1219 forall( type T ) T const volatile * ?++( T const volatile *restrict volatile * );
     1218forall( otype T ) T const volatile * ?++( T const volatile *restrict volatile * );
    12201219\end{lstlisting}
    12211220One overloading is needed for each combination of qualifiers in the pointed-at type\index{deficiencies!pointers to qualified types}.
     
    12251224The \lstinline$restrict$ qualifier is handled just like \lstinline$const$ and \lstinline$volatile$ in the previous case:
    12261225\begin{lstlisting}
    1227 forall( type T ) T restrict * ?++( T restrict *restrict volatile * );
     1226forall( otype T ) T restrict * ?++( T restrict *restrict volatile * );
    12281227\end{lstlisting} with \lstinline$T$ inferred to be \lstinline$float *$.
    12291228This 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.
     
    12831282long double ++?( volatile long double * ), ++?( _Atomic volatile long double * );
    12841283
    1285 forall( type T ) T * ++?( T * restrict volatile * ), * ++?( T * _Atomic restrict volatile * );
    1286 forall( type T ) _Atomic T * ++?( _Atomic T * restrict volatile * ), * ++?( _Atomic T * _Atomic restrict volatile * );
    1287 forall( type T ) const T * ++?( const T * restrict volatile * ), * ++?( const T * _Atomic restrict volatile * );
    1288 forall( type T ) volatile T * ++?( volatile T * restrict volatile * ), * ++?( volatile T * _Atomic restrict volatile * );
    1289 forall( type T ) restrict T * ++?( restrict T * restrict volatile * ), * ++?( restrict T * _Atomic restrict volatile * );
    1290 forall( type T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
     1284forall( otype T ) T * ++?( T * restrict volatile * ), * ++?( T * _Atomic restrict volatile * );
     1285forall( otype T ) _Atomic T * ++?( _Atomic T * restrict volatile * ), * ++?( _Atomic T * _Atomic restrict volatile * );
     1286forall( otype T ) const T * ++?( const T * restrict volatile * ), * ++?( const T * _Atomic restrict volatile * );
     1287forall( otype T ) volatile T * ++?( volatile T * restrict volatile * ), * ++?( volatile T * _Atomic restrict volatile * );
     1288forall( otype T ) restrict T * ++?( restrict T * restrict volatile * ), * ++?( restrict T * _Atomic restrict volatile * );
     1289forall( otype T ) _Atomic const T * ++?( _Atomic const T * restrict volatile * ),
    12911290        * ++?( _Atomic const T * _Atomic restrict volatile * );
    1292 forall( type T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
     1291forall( otype T ) _Atomic volatile T * ++?( _Atomic volatile T * restrict volatile * ),
    12931292        * ++?( _Atomic volatile T * _Atomic restrict volatile * );
    1294 forall( type T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
     1293forall( otype T ) _Atomic restrict T * ++?( _Atomic restrict T * restrict volatile * ),
    12951294        * ++?( _Atomic restrict T * _Atomic restrict volatile * );
    1296 forall( type T ) const volatile T * ++?( const volatile T * restrict volatile * ),
     1295forall( otype T ) const volatile T * ++?( const volatile T * restrict volatile * ),
    12971296        * ++?( const volatile T * _Atomic restrict volatile * );
    1298 forall( type T ) const restrict T * ++?( const restrict T * restrict volatile * ),
     1297forall( otype T ) const restrict T * ++?( const restrict T * restrict volatile * ),
    12991298        * ++?( const restrict T * _Atomic restrict volatile * );
    1300 forall( type T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
     1299forall( otype T ) restrict volatile T * ++?( restrict volatile T * restrict volatile * ),
    13011300        * ++?( restrict volatile T * _Atomic restrict volatile * );
    1302 forall( type T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
     1301forall( otype T ) _Atomic const volatile T * ++?( _Atomic const volatile T * restrict volatile * ),
    13031302        * ++?( _Atomic const volatile T * _Atomic restrict volatile * );
    1304 forall( type T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
     1303forall( otype T ) _Atomic const restrict T * ++?( _Atomic const restrict T * restrict volatile * ),
    13051304        * ++?( _Atomic const restrict T * _Atomic restrict volatile * );
    1306 forall( type T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
     1305forall( otype T ) _Atomic restrict volatile T * ++?( _Atomic restrict volatile T * restrict volatile * ),
    13071306        * ++?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1308 forall( type T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
     1307forall( otype T ) const restrict volatile T * ++?( const restrict volatile T * restrict volatile * ),
    13091308        * ++?( const restrict volatile T * _Atomic restrict volatile * );
    1310 forall( type T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
     1309forall( otype T ) _Atomic const restrict volatile T * ++?( _Atomic const restrict volatile T * restrict volatile * ),
    13111310        * ++?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    13121311
     
    13271326long double --?( volatile long double * ), --?( _Atomic volatile long double * );
    13281327
    1329 forall( type T ) T * --?( T * restrict volatile * ), * --?( T * _Atomic restrict volatile * );
    1330 forall( type T ) _Atomic T * --?( _Atomic T * restrict volatile * ), * --?( _Atomic T * _Atomic restrict volatile * );
    1331 forall( type T ) const T * --?( const T * restrict volatile * ), * --?( const T * _Atomic restrict volatile * );
    1332 forall( type T ) volatile T * --?( volatile T * restrict volatile * ), * --?( volatile T * _Atomic restrict volatile * );
    1333 forall( type T ) restrict T * --?( restrict T * restrict volatile * ), * --?( restrict T * _Atomic restrict volatile * );
    1334 forall( type T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
     1328forall( otype T ) T * --?( T * restrict volatile * ), * --?( T * _Atomic restrict volatile * );
     1329forall( otype T ) _Atomic T * --?( _Atomic T * restrict volatile * ), * --?( _Atomic T * _Atomic restrict volatile * );
     1330forall( otype T ) const T * --?( const T * restrict volatile * ), * --?( const T * _Atomic restrict volatile * );
     1331forall( otype T ) volatile T * --?( volatile T * restrict volatile * ), * --?( volatile T * _Atomic restrict volatile * );
     1332forall( otype T ) restrict T * --?( restrict T * restrict volatile * ), * --?( restrict T * _Atomic restrict volatile * );
     1333forall( otype T ) _Atomic const T * --?( _Atomic const T * restrict volatile * ),
    13351334        * --?( _Atomic const T * _Atomic restrict volatile * );
    1336 forall( type T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
     1335forall( otype T ) _Atomic volatile T * --?( _Atomic volatile T * restrict volatile * ),
    13371336        * --?( _Atomic volatile T * _Atomic restrict volatile * );
    1338 forall( type T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
     1337forall( otype T ) _Atomic restrict T * --?( _Atomic restrict T * restrict volatile * ),
    13391338        * --?( _Atomic restrict T * _Atomic restrict volatile * );
    1340 forall( type T ) const volatile T * --?( const volatile T * restrict volatile * ),
     1339forall( otype T ) const volatile T * --?( const volatile T * restrict volatile * ),
    13411340        * --?( const volatile T * _Atomic restrict volatile * );
    1342 forall( type T ) const restrict T * --?( const restrict T * restrict volatile * ),
     1341forall( otype T ) const restrict T * --?( const restrict T * restrict volatile * ),
    13431342        * --?( const restrict T * _Atomic restrict volatile * );
    1344 forall( type T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
     1343forall( otype T ) restrict volatile T * --?( restrict volatile T * restrict volatile * ),
    13451344        * --?( restrict volatile T * _Atomic restrict volatile * );
    1346 forall( type T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
     1345forall( otype T ) _Atomic const volatile T * --?( _Atomic const volatile T * restrict volatile * ),
    13471346        * --?( _Atomic const volatile T * _Atomic restrict volatile * );
    1348 forall( type T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
     1347forall( otype T ) _Atomic const restrict T * --?( _Atomic const restrict T * restrict volatile * ),
    13491348        * --?( _Atomic const restrict T * _Atomic restrict volatile * );
    1350 forall( type T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
     1349forall( otype T ) _Atomic restrict volatile T * --?( _Atomic restrict volatile T * restrict volatile * ),
    13511350        * --?( _Atomic restrict volatile T * _Atomic restrict volatile * );
    1352 forall( type T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
     1351forall( otype T ) const restrict volatile T * --?( const restrict volatile T * restrict volatile * ),
    13531352        * --?( const restrict volatile T * _Atomic restrict volatile * );
    1354 forall( type T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
     1353forall( otype T ) _Atomic const restrict volatile T * --?( _Atomic const restrict volatile T * restrict volatile * ),
    13551354        * --?( _Atomic const restrict volatile T * _Atomic restrict volatile * );
    13561355\end{lstlisting}
     
    13801379\predefined
    13811380\begin{lstlisting}
    1382 forall( type T ) lvalue T *?( T * );
    1383 forall( type T ) _Atomic lvalue T *?( _Atomic T * );
    1384 forall( type T ) const lvalue T *?( const T * );
    1385 forall( type T ) volatile lvalue T *?( volatile T * );
    1386 forall( type T ) restrict lvalue T *?( restrict T * );
    1387 forall( type T ) _Atomic const lvalue T *?( _Atomic const T * );
    1388 forall( type T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
    1389 forall( type T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
    1390 forall( type T ) const volatile lvalue T *?( const volatile T * );
    1391 forall( type T ) const restrict lvalue T *?( const restrict T * );
    1392 forall( type T ) restrict volatile lvalue T *?( restrict volatile T * );
    1393 forall( type T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
    1394 forall( type T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
    1395 forall( type T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
    1396 forall( type T ) const restrict volatile lvalue T *?( const restrict volatile T * );
    1397 forall( type T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
     1381forall( otype T ) lvalue T *?( T * );
     1382forall( otype T ) _Atomic lvalue T *?( _Atomic T * );
     1383forall( otype T ) const lvalue T *?( const T * );
     1384forall( otype T ) volatile lvalue T *?( volatile T * );
     1385forall( otype T ) restrict lvalue T *?( restrict T * );
     1386forall( otype T ) _Atomic const lvalue T *?( _Atomic const T * );
     1387forall( otype T ) _Atomic volatile lvalue T *?( _Atomic volatile T * );
     1388forall( otype T ) _Atomic restrict lvalue T *?( _Atomic restrict T * );
     1389forall( otype T ) const volatile lvalue T *?( const volatile T * );
     1390forall( otype T ) const restrict lvalue T *?( const restrict T * );
     1391forall( otype T ) restrict volatile lvalue T *?( restrict volatile T * );
     1392forall( otype T ) _Atomic const volatile lvalue T *?( _Atomic const volatile T * );
     1393forall( otype T ) _Atomic const restrict lvalue T *?( _Atomic const restrict T * );
     1394forall( otype T ) _Atomic restrict volatile lvalue T *?( _Atomic restrict volatile T * );
     1395forall( otype T ) const restrict volatile lvalue T *?( const restrict volatile T * );
     1396forall( otype T ) _Atomic const restrict volatile lvalue T *?( _Atomic const restrict volatile T * );
    13981397forall( ftype FT ) FT *?( FT * );
    13991398\end{lstlisting}
     
    15101509\begin{rationale}
    15111510\begin{lstlisting}
    1512 type Pair = struct { int first, second; };
     1511otype Pair = struct { int first, second; };
    15131512size_t p_size = sizeof(Pair);           // constant expression
    1514 extern type Rational;@\use{Rational}@
     1513extern otype Rational;@\use{Rational}@
    15151514size_t c_size = sizeof(Rational);       // non-constant expression
    15161515forall(type T) T f(T p1, T p2) {
     
    16361635Consider
    16371636\begin{lstlisting}
    1638 forall( type T | T ?*?( T, T ) ) T square( T );
     1637forall( otype T | T ?*?( T, T ) ) T square( T );
    16391638short s;
    16401639square( s );
     
    16471646A more troubling example is
    16481647\begin{lstlisting}
    1649 forall( type T | ?*?( T, T ) ) T product( T[], int n );
     1648forall( otype T | ?*?( T, T ) ) T product( T[], int n );
    16501649short sa[5];
    16511650product( sa, 5);
     
    17041703        ?+?( _Complex long double, _Complex long double ), ?-?( _Complex long double, _Complex long double );
    17051704
    1706 forall( type T ) T * ?+?( T *, ptrdiff_t ), * ?+?( ptrdiff_t, T * ), * ?-?( T *, ptrdiff_t );
    1707 forall( type T ) _Atomic T * ?+?( _Atomic T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic T * ),
     1705forall( otype T ) T * ?+?( T *, ptrdiff_t ), * ?+?( ptrdiff_t, T * ), * ?-?( T *, ptrdiff_t );
     1706forall( otype T ) _Atomic T * ?+?( _Atomic T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic T * ),
    17081707        * ?-?( _Atomic T *, ptrdiff_t );
    1709 forall( type T ) const T * ?+?( const T *, ptrdiff_t ), * ?+?( ptrdiff_t, const T * ),
     1708forall( otype T ) const T * ?+?( const T *, ptrdiff_t ), * ?+?( ptrdiff_t, const T * ),
    17101709        * ?-?( const T *, ptrdiff_t );
    1711 forall( type T ) restrict T * ?+?( restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict T * ),
     1710forall( otype T ) restrict T * ?+?( restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict T * ),
    17121711        * ?-?( restrict T *, ptrdiff_t );
    1713 forall( type T ) volatile T * ?+?( volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, volatile T * ),
     1712forall( otype T ) volatile T * ?+?( volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, volatile T * ),
    17141713        * ?-?( volatile T *, ptrdiff_t );
    1715 forall( type T ) _Atomic const T * ?+?( _Atomic const T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic const T * ),
     1714forall( otype T ) _Atomic const T * ?+?( _Atomic const T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic const T * ),
    17161715        * ?-?( _Atomic const T *, ptrdiff_t );
    1717 forall( type T ) _Atomic restrict T * ?+?( _Atomic restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic restrict T * ),
     1716forall( otype T ) _Atomic restrict T * ?+?( _Atomic restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic restrict T * ),
    17181717        * ?-?( _Atomic restrict T *, ptrdiff_t );
    1719 forall( type T ) _Atomic volatile T * ?+?( _Atomic volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic volatile T * ),
     1718forall( otype T ) _Atomic volatile T * ?+?( _Atomic volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, _Atomic volatile T * ),
    17201719        * ?-?( _Atomic volatile T *, ptrdiff_t );
    1721 forall( type T ) const restrict T * ?+?( const restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, const restrict T * ),
     1720forall( otype T ) const restrict T * ?+?( const restrict T *, ptrdiff_t ), * ?+?( ptrdiff_t, const restrict T * ),
    17221721        * ?-?( const restrict T *, ptrdiff_t );
    1723 forall( type T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, const volatile T * ),
     1722forall( otype T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, const volatile T * ),
    17241723        * ?-?( const volatile T *, ptrdiff_t );
    1725 forall( type T ) restrict volatile T * ?+?( restrict volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict volatile T * ),
     1724forall( otype T ) restrict volatile T * ?+?( restrict volatile T *, ptrdiff_t ), * ?+?( ptrdiff_t, restrict volatile T * ),
    17261725        * ?-?( restrict volatile T *, ptrdiff_t );
    1727 forall( type T ) _Atomic const restrict T * ?+?( _Atomic const restrict T *, ptrdiff_t ),
     1726forall( otype T ) _Atomic const restrict T * ?+?( _Atomic const restrict T *, ptrdiff_t ),
    17281727        * ?+?( ptrdiff_t, _Atomic const restrict T * ),
    17291728        * ?-?( _Atomic const restrict T *, ptrdiff_t );
    1730 forall( type T ) ptrdiff_t
     1729forall( otype T ) ptrdiff_t
    17311730        * ?-?( const restrict volatile T *, const restrict volatile T * ),
    17321731        * ?-?( _Atomic const restrict volatile T *, _Atomic const restrict volatile T * );
     
    20522051
    20532052\begin{lstlisting}
    2054 extern type Rational;@\use{Rational}@
     2053extern otype Rational;@\use{Rational}@
    20552054extern const Rational 0;@\use{0}@
    20562055extern int ?!=?( Rational, Rational );
     
    20952094If 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
    20962095\begin{lstlisting}
    2097 forall( type T ) T cond( int, T, T );
     2096forall( otype T ) T cond( int, T, T );
    20982097forall( dtype D ) void * cond( int, D *, void * ), * cond( int, void *, D * );
    20992098forall( dtype D ) _atomic void * cond(
     
    24552454\predefined
    24562455\begin{lstlisting}
    2457 forall( type T ) T
     2456forall( otype T ) T
    24582457        * ?+=?( T * restrict volatile *, ptrdiff_t ),
    24592458        * ?-=?( T * restrict volatile *, ptrdiff_t ),
    24602459        * ?+=?( T * _Atomic restrict volatile *, ptrdiff_t ),
    24612460        * ?-=?( T * _Atomic restrict volatile *, ptrdiff_t );
    2462 forall( type T ) T _Atomic
     2461forall( otype T ) T _Atomic
    24632462        * ?+=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    24642463        * ?-=?( T _Atomic * restrict volatile *, ptrdiff_t ),
    24652464        * ?+=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t ),
    24662465        * ?-=?( T _Atomic * _Atomic restrict volatile *, ptrdiff_t );
    2467 forall( type T ) T const
     2466forall( otype T ) T const
    24682467        * ?+=?( T const * restrict volatile *, ptrdiff_t ),
    24692468        * ?-=?( T const * restrict volatile *, ptrdiff_t ),
    24702469        * ?+=?( T const * _Atomic restrict volatile *, ptrdiff_t ),
    24712470        * ?-=?( T const * _Atomic restrict volatile *, ptrdiff_t );
    2472 forall( type T ) T restrict
     2471forall( otype T ) T restrict
    24732472        * ?+=?( T restrict * restrict volatile *, ptrdiff_t ),
    24742473        * ?-=?( T restrict * restrict volatile *, ptrdiff_t ),
    24752474        * ?+=?( T restrict * _Atomic restrict volatile *, ptrdiff_t ),
    24762475        * ?-=?( T restrict * _Atomic restrict volatile *, ptrdiff_t );
    2477 forall( type T ) T volatile
     2476forall( otype T ) T volatile
    24782477        * ?+=?( T volatile * restrict volatile *, ptrdiff_t ),
    24792478        * ?-=?( T volatile * restrict volatile *, ptrdiff_t ),
    24802479        * ?+=?( T volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24812480        * ?-=?( T volatile * _Atomic restrict volatile *, ptrdiff_t );
    2482 forall( type T ) T _Atomic const
     2481forall( otype T ) T _Atomic const
    24832482        * ?+=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    24842483        * ?-=?( T _Atomic const restrict volatile *, ptrdiff_t ),
    24852484        * ?+=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t ),
    24862485        * ?-=?( T _Atomic const _Atomic restrict volatile *, ptrdiff_t );
    2487 forall( type T ) T _Atomic restrict
     2486forall( otype T ) T _Atomic restrict
    24882487        * ?+=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    24892488        * ?-=?( T _Atomic restrict * restrict volatile *, ptrdiff_t ),
    24902489        * ?+=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t ),
    24912490        * ?-=?( T _Atomic restrict * _Atomic restrict volatile *, ptrdiff_t );
    2492 forall( type T ) T _Atomic volatile
     2491forall( otype T ) T _Atomic volatile
    24932492        * ?+=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    24942493        * ?-=?( T _Atomic volatile * restrict volatile *, ptrdiff_t ),
    24952494        * ?+=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t ),
    24962495        * ?-=?( T _Atomic volatile * _Atomic restrict volatile *, ptrdiff_t );
    2497 forall( type T ) T const restrict
     2496forall( otype T ) T const restrict
    24982497        * ?+=?( T const restrict * restrict volatile *, ptrdiff_t ),
    24992498        * ?-=?( T const restrict * restrict volatile *, ptrdiff_t ),
    25002499        * ?+=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    25012500        * ?-=?( T const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2502 forall( type T ) T const volatile
     2501forall( otype T ) T const volatile
    25032502        * ?+=?( T const volatile * restrict volatile *, ptrdiff_t ),
    25042503        * ?-=?( T const volatile * restrict volatile *, ptrdiff_t ),
    25052504        * ?+=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25062505        * ?-=?( T const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2507 forall( type T ) T restrict volatile
     2506forall( otype T ) T restrict volatile
    25082507        * ?+=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    25092508        * ?-=?( T restrict volatile * restrict volatile *, ptrdiff_t ),
    25102509        * ?+=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25112510        * ?-=?( T restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2512 forall( type T ) T _Atomic const restrict
     2511forall( otype T ) T _Atomic const restrict
    25132512        * ?+=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    25142513        * ?-=?( T _Atomic const restrict * restrict volatile *, ptrdiff_t ),
    25152514        * ?+=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t ),
    25162515        * ?-=?( T _Atomic const restrict * _Atomic restrict volatile *, ptrdiff_t );
    2517 forall( type T ) T _Atomic const volatile
     2516forall( otype T ) T _Atomic const volatile
    25182517        * ?+=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    25192518        * ?-=?( T _Atomic const volatile * restrict volatile *, ptrdiff_t ),
    25202519        * ?+=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25212520        * ?-=?( T _Atomic const volatile * _Atomic restrict volatile *, ptrdiff_t );
    2522 forall( type T ) T _Atomic restrict volatile
     2521forall( otype T ) T _Atomic restrict volatile
    25232522        * ?+=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    25242523        * ?-=?( T _Atomic restrict volatile * restrict volatile *, ptrdiff_t ),
    25252524        * ?+=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25262525        * ?-=?( T _Atomic restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2527 forall( type T ) T const restrict volatile
     2526forall( otype T ) T const restrict volatile
    25282527        * ?+=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    25292528        * ?-=?( T const restrict volatile * restrict volatile *, ptrdiff_t ),
    25302529        * ?+=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t ),
    25312530        * ?-=?( T const restrict volatile * _Atomic restrict volatile *, ptrdiff_t );
    2532 forall( type T ) T _Atomic const restrict volatile
     2531forall( otype T ) T _Atomic const restrict volatile
    25332532        * ?+=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
    25342533        * ?-=?( T _Atomic const restrict volatile * restrict volatile *, ptrdiff_t ),
     
    28422841This 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.
    28432842\begin{lstlisting}
    2844 forall( type T ) struct Pair { T a, b;
     2843forall( otype T ) struct Pair { T a, b;
    28452844} mkPair( T, T ); // illegal
    28462845\end{lstlisting}
     
    28672866If this restriction were lifted, it would be possible to write
    28682867\begin{lstlisting}
    2869 forall( type T ) T * alloc( void );@\use{alloc}@ int *p = alloc();
     2868forall( otype T ) T * alloc( void );@\use{alloc}@ int *p = alloc();
    28702869\end{lstlisting}
    28712870Here \lstinline$alloc()$ would receive \lstinline$int$ as an inferred argument, and return an
     
    28762875\lstinline$T$:
    28772876\begin{lstlisting}
    2878 forall( type T ) T * alloc( T initial_value );@\use{alloc}@
     2877forall( otype T ) T * alloc( T initial_value );@\use{alloc}@
    28792878\end{lstlisting}
    28802879\end{rationale}
     
    28992898\begin{lstlisting}
    29002899int fi( int );
    2901 forall( type T ) T fT( T );
     2900forall( otype T ) T fT( T );
    29022901\end{lstlisting}
    29032902\lstinline$fi()$ takes an \lstinline$int$ and returns an \lstinline$int$. \lstinline$fT()$ takes a
     
    29052904\begin{lstlisting}
    29062905int (*pfi )( int ) = fi;
    2907 forall( type T ) T (*pfT )( T ) = fT;
     2906forall( otype T ) T (*pfT )( T ) = fT;
    29082907\end{lstlisting}
    29092908\lstinline$pfi$ and \lstinline$pfT$ are pointers to functions. \lstinline$pfT$ is not polymorphic, but the function it points at is.
     
    29122911        return pfi;
    29132912}
    2914 forall( type T ) T (*fvpfT( void ))( T ) {
     2913forall( otype T ) T (*fvpfT( void ))( T ) {
    29152914        return pfT;
    29162915}
     
    29182917\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.
    29192918\begin{lstlisting}
    2920 forall( type T ) int ( *fTpfi( T ) )( int );
    2921 forall( type T ) T ( *fTpfT( T ) )( T );
    2922 forall( type T, type U ) U ( *fTpfU( T ) )( U );
     2919forall( otype T ) int ( *fTpfi( T ) )( int );
     2920forall( otype T ) T ( *fTpfT( T ) )( T );
     2921forall( otype T, otype U ) U ( *fTpfU( T ) )( U );
    29232922\end{lstlisting}
    29242923\lstinline$fTpfi()$ is a polymorphic function that returns a pointer to a monomorphic function taking an integer and returning an integer.
     
    29302929\lstinline$char *$.
    29312930\begin{lstlisting}
    2932 forall( type T, type U, type V ) U * f( T *, U, V * const );
    2933 forall( type U, type V, type W ) U * g( V *, U, W * const );
     2931forall( otype T, otype U, otype V ) U * f( T *, U, V * const );
     2932forall( otype U, otype V, otype W ) U * g( V *, U, W * const );
    29342933\end{lstlisting}
    29352934The functions \lstinline$f()$ and \lstinline$g()$ have compatible types.
     
    29392938Replacing every \(f_i\) by \(g_i\) in \(f\) gives
    29402939\begin{lstlisting}
    2941 forall( type V, type U, type W ) U * f( V *, U, W * const );
     2940forall( otype V, otype U, otype W ) U * f( V *, U, W * const );
    29422941\end{lstlisting} which has a return type and parameter list that is compatible with \(g\).
    29432942\begin{rationale}
     
    31273126\examples
    31283127\begin{lstlisting}
    3129 forall( type T | T ?*?( T, T ))@\use{?*?}@
     3128forall( otype T | T ?*?( T, T ))@\use{?*?}@
    31303129T square( T val ) {@\impl{square}@
    31313130        return val + val;
    31323131}
    3133 context summable( type T ) {@\impl{summable}@
     3132trait summable( otype T ) {@\impl{summable}@
    31343133        T ?+=?( T *, T );@\use{?+=?}@
    31353134        const T 0;@\use{0}@
    31363135};
    3137 context list_of( type List, type Element ) {@\impl{list_of}@
     3136trait list_of( otype List, otype Element ) {@\impl{list_of}@
    31383137        Element car( List );
    31393138        List cdr( List );
     
    31423141        int is_nil( List );
    31433142};
    3144 context sum_list( type List, type Element | summable( Element ) | list_of( List, Element ) ) {};
     3143trait sum_list( otype List, otype Element | summable( Element ) | list_of( List, Element ) ) {};
    31453144\end{lstlisting}
    31463145\lstinline$sum_list$ contains seven declarations, which describe a list whose elements can be added up.
     
    32043203Incomplete type declarations allow compact mutually-recursive types.
    32053204\begin{lstlisting}
    3206 type t1; // incomplete type declaration
    3207 type t2 = struct { t1 * p; ... };
    3208 type t1 = struct { t2 * p; ... };
     3205otype t1; // incomplete type declaration
     3206otype t2 = struct { t1 * p; ... };
     3207otype t1 = struct { t2 * p; ... };
    32093208\end{lstlisting}
    32103209Without them, mutual recursion could be handled by declaring mutually recursive structures, then initializing the types to those structures.
    32113210\begin{lstlisting}
    32123211struct s1;
    3213 type t2 = struct s2 { struct s1 * p; ... };
    3214 type t1 = struct s1 { struct s2 * p; ... };
     3212otype t2 = struct s2 { struct s1 * p; ... };
     3213otype t1 = struct s1 { struct s2 * p; ... };
    32153214\end{lstlisting}
    32163215This introduces extra names, and may force the programmer to cast between the types and their implementations.
     
    32673266This prevents the declaration of types that contain each other.
    32683267\begin{lstlisting}
    3269 type t1;
    3270 type t2 = t1; // illegal: incomplete type t1
    3271 type t1 = t2;
     3268otype t1;
     3269otype t2 = t1; // illegal: incomplete type t1
     3270otype t1 = t2;
    32723271\end{lstlisting}
    32733272
     
    32763275 types}.
    32773276\begin{lstlisting}
    3278 extern type Huge; // extended-precision integer type
    3279 type Rational = struct {
     3277extern otype Huge; // extended-precision integer type
     3278otype Rational = struct {
    32803279        Huge numerator, denominator;    // illegal
    32813280};
     
    33163315\begin{lstlisting}
    33173316#include <stdlib.h>
    3318 T * new( type T ) { return ( T * )malloc( sizeof( T) ); };
     3317T * new( otype T ) { return ( T * )malloc( sizeof( T) ); };
    33193318@\ldots@ int * ip = new( int );
    33203319\end{lstlisting}
     
    33273326Since type declarations create new types, instances of types are always passed by value.
    33283327\begin{lstlisting}
    3329 type A1 = int[2];
     3328otype A1 = int[2];
    33303329void f1( A1 a ) { a[0] = 0; };
    3331 typedef int A2[2];
     3330otypedef int A2[2];
    33323331void f2( A2 a ) { a[0] = 0; };
    33333332A1 v1;
     
    33463345That unit might contain the declarations
    33473346\begin{lstlisting}
    3348 type Complex = struct { float re, im; };@\impl{Complex}@
     3347otype Complex = struct { float re, im; };@\impl{Complex}@
    33493348Complex cplx_i = { 0.0, 1.0 };@\impl{cplx_i}@
    33503349float abs( Complex c ) {@\impl{abs( Complex )}@
     
    33553354
    33563355\begin{lstlisting}
    3357 type Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
     3356otype Time_of_day = int;@\impl{Time_of_day}@ // seconds since midnight.
    33583357Time_of_day ?+?( Time_of_day t1, int seconds ) {@\impl{?+?}@
    33593358        return (( int)t1 + seconds ) % 86400;
     
    34293428\examples
    34303429\begin{lstlisting}
    3431 context s( type T ) {
     3430trait s( otype T ) {
    34323431        T a, b;
    34333432} struct impl { int left, right; } a = { 0, 0 };
    3434 type Pair | s( Pair ) = struct impl;
     3433otype Pair | s( Pair ) = struct impl;
    34353434Pair b = { 1, 1 };
    34363435\end{lstlisting}
     
    34403439\lstinline$Pair b$ is compulsory because there is no \lstinline$struct impl b$ to construct a value from.
    34413440\begin{lstlisting}
    3442 context ss( type T ) {
     3441trait ss( otype T ) {
    34433442        T clone( T );
    34443443        void munge( T * );
    34453444}
    3446 type Whatsit | ss( Whatsit );@\use{Whatsit}@
    3447 type Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
     3445otype Whatsit | ss( Whatsit );@\use{Whatsit}@
     3446otype Doodad | ss( Doodad ) = struct doodad {@\use{Doodad}@
    34483447        Whatsit; // anonymous member
    34493448        int extra;
     
    34663465Default functions and objects are subject to the normal scope rules.
    34673466\begin{lstlisting}
    3468 type T = @\ldots@;
     3467otype T = @\ldots@;
    34693468T a_T = @\ldots@;               // Default assignment used.
    34703469T ?=?( T *, T );
     
    37353734The assertion ``\lstinline$scalar( Complex )$'' should be read as ``type \lstinline$Complex$ is scalar''.
    37363735\begin{lstlisting}
    3737 context scalar( type T ) {@\impl{scalar}@
     3736trait scalar( otype T ) {@\impl{scalar}@
    37383737        int !?( T );
    37393738        int ?<?( T, T ), ?<=?( T, T ), ?==?( T, T ), ?>=?( T, T ), ?>?( T, T ), ?!=?( T, T );
     
    37453744This is equivalent to inheritance of specifications.
    37463745\begin{lstlisting}
    3747 context arithmetic( type T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
     3746trait arithmetic( otype T | scalar( T ) ) {@\impl{arithmetic}@@\use{scalar}@
    37483747        T +?( T ), -?( T );
    37493748        T ?*?( T, T ), ?/?( T, T ), ?+?( T, T ), ?-?( T, T );
     
    37543753\define{integral types}.
    37553754\begin{lstlisting}
    3756 context integral( type T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
     3755trait integral( otype T | arithmetic( T ) ) {@\impl{integral}@@\use{arithmetic}@
    37573756        T ~?( T );
    37583757        T ?&?( T, T ), ?|?( T, T ), ?^?( T, T );
     
    37683767The only operation that can be applied to all modifiable lvalues is simple assignment.
    37693768\begin{lstlisting}
    3770 context m_lvalue( type T ) {@\impl{m_lvalue}@
     3769trait m_lvalue( otype T ) {@\impl{m_lvalue}@
    37713770        T ?=?( T *, T );
    37723771};
     
    37783777Scalars can also be incremented and decremented.
    37793778\begin{lstlisting}
    3780 context m_l_scalar( type T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
     3779trait m_l_scalar( otype T | scalar( T ) | m_lvalue( T ) ) {@\impl{m_l_scalar}@
    37813780        T ?++( T * ), ?--( T * );@\use{scalar}@@\use{m_lvalue}@
    37823781        T ++?( T * ), --?( T * );
     
    37873786Note that this results in the ``inheritance'' of \lstinline$scalar$ along both paths.
    37883787\begin{lstlisting}
    3789 context m_l_arithmetic( type T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
     3788trait m_l_arithmetic( otype T | m_l_scalar( T ) | arithmetic( T ) ) {@\impl{m_l_arithmetic}@
    37903789        T ?/=?( T *, T ), ?*=?( T *, T );@\use{m_l_scalar}@@\use{arithmetic}@
    37913790        T ?+=?( T *, T ), ?-=?( T *, T );
    37923791};
    3793 context m_l_integral( type T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
     3792trait m_l_integral( otype T | m_l_arithmetic( T ) | integral( T ) ) {@\impl{m_l_integral}@
    37943793        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );@\use{m_l_arithmetic}@
    37953794        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );@\use{integral}@
     
    38113810\lstinline$arithmetic$, so these operators cannot be consolidated in \lstinline$scalar$.
    38123811\begin{lstlisting}
    3813 context pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
     3812trait pointer( type P | scalar( P ) ) {@\impl{pointer}@@\use{scalar}@
    38143813        P ?+?( P, long int ), ?+?( long int, P ), ?-?( P, long int );
    38153814        ptrdiff_t ?-?( P, P );
    38163815};
    3817 context m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
     3816trait m_l_pointer( type P | pointer( P ) | m_l_scalar( P ) ) {@\impl{m_l_pointer}@
    38183817        P ?+=?( P *, long int ), ?-=?( P *, long int );
    38193818        P ?=?( P *, void * );
     
    38273826``\lstinline$Safe_pointer$ acts like a pointer to \lstinline$int$''.
    38283827\begin{lstlisting}
    3829 context ptr_to( type P | pointer( P ), type T ) {@\impl{ptr_to}@@\use{pointer}@
     3828trait ptr_to( type P | pointer( P ), otype T ) {@\impl{ptr_to}@@\use{pointer}@
    38303829        lvalue T *?( P );
    38313830        lvalue T ?[?]( P, long int );
    38323831};
    3833 context ptr_to_const( type P | pointer( P ), type T ) {@\impl{ptr_to_const}@
     3832trait ptr_to_const( type P | pointer( P ), otype T ) {@\impl{ptr_to_const}@
    38343833        const lvalue T *?( P );
    38353834        const lvalue T ?[?]( P, long int );@\use{pointer}@
    38363835};
    3837 context ptr_to_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_volatile}@
     3836trait ptr_to_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_volatile}@
    38383837        volatile lvalue T *?( P );
    38393838        volatile lvalue T ?[?]( P, long int );@\use{pointer}@
    38403839};
    3841 context ptr_to_const_volatile( type P | pointer( P ), type T ) }@\impl{ptr_to_const_volatile}@
     3840trait ptr_to_const_volatile( type P | pointer( P ), otype T ) }@\impl{ptr_to_const_volatile}@
    38423841        const volatile lvalue T *?( P );@\use{pointer}@
    38433842        const volatile lvalue T ?[?]( P, long int );
     
    38493848``\lstinline$ptr_to$'' specifications.
    38503849\begin{lstlisting}
    3851 context 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}@ {
     3850trait 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}@ {
    38523851        P ?=?( P *, T * );
    38533852        T * ?=?( T **, P );
    38543853};
    3855 context 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}@) {
     3854trait 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}@) {
    38563855        P ?=?( P *, const T * );
    38573856        const T * ?=?( const T **, P );
    38583857};
    3859 context 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}@
     3858trait 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}@
    38603859        P ?=?( P *, volatile T * );
    38613860        volatile T * ?=?( volatile T **, P );
    38623861};
    3863 context 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}@
     3862trait 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}@
    38643863                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}@
    38653864        P ?=?( P *, const volatile T * );
     
    38713870An 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.
    38723871\begin{lstlisting}
    3873 context 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 ) ) {
     3872trait 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 ) ) {
    38743873        MyP ?=?( MyP *, CP );
    38753874        CP ?=?( CP *, MyP );
     
    39043903C and \CFA have an extra, non-obvious comparison operator: ``\lstinline$!$'', logical negation, returns 1 if its operand compares equal to 0, and 0 otherwise.
    39053904\begin{lstlisting}
    3906 context comparable( type T ) {
     3905trait comparable( otype T ) {
    39073906        const T 0;
    39083907        int compare( T, T );
    39093908}
    3910 forall( type T | comparable( T ) ) int ?<?( T l, T r ) {
     3909forall( otype T | comparable( T ) ) int ?<?( T l, T r ) {
    39113910        return compare( l, r ) < 0;
    39123911}
    39133912// ... similarly for <=, ==, >=, >, and !=.
    3914 forall( type T | comparable( T ) ) int !?( T operand ) {
     3913forall( otype T | comparable( T ) ) int !?( T operand ) {
    39153914        return !compare( operand, 0 );
    39163915}
     
    39243923Similarly, a complete integral type would provide integral operations based on integral assignment operations.
    39253924\begin{lstlisting}
    3926 context arith_base( type T ) {
     3925trait arith_base( otype T ) {
    39273926        const T 1;
    39283927        T ?+=?( T *, T ), ?-=?( T *, T ), ?*=?( T *, T ), ?/=?( T *, T );
    39293928}
    3930 forall( type T | arith_base( T ) ) T ?+?( T l, T r ) {
     3929forall( otype T | arith_base( T ) ) T ?+?( T l, T r ) {
    39313930        return l += r;
    39323931}
    3933 forall( type T | arith_base( T ) ) T ?++( T * operand ) {
     3932forall( otype T | arith_base( T ) ) T ?++( T * operand ) {
    39343933        T temporary = *operand;
    39353934        *operand += 1;
    39363935        return temporary;
    39373936}
    3938 forall( type T | arith_base( T ) ) T ++?( T * operand ) {
     3937forall( otype T | arith_base( T ) ) T ++?( T * operand ) {
    39393938        return *operand += 1;
    39403939}
    39413940// ... similarly for -, --, *, and /.
    3942 context int_base( type T ) {
     3941trait int_base( otype T ) {
    39433942        T ?&=?( T *, T ), ?|=?( T *, T ), ?^=?( T *, T );
    39443943        T ?%=?( T *, T ), ?<<=?( T *, T ), ?>>=?( T *, T );
    39453944}
    3946 forall( type T | int_base( T ) ) T ?&?( T l, T r ) {
     3945forall( otype T | int_base( T ) ) T ?&?( T l, T r ) {
    39473946        return l &= r;
    39483947}
  • src/examples/fstream_test.c

    rbed4c63e rae357ec  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 15:12:21 2016
    13 // Update Count     : 51
     12// Last Modified On : Sun Mar  6 20:58:29 2016
     13// Update Count     : 54
    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

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

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

    rbed4c63e rae357ec  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 21 13:54:09 2015
    13 // Update Count     : 322
     12// Last Modified On : Wed Mar  2 23:28:02 2016
     13// Update Count     : 328
    1414//
    1515
     
    4343#include <ctype.h>
    4444#include <curses.h>
    45 #include <demangle.h>           // enum / contains "type"
    46 #include <dialog.h>                     // enum / contains "type"
     45#include <demangle.h>
     46#include <dialog.h>
    4747#include <dirent.h>
    4848#include <dis-asm.h>
     
    5656#include <err.h>
    5757#include <errno.h>
     58#if 0
    5859#include <error.h>
     60#endif
     61#include <eti.h>
     62#include <evdns.h>
     63#include <event.h>
     64#include <evhttp.h>
    5965#if 0
    60 #include <eti.h>
    61 #include <evdns.h>                      // subdirectory event2 contains "type"
    62 #include <event.h>
    63 #include <evhttp.h>                     // enum / subdirectory event2 contains "type"
    6466#include <evrpc.h>
    6567#include <evutil.h>
    6668#include <execinfo.h>
    67 #include <expat.h>                      // enum / contains "type" and "context"
     69#include <expat.h>
    6870#include <expat_config.h>
    6971#include <expat_external.h>
     
    7476#include <fmtmsg.h>
    7577#include <fnmatch.h>
    76 #include <form.h>                       // contains "type"
     78#include <form.h>
    7779#include <fpu_control.h>
    7880#include <fstab.h>
     
    8183#include <ftw.h>
    8284#include <gconv.h>
    83 //#include <gcrypt.h>           // enum / contains "type"
     85//#include <gcrypt.h>
    8486//#include <gcrypt-module.h>
    8587#include <getopt.h>
     
    107109#include <limits.h>
    108110#include <locale.h>
    109 #include <math.h>                       // contains "type"
     111#include <math.h>
    110112#include <ncurses.h>
    111113#include <setjmp.h>
  • src/examples/it_out.c

    rbed4c63e rae357ec  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:11:00 2016
    13 // Update Count     : 5
     12// Last Modified On : Tue Mar  8 22:14:39 2016
     13// Update Count     : 8
    1414//
    1515
     
    2121};
    2222
    23 trait writeable( type T ) {
     23trait writeable( otype T ) {
    2424        forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
    2525};
     
    3636};
    3737
    38 trait readable( type T ) {
     38trait readable( otype 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( type iterator_type, type elt_type ) {
     45trait iterator( otype iterator_type, otype elt_type ) {
    4646        iterator_type ?++( iterator_type* );
    4747        iterator_type ++?( iterator_type* );
     
    5252};
    5353
    54 forall( type elt_type | writeable( elt_type ),
    55                 type iterator_type | iterator( iterator_type, elt_type ),
     54forall( otype elt_type | writeable( elt_type ),
     55                otype 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( type elt_type | writeable( elt_type ),
    60                 type iterator_type | iterator( iterator_type, elt_type ),
     59forall( otype elt_type | writeable( elt_type ),
     60                otype 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

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

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

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

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

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

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

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

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

    rbed4c63e rae357ec  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 17 12:23:25 2016
    13 // Update Count     : 13
     12// Last Modified On : Tue Mar  8 22:04:58 2016
     13// Update Count     : 16
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
     18forall( otype 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

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

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

    rbed4c63e rae357ec  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:06:35 2016
    13 // Update Count     : 208
     12// Last Modified On : Mon Mar  7 13:51:23 2016
     13// Update Count     : 227
    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
    135148        int len = strlen( cp );
    136149        // null string => no separator
    137150  if ( len == 0 ) { sepOff( os ); return os; }
    138         // first character NOT spacing or special punctuation => add left separator
    139         if ( sepPrt( os ) && isspace( cp[0] ) == 0 && cp[0] != '.' && cp[0] != ',' ) {
     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 ) {
    140153                prtfmt( os, "%s", sepGet( os ) );
    141154        } // if
    142         // last character is spacing or special punctuation => turn off separator for next item
     155        // last character IS spacing or opening punctuation => turn off separator for next item
    143156        unsigned int posn = len - 1;
    144         if ( isspace( cp[posn] ) || cp[posn] == ':' || cp[posn] == '$' ) {
     157        if ( isspace( cp[posn] ) || mask[ cp[posn] ] == Open || mask[ cp[posn] ] == OpenClose ) {
    145158                sepOff( os );
    146159        } else {
Note: See TracChangeset for help on using the changeset viewer.