Ignore:
Timestamp:
Mar 10, 2024, 11:21:18 AM (7 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
9398177
Parents:
b64d0f4
Message:

more switch to tabs

Location:
doc/theses/mike_brooks_MMath/programs
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal-matmul.cfa

    rb64d0f4 r5546f50b  
    44forall( [M], [N], [P] )
    55void matmul( array(float, M, P) & src1,
    6             array(float, P, N) & src2,
    7             array(float, M, N) & tgt ) {
    8     for (i; M) for (j; N) {
    9         tgt[i][j] = 0;
    10         for (k; P)
    11             tgt[i][j] += src1[i][k] * src2[k][j];
    12     }
     6                        array(float, P, N) & src2,
     7                        array(float, M, N) & tgt ) {
     8        for (i; M) for (j; N) {
     9                tgt[i][j] = 0;
     10                for (k; P)
     11                        tgt[i][j] += src1[i][k] * src2[k][j];
     12        }
    1313}
  • doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal-stdvec.cpp

    rb64d0f4 r5546f50b  
    33forall( [M], [N], [P] )
    44void matmul( array(float, M, P) & src1,
    5             array(float, P, N) & src2,
    6             array(float, M, N) & tgt ) {
    7     for (i; M) for (j; N) {
    8         tgt[i][j] = 0;
    9         for (k; P)
    10             tgt[i][j] += src1[i][k] * src2[k][j];
    11     }
     5                        array(float, P, N) & src2,
     6                        array(float, M, N) & tgt ) {
     7        for (i; M) for (j; N) {
     8                tgt[i][j] = 0;
     9                for (k; P)
     10                        tgt[i][j] += src1[i][k] * src2[k][j];
     11        }
    1212}
    1313*/
     
    3030
    3131float f( vector<float> & a ) {
    32     float result = 0;
    33     for( int i = 0; i < BOUND(a.size()); i++ ) {
    34         result += a.at(i);
    35         // hillarious that, while writing THIS VERY DEMO, on first go, I actaully wrote it a[i]
    36     }
    37     return result;
     32        float result = 0;
     33        for( int i = 0; i < BOUND(a.size()); i++ ) {
     34                result += a.at(i);
     35                // hillarious that, while writing THIS VERY DEMO, on first go, I actaully wrote it a[i]
     36        }
     37        return result;
    3838}
    3939
     
    4141#include <iostream>
    4242int main( int argc, char ** argv ) {
    43     vector<float> v(5);
    44     v.at(0) = 3.14;
    45     v.at(1) = 3.14;
    46     v.at(2) = 3.14;
    47     v.at(3) = 3.14;
    48     v.at(4) = 3.14;
     43        vector<float> v(5);
     44        v.at(0) = 3.14;
     45        v.at(1) = 3.14;
     46        v.at(2) = 3.14;
     47        v.at(3) = 3.14;
     48        v.at(4) = 3.14;
    4949
    50     float answer = f(v);
     50        float answer = f(v);
    5151
    52     cout << "answer: " << answer << endl;
     52        cout << "answer: " << answer << endl;
    5353
    5454}
     
    8080
    8181void matmul( mat & a, mat & b, mat & rslt ) {
    82     size_t m = rslt.size();
    83     assert( m == a.size() );
    84     size_t p = b.size();
    85     for ( int i = 0; i < BOUND(m); i++ ) {
    86         assert( p == a.at(i).size() );
    87         size_t n = rslt.at(i).size();
    88         for ( int j = 0; j < BOUND(n); j++ ) {
    89             rslt.at(i).at(j) = 0.0;
    90             for ( int k = 0; k < BOUND(p); k++ ) {
    91                 assert(b.at(k).size() == n); // asking to check it too often
    92                 rslt.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j);
    93             }
    94         }
    95     }
     82        size_t m = rslt.size();
     83        assert( m == a.size() );
     84        size_t p = b.size();
     85        for ( int i = 0; i < BOUND(m); i++ ) {
     86                assert( p == a.at(i).size() );
     87                size_t n = rslt.at(i).size();
     88                for ( int j = 0; j < BOUND(n); j++ ) {
     89                        rslt.at(i).at(j) = 0.0;
     90                        for ( int k = 0; k < BOUND(p); k++ ) {
     91                                assert(b.at(k).size() == n); // asking to check it too often
     92                                rslt.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j);
     93                        }
     94                }
     95        }
    9696}
    9797
     
    9999#include <iostream>
    100100int main( int argc, char ** argv ) {
    101     mat a(5, vector<float>(6));
    102     mat b(6, vector<float>(7));
    103     mat r(5, vector<float>(7));
    104     matmul(a, b, r);
     101        mat a(5, vector<float>(6));
     102        mat b(6, vector<float>(7));
     103        mat r(5, vector<float>(7));
     104        matmul(a, b, r);
    105105}
    106106#endif
  • doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal.cfa

    rb64d0f4 r5546f50b  
    99forall( [N] )
    1010size_t foo( array( size_t, N ) & a ) {
    11     size_t retval = 0;
    12     for( i; N ) {
    13         retval += a[i];
    14     }
    15     return retval;
     11        size_t retval = 0;
     12        for( i; N ) {
     13                retval += a[i];
     14        }
     15        return retval;
    1616}
    1717
     
    2020forall( [N], [M] )
    2121size_t foo( array( size_t, N, M ) & a ) {
    22     size_t retval = 0;
    23     for( i; N ) for( j; M ) {
    24         retval += a[i][j];
    25     }
    26     return retval;
     22        size_t retval = 0;
     23        for( i; N ) for( j; M ) {
     24                retval += a[i][j];
     25        }
     26        return retval;
    2727}
    2828
     
    3131forall( [N] )
    3232size_t foo( array( size_t, N ) & a, array( size_t, N ) & b ) {
    33     size_t retval = 0;
    34     for( i; N ) {
    35         retval += a[i] - b[i];
    36     }
    37     return retval;
     33        size_t retval = 0;
     34        for( i; N ) {
     35                retval += a[i] - b[i];
     36        }
     37        return retval;
    3838}
    3939
     
    4242forall( [M], [N], [P] )
    4343void foo   ( array(size_t, M, P) & src1,
    44             array(size_t, P, N) & src2,
    45             array(size_t, M, N) & tgt ) {
    46     for (i; M) for (j; N) {
    47         tgt[i][j] = 0;
    48         for (k; P)
    49             tgt[i][j] += src1[i][k] * src2[k][j];
    50     }
     44                        array(size_t, P, N) & src2,
     45                        array(size_t, M, N) & tgt ) {
     46        for (i; M) for (j; N) {
     47                tgt[i][j] = 0;
     48                for (k; P)
     49                        tgt[i][j] += src1[i][k] * src2[k][j];
     50        }
    5151}
    5252
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-arrty.c

    rb64d0f4 r5546f50b  
    150150
    151151// Local Variables: //
    152 // compile-command: "sed -f sedcmd bkgd-carray-arrty.c > tmp.c; gcc tmp.c" //
     152// compile-command: "sed -f sedcmd bkgd-carray-arrty.c | gcc -c -x c -" //
    153153// End: //
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-decay.c

    rb64d0f4 r5546f50b  
    1818        // reusing local var `float a[10];`}
    1919        float v;
    20         f(  a,  a ); $\C{// ok: two decays, one into an array spelling}$
    21         f( &v, &v ); $\C{// ok: no decays; a non-array passes to an array spelling}$
     20        f( a, a );                                      $\C{// ok: two decays, one into an array spelling}$
     21        f( &v, &v );                            $\C{// ok: no decays; a non-array passes to an array spelling}$
    2222
    23         char ca[] = "hello";    $\C{// array on stack, initialized from read-only data}$
    24         char *cp = "hello";     $\C{// pointer to read-only data [decay here]}$
    25         void edit(char c[]) {   $\C{// param is pointer}$
     23        char ca[] = "hello";            $\C{// array on stack, initialized from read-only data}$
     24        char *cp = "hello";                     $\C{// pointer to read-only data [decay here]}$
     25        void edit( char c[] ) {         $\C{// param is pointer}$
    2626                c[3] = 'p';
    2727        }
    28         edit(ca);               $\C{// ok [decay here]}$
    29         edit(cp);               $\C{// Segmentation fault}$
    30         edit("hello");          $\C{// Segmentation fault [decay here]}$
     28        edit( ca );                                     $\C{// ok [decay here]}$
     29        edit( c p );                            $\C{// Segmentation fault}$
     30        edit( "hello" );                        $\C{// Segmentation fault [decay here]}$
    3131
    3232        void decay( float x[10] ) {
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-mdim.c

    rb64d0f4 r5546f50b  
    1414
    1515int main() {
     16        float a[3][10];
     17        static_assert(sizeof(float)==4);                        $\C{// floats (atomic elements) are 4 bytes}$
     18        static_assert(sizeof(void*)==8);                        $\C{// pointers are 8 bytes}$
    1619
    17 /*
    18 As in the last section, we inspect the declaration ...
    19 */
    20     float a[3][10];
    21 /*
     20        static_assert(sizeof( a ) == 120);                      $\C{// the array, float[3][10]}$
     21        static_assert(sizeof( a[0] ) == 40);            $\C{// its first element, float[10]}$
     22        static_assert(sizeof( a[0][0] ) == 4 );         $\C{// its first grand element, float}$
    2223
    23 */
    24     static_assert(sizeof(float)==4);    // floats (atomic elements) are 4 bytes
    25     static_assert(sizeof(void*)==8);    // pointers are 8 bytes
    26 /*
     24        static_assert(sizeof(&(a)) == 8);                       $\C{// pointer to the array, float(*)[3][10]}$
     25        static_assert(sizeof(&(a[0])) == 8  );          $\C{// pointer to its first element, float(*)[10]}$
     26        static_assert(sizeof(&(a[0][0])) == 8  );       $\C{// pointer to its first grand-element, float*}$
    2727
    28 The significant axis of deriving expressions from @a@ is now ``itself,'' ``first element'' or ``first grand-element (meaning, first element of first element).''
    29 */
    30     static_assert(sizeof(  a       ) == 120); // the array, float[3][10]
    31     static_assert(sizeof(  a[0]    ) == 40 ); // its first element, float[10]
    32     static_assert(sizeof(  a[0][0] ) == 4  ); // its first grand element, float
     28        float (*pa  )[3][10] = &(a        );
     29        float (*pa0 )   [10] = &(a[0]   );
     30        float  *pa00             = &(a[0][0]);
    3331
    34     static_assert(sizeof(&(a      )) == 8  ); // pointer to the array, float(*)[3][10]
    35     static_assert(sizeof(&(a[0]   )) == 8  ); // pointer to its first element, float(*)[10]
    36     static_assert(sizeof(&(a[0][0])) == 8  ); // pointer to its first grand-element, float*
     32        static_assert((void*)&a == (void*)&(a[0]   ));
     33        static_assert((void*)&a == (void*)&(a[0][0]));
    3734
    38     float (*pa  )[3][10] = &(a      );
    39     float (*pa0 )   [10] = &(a[0]   );
    40     float  *pa00         = &(a[0][0]);
     35        assert( (void *) pa == (void *) pa0  );
     36        assert( (void *) pa == (void *) pa00 );
    4137
    42     static_assert((void*)&a == (void*)&(a[0]   ));
    43     static_assert((void*)&a == (void*)&(a[0][0]));
    44 
    45     assert( (void *) pa == (void *) pa0  );
    46     assert( (void *) pa == (void *) pa00 );
    47 
    48 //    float (*b[3])[10];
    49     float *b[3];
    50     for (int i = 0; i < 3; i ++) {
    51         b[i] = malloc(sizeof(float[10]));
    52     }
    53     a[2][3];
    54     b[2][3];
     38//      float (*b[3])[10];
     39        float *b[3];
     40        for (int i = 0; i < 3; i ++) {
     41                b[i] = malloc(sizeof(float[10]));
     42        }
     43        a[2][3];
     44        b[2][3];
    5545/*
    5646
  • doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa

    rb64d0f4 r5546f50b  
    1111forall( T, [Nclients], [Ncosts] )
    1212struct request {
    13     unsigned int requestor_id;
    14     array( T, Nclients ) impacted_client_ids; // nested VLA
    15     array( float, Ncosts ) cost_contribs; // nested VLA
    16     float total_cost;
     13        unsigned int requestor_id;
     14        array( T, Nclients ) impacted_client_ids; // nested VLA
     15        array( float, Ncosts ) cost_contribs; // nested VLA
     16        float total_cost;
    1717};
    1818
     
    4141forall( T, [Nclients], [Ncosts] )
    4242void summarize( request( T, Nclients, Ncosts ) & r ) {
    43     r.total_cost = 0;
    44     for( i; Ncosts )
    45         r.total_cost += r.cost_contribs[i];
    46     // say the cost is per-client, to make output vary
    47     r.total_cost *= Nclients;
     43        r.total_cost = 0;
     44        for( i; Ncosts )
     45                r.total_cost += r.cost_contribs[i];
     46        // say the cost is per-client, to make output vary
     47        r.total_cost *= Nclients;
    4848}
    4949
  • doc/theses/mike_brooks_MMath/programs/hello-array.cfa

    rb64d0f4 r5546f50b  
    1010forall( [N] ) // array bound
    1111array(bool, N) & f( array(float, N) & a, array(float, N) & b ) {
    12     array(bool, N) & ret = *alloc(); // sizeof used by alloc
    13     for( i; N ) {
    14         ret[i] = 0.005 > 2 * (abs(a[i] - b[i])) / (abs(a[i]) + abs(b[i]));
    15     }
    16     return ret;
     12        array(bool, N) & ret = *alloc(); // sizeof used by alloc
     13        for( i; N ) {
     14                ret[i] = 0.005 > 2 * (abs(a[i] - b[i])) / (abs(a[i]) + abs(b[i]));
     15        }
     16        return ret;
    1717}
    1818
     
    2929
    3030int main( int argc, char * argv[] ) {
    31     int n = ato( argv[1] );
    32     array(float, n) a, b; // VLA
    33     for ( i; n ) {
    34         a[i] = 3.14 / (i + 1);
    35         b[i] = a[i] + 0.005 ;
    36     }
    37     array(bool, n) & result = f( a, b ); // call
    38     sout | "result: " | nonl;
    39     for ( i; n )
    40         sout | result[i] | nonl;
    41     sout | nl;
    42     free( &result ); // free returned storage
     31        int n = ato( argv[1] );
     32        array(float, n) a, b; // VLA
     33        for ( i; n ) {
     34                a[i] = 3.14 / (i + 1);
     35                b[i] = a[i] + 0.005 ;
     36        }
     37        array(bool, n) & result = f( a, b ); // call
     38        sout | "result: " | nonl;
     39        for ( i; n )
     40                sout | result[i] | nonl;
     41        sout | nl;
     42        free( &result ); // free returned storage
    4343}
    4444/*
     
    5252        array(float, 10) a;
    5353        array(float, 20) b;
    54     f( a, a );
    55     f( b, b );
    56     f( a, b );
     54        f( a, a );
     55        f( b, b );
     56        f( a, b );
    5757}
    5858
     
    6060forall( [M], [N] )
    6161void bad( array(float, M) &a, array(float, N) &b ) {
    62     f( a, a ); // ok
    63     f( b, b ); // ok
    64     f( a, b ); // error
     62        f( a, a ); // ok
     63        f( b, b ); // ok
     64        f( a, b ); // error
    6565}
    6666#endif
     
    7070forall( [M], [N] )
    7171void bad_fixed( array(float, M) & a, array(float, N) & b ) {
    72     if ( M == N ) {
    73         f( a, (array(float, M) &)b ); // cast b to matching type
    74     }
     72        if ( M == N ) {
     73                f( a, (array(float, M) &)b ); // cast b to matching type
     74        }
    7575}
  • doc/theses/mike_brooks_MMath/programs/hello-md.cfa

    rb64d0f4 r5546f50b  
    6060forall( [N] )
    6161void print1d_cstyle( array(float, N) & c ) {
    62     for ( i; N ) {
    63         sout | c[i] | nonl;
    64     }
    65     sout | nl;
     62        for ( i; N ) {
     63                sout | c[i] | nonl;
     64        }
     65        sout | nl;
    6666}
    6767
     
    7979forall( [N], C & | ar( C, float, N ) )
    8080void print1d( C & c ) {
    81     for( i; N ) {
    82         sout | c[i] | nonl;
    83     }
    84     sout | nl;
     81        for( i; N ) {
     82                sout | c[i] | nonl;
     83        }
     84        sout | nl;
    8585}
    8686
     
    9999
    100100void fill( array(float, 5, 7) & a ) {
    101     for ( i; (ptrdiff_t) 5 ) {
    102         for ( j; 7 ) {
    103             a[i,j] = 1.0 * i + 0.1 * j;
    104             sout | a[[i,j]] | nonl;
    105         }
    106         sout | nl;
    107     }
    108     sout | nl;
     101        for ( i; (ptrdiff_t) 5 ) {
     102                for ( j; 7 ) {
     103                        a[i,j] = 1.0 * i + 0.1 * j;
     104                        sout | a[[i,j]] | nonl;
     105                }
     106                sout | nl;
     107        }
     108        sout | nl;
    109109}
    110110
     
    1251254.0  4.1  4.2  4.3  4.4  4.5  4.6
    126126*/
    127    
     127
    128128
    129129
  • doc/theses/mike_brooks_MMath/programs/lst-features-intro.run.cfa

    rb64d0f4 r5546f50b  
    1919
    2020struct req {
    21   int pri, rqr;
    22   inline dlink(req);
     21        int pri, rqr;
     22        inline dlink(req);
    2323};
    2424
     
    2626
    2727req
    28   r1 = {1, 42},
    29   r2 = {2, 42};
     28        r1 = {1, 42},
     29        r2 = {2, 42};
    3030
    3131insert_first(reqs, r2);
     
    5151
    5252while( req & cur = reqs`elems; cur`moveNext )
    53     printf("{%d %d} ", cur.pri, cur.rqr);
     53        printf("{%d %d} ", cur.pri, cur.rqr);
    5454printf("\n");
    5555
  • doc/theses/mike_brooks_MMath/programs/lst-features-multidir.run.cfa

    rb64d0f4 r5546f50b  
    1919
    2020struct req {
    21   int pri, rqr;
    22   inline struct by_pri { inline dlink(req); };
    23   inline struct by_rqr { inline dlink(req); };
     21        int pri, rqr;
     22        inline struct by_pri { inline dlink(req); };
     23        inline struct by_rqr { inline dlink(req); };
    2424};
    2525
     
    4444
    4545struct req
    46   r42a = {1, 42},
    47   r42b = {2, 42},
    48   r17a = {2, 17},
    49   r17b = {3, 17},
    50   r17c = {4, 17},
    51   r99a = {3, 99};
     46        r42a = {1, 42},
     47        r42b = {2, 42},
     48        r17a = {2, 17},
     49        r17b = {3, 17},
     50        r17c = {4, 17},
     51        r99a = {3, 99};
    5252
    5353insert_first(reqs_pri_global, r17c);
     
    7575
    7676with(DLINK_VIA(req, req.by_pri)) {
    77     while( req & cur = reqs_pri_global`elems; cur`moveNext )
    78         printf("{%d %d} ", cur.pri, cur.rqr);
    79     printf("| ");
     77        while( req & cur = reqs_pri_global`elems; cur`moveNext )
     78                printf("{%d %d} ", cur.pri, cur.rqr);
     79        printf("| ");
    8080}
    8181
    8282with(DLINK_VIA(req, req.by_rqr)) {
    83     while( req & cur = reqs_rqr_42`elems; cur`moveNext )
    84         printf("{%d %d} ", cur.pri, cur.rqr);
    85     printf("| ");
    86     while( req & cur = reqs_rqr_17`elems; cur`moveNext )
    87         printf("{%d %d} ", cur.pri, cur.rqr);
    88     printf("| ");
    89     while( req & cur = reqs_rqr_99`elems; cur`moveNext )
    90         printf("{%d %d} ", cur.pri, cur.rqr);
    91     printf("\n");
     83        while( req & cur = reqs_rqr_42`elems; cur`moveNext )
     84                printf("{%d %d} ", cur.pri, cur.rqr);
     85        printf("| ");
     86        while( req & cur = reqs_rqr_17`elems; cur`moveNext )
     87                printf("{%d %d} ", cur.pri, cur.rqr);
     88        printf("| ");
     89        while( req & cur = reqs_rqr_99`elems; cur`moveNext )
     90                printf("{%d %d} ", cur.pri, cur.rqr);
     91        printf("\n");
    9292}
    9393
  • doc/theses/mike_brooks_MMath/programs/lst-issues-attach-reduction.hpp

    rb64d0f4 r5546f50b  
    100100template<typename El>
    101101class list {
    102     struct node {
    103         LIST_ENTRY(node) links;
    104         El elem;
    105     };
    106     LIST_HEAD(Impl, node);
    107     Impl impl;
     102        struct node {
     103                LIST_ENTRY(node) links;
     104                El elem;
     105        };
     106        LIST_HEAD(Impl, node);
     107        Impl impl;
    108108  public:
    109     list() {
    110         LIST_INIT(&impl);
    111     }
    112     void push_front( const El & src ) {
    113         node * n = new node();
    114         n->elem = src;
    115         LIST_INSERT_HEAD(&impl, n, links);
    116     }
    117     // ... `emplace` elided
     109        list() {
     110                LIST_INIT(&impl);
     111        }
     112        void push_front( const El & src ) {
     113                node * n = new node();
     114                n->elem = src;
     115                LIST_INSERT_HEAD(&impl, n, links);
     116        }
     117        // ... `emplace` elided
    118118
    119119
     
    129129
    130130
    131     template<typename... CtorArgs>
    132     void emplace_front( CtorArgs... args ) { 
    133         El tempEl{args...}; // (mock: avoid real emplacing to keep `struct node` simple; disucssion is about allocation, not copying)
    134         push_front(tempEl);
    135     }
    136     class IType {
    137         node* p;
    138       public:
    139         IType(node* p) : p(p) {}
    140         bool operator!=(IType rhs) {return p != rhs.p;}
    141         const El& operator*() {return p->elem;}
    142         void operator++() { p = LIST_NEXT(p, links); }
    143     };
    144     IType begin() {return IType(LIST_FIRST(&impl)); }
    145     IType end() {return IType(NULL); }
     131        template<typename... CtorArgs>
     132        void emplace_front( CtorArgs... args ) { 
     133                El tempEl{args...}; // (mock: avoid real emplacing to keep `struct node` simple; disucssion is about allocation, not copying)
     134                push_front(tempEl);
     135        }
     136        class IType {
     137                node* p;
     138          public:
     139                IType(node* p) : p(p) {}
     140                bool operator!=(IType rhs) {return p != rhs.p;}
     141                const El& operator*() {return p->elem;}
     142                void operator++() { p = LIST_NEXT(p, links); }
     143        };
     144        IType begin() {return IType(LIST_FIRST(&impl)); }
     145        IType end() {return IType(NULL); }
    146146
    147147
  • doc/theses/mike_brooks_MMath/programs/lst-issues-intrusive.run.c

    rb64d0f4 r5546f50b  
    2121
    2222struct req {
    23   int pri, rqr;
    24   LIST_ENTRY(req) x;
     23        int pri, rqr;
     24        LIST_ENTRY(req) x;
    2525};
    2626
     
    3131
    3232struct req
    33   r1 = {1, 42},
    34   r2 = {2, 42};
     33        r1 = {1, 42},
     34        r2 = {2, 42};
    3535
    3636LIST_INSERT_HEAD(
    37   &reqs, &r2, x);
     37        &reqs, &r2, x);
    3838LIST_INSERT_HEAD(
    39   &reqs, &r1, x);
     39        &reqs, &r1, x);
    4040
    4141
     
    5151struct req *cur;
    5252LIST_FOREACH(cur, &reqs, x)
    53     printf("{%d %d} ", cur->pri, cur->rqr);
     53        printf("{%d %d} ", cur->pri, cur->rqr);
    5454printf("\n");
    5555
  • doc/theses/mike_brooks_MMath/programs/lst-issues-multi-static.run.c

    rb64d0f4 r5546f50b  
    1919
    2020struct req {
    21   int pri, rqr;
    22   LIST_ENTRY(req) by_pri;
    23   LIST_ENTRY(req) by_rqr;
     21        int pri, rqr;
     22        LIST_ENTRY(req) by_pri;
     23        LIST_ENTRY(req) by_rqr;
    2424};
    2525
     
    3737
    3838struct req
    39   r42a = {1, 42},
    40   r42b = {2, 42},
    41   r17a = {2, 17},
    42   r17b = {3, 17},
    43   r17c = {4, 17},
    44   r99a = {3, 99};
     39        r42a = {1, 42},
     40        r42b = {2, 42},
     41        r17a = {2, 17},
     42        r17b = {3, 17},
     43        r17c = {4, 17},
     44        r99a = {3, 99};
    4545
    4646LIST_INSERT_HEAD(&reqs_pri_global, &r17c, by_pri);
     
    6868struct req *cur;
    6969LIST_FOREACH(cur, &reqs_pri_global, by_pri)
    70     printf("{%d %d} ", cur->pri, cur->rqr);
     70        printf("{%d %d} ", cur->pri, cur->rqr);
    7171printf("| ");
    7272LIST_FOREACH(cur, &reqs_rqr_42, by_rqr)
    73     printf("{%d %d} ", cur->pri, cur->rqr);
     73        printf("{%d %d} ", cur->pri, cur->rqr);
    7474printf("| ");
    7575LIST_FOREACH(cur, &reqs_rqr_17, by_rqr)
    76     printf("{%d %d} ", cur->pri, cur->rqr);
     76        printf("{%d %d} ", cur->pri, cur->rqr);
    7777printf("| ");
    7878LIST_FOREACH(cur, &reqs_rqr_99, by_rqr)
    79     printf("{%d %d} ", cur->pri, cur->rqr);
     79        printf("{%d %d} ", cur->pri, cur->rqr);
    8080printf("\n");
    8181
  • doc/theses/mike_brooks_MMath/programs/lst-issues-wrapped-byref.run.cpp

    rb64d0f4 r5546f50b  
    2121
    2222struct req {
    23   int pri, rqr;
     23        int pri, rqr;
    2424};
    2525
     
    3131
    3232req
    33   r1 = {1, 42},
    34   r2 = {2, 42};
     33        r1 = {1, 42},
     34        r2 = {2, 42};
    3535
    3636reqs.push_front(
    37   &r2);
     37        &r2);
    3838reqs.push_front(
    39   &r1);
     39        &r1);
    4040
    4141
     
    5353
    5454for (auto const& cur : reqs)
    55     printf("{%d %d} ", cur->pri, cur->rqr);
     55        printf("{%d %d} ", cur->pri, cur->rqr);
    5656printf("\n");
    5757
  • doc/theses/mike_brooks_MMath/programs/lst-issues-wrapped-emplaced.run.cpp

    rb64d0f4 r5546f50b  
    2121
    2222struct req {
    23   int pri, rqr;
     23        int pri, rqr;
    2424};
    2525
     
    3535
    3636reqs.emplace_front(
    37   2, 42);
     37        2, 42);
    3838reqs.emplace_front(
    39   1, 42);
     39        1, 42);
    4040
    4141
     
    5353
    5454for (auto const& cur : reqs)
    55     printf("{%d %d} ", cur.pri, cur.rqr);
     55        printf("{%d %d} ", cur.pri, cur.rqr);
    5656printf("\n");
    5757
  • doc/theses/mike_brooks_MMath/programs/sharectx-demo.cfa

    rb64d0f4 r5546f50b  
    1919
    2020void helper2() {
    21    c();
    22    string_sharectx c = {NEW_SHARING};
    23    d();
     21        c();
     22        string_sharectx c = {NEW_SHARING};
     23        d();
    2424}
    2525void helper1() {
    26    a();
    27    string_sharectx c = {NO_SHARING};
    28    b();
    29    helper2();
    30    e();
     26        a();
     27        string_sharectx c = {NO_SHARING};
     28        b();
     29        helper2();
     30        e();
    3131}
    3232int main() {
    33    helper1();
     33        helper1();
    3434}
    3535
  • doc/theses/mike_brooks_MMath/programs/sharing-demo.cfa

    rb64d0f4 r5546f50b  
    3737        assert( s1 == "a+c" );
    3838        sout | xstr(S1s1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    39      
     39
    4040        #define S1As1 s1a[1] = '-'
    4141        S1As1;
    4242        assert( s1a == "a-c" );
    4343        sout | xstr(S1As1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    44      
     44
    4545        #define S2s1 s2 [1] = '|'
    4646        S2s1;
     
    4949        sout | "\\end{tabular}";
    5050        sout | "\\par\\noindent";
    51      
     51
    5252        sout | "Assignment of a value is just a modificiation."
    5353                   "\nThe aliasing relationship is established at construction and is unaffected by assignment of a value.";
     
    6161        assert( s1 == "qrs" );
    6262        sout | xstr(S1qrs) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    63    
     63
    6464        #define S1Atuv s1a = "tuv"
    6565        S1Atuv;
    6666        assert( s1a == "tuv" );
    6767        sout | xstr(S1Atuv) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    68    
     68
    6969        #define S2wxy s2  = "wxy"
    7070        S2wxy;
     
    8787        assert( s2 == "wxy" );
    8888        sout | xstr(S1S2) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    89    
     89
    9090        #define S1aaa s1  = "aaa"
    9191        S1aaa;
     
    9494        assert( s2 == "wxy" );
    9595        sout | xstr(S1aaa) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    96    
     96
    9797        #define S2S1 s2  = s1
    9898        S2S1;
     
    101101        assert( s2 == "aaa" );
    102102        sout | xstr(S2S1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\";
    103    
     103
    104104        #define S2bbb s2  = "bbb"
    105105        S2bbb;
     
    191191        sout | "\t\t\t\t& @s1@\t& @s1_mid@\t& @s2@\t\\\\";
    192192        sout | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\";
    193    
     193
    194194        #define D2_s1mid_ff s1_mid = "ff"
    195195        D2_s1mid_ff;
     
    207207        sout | "\\end{tabular}";
    208208        sout | "\\par\\noindent";
    209    
     209
    210210    sout | "In the \\emph{ff} step, which is a positive example of flow across an aliasing relationship, the result is straightforward to accept because the flow direction is from contained (small) to containing (large).  The following rules for edits through aliasing substrings will guide how to flow in the opposite direction.";
    211211        sout | "\\par";
     
    233233        assert( s1_mid == "i" );
    234234        sout  | xstr(D2_s1mid_i)  | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\";
    235    
     235
    236236        #define D2_s1mid_empty s1_mid = ""
    237237        D2_s1mid_empty;
     
    247247        sout | "\\end{tabular}";
    248248        sout | "\\par\\noindent";
    249    
     249
    250250    sout | "Multiple portions can be aliased.  When there are several aliasing substrings at once, the text editor analogy becomes an online multi-user editor.  I should be able to edit a paragraph in one place (changing the document's length), without my edits affecting which letters are within a mouse-selection that you had made previously, somewhere else.";
    251251        sout | "\\par\\noindent";
     
    279279        sout | "\\begin{tabular}{llllll}";
    280280        sout | "\t\t\t\t& @s1@\t& @s1_bgn@\t& @s1_crs@\t& @s1_mid@\t& @s1_end@\t\\\\";
    281    
     281
    282282        #define D2_s1crs_s1 string s1_crs = s1(3, 2)`shareEdits
    283283        D2_s1crs_s1;
     
    288288        assert( s1_end == "d" ); 
    289289        sout  | xstr(D2_s1crs_s1)  | "\t& " | s1 | "\t& " | s1_bgn | "\t& " | s1_crs | "\t& " | s1_mid | "\t& " | s1_end | "\t\\\\";
    290    
     290
    291291        #define D2_s1crs_ppp s1_crs = "+++"
    292292        D2_s1crs_ppp;
     
    316316
    317317        // "The extreme form of this shortening happens when a bystander alias is a proper substring of an edit.  The bystander becomes an empty substring."
    318    
     318
    319319        string all = "They said hello again";
    320320        string greet     = all(10,5)`shareEdits;
     
    327327        assert( greet_end == "o" );
    328328     
    329    
     329
    330330        greet = "sup";
    331331        assert( all == "They said sup again" );
     
    334334        // assert( greet_end == "" );
    335335     
    336    
     336
    337337 
    338338
     
    342342
    343343 
    344    
     344
    345345        greet_bgn = "what";
    346346     
     
    353353        // assert( greet_end == "" );    ------ Should be so, but fails
    354354     
    355    
     355
    356356        greet_end = "...";
    357357     
     
    365365        assert( greet_end == "..." );
    366366     
    367    
     367
    368368 
    369369
Note: See TracChangeset for help on using the changeset viewer.