Changeset 5546f50b for doc/theses/mike_brooks_MMath
- Timestamp:
- Mar 10, 2024, 11:21:18 AM (7 months ago)
- Branches:
- master
- Children:
- 9398177
- Parents:
- b64d0f4
- 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 4 4 forall( [M], [N], [P] ) 5 5 void matmul( array(float, M, P) & src1, 6 7 8 9 10 11 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 } 13 13 } -
doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal-stdvec.cpp
rb64d0f4 r5546f50b 3 3 forall( [M], [N], [P] ) 4 4 void matmul( array(float, M, P) & src1, 5 6 7 8 9 10 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 } 12 12 } 13 13 */ … … 30 30 31 31 float f( vector<float> & a ) { 32 33 34 35 36 37 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; 38 38 } 39 39 … … 41 41 #include <iostream> 42 42 int main( int argc, char ** argv ) { 43 44 45 46 47 48 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; 49 49 50 50 float answer = f(v); 51 51 52 52 cout << "answer: " << answer << endl; 53 53 54 54 } … … 80 80 81 81 void matmul( mat & a, mat & b, mat & rslt ) { 82 83 84 85 86 87 88 89 90 91 92 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 } 96 96 } 97 97 … … 99 99 #include <iostream> 100 100 int main( int argc, char ** argv ) { 101 102 103 104 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); 105 105 } 106 106 #endif -
doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal.cfa
rb64d0f4 r5546f50b 9 9 forall( [N] ) 10 10 size_t foo( array( size_t, N ) & a ) { 11 12 13 14 15 11 size_t retval = 0; 12 for( i; N ) { 13 retval += a[i]; 14 } 15 return retval; 16 16 } 17 17 … … 20 20 forall( [N], [M] ) 21 21 size_t foo( array( size_t, N, M ) & a ) { 22 23 24 25 26 22 size_t retval = 0; 23 for( i; N ) for( j; M ) { 24 retval += a[i][j]; 25 } 26 return retval; 27 27 } 28 28 … … 31 31 forall( [N] ) 32 32 size_t foo( array( size_t, N ) & a, array( size_t, N ) & b ) { 33 34 35 36 37 33 size_t retval = 0; 34 for( i; N ) { 35 retval += a[i] - b[i]; 36 } 37 return retval; 38 38 } 39 39 … … 42 42 forall( [M], [N], [P] ) 43 43 void foo ( array(size_t, M, P) & src1, 44 45 46 47 48 49 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 } 51 51 } 52 52 -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-arrty.c
rb64d0f4 r5546f50b 150 150 151 151 // 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 -" // 153 153 // End: // -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-decay.c
rb64d0f4 r5546f50b 18 18 // reusing local var `float a[10];`} 19 19 float v; 20 f( a, a );$\C{// ok: two decays, one into an array spelling}$21 f( &v, &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}$ 22 22 23 char ca[] = "hello"; 24 char *cp = "hello"; 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}$ 26 26 c[3] = 'p'; 27 27 } 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]}$ 31 31 32 32 void decay( float x[10] ) { -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-mdim.c
rb64d0f4 r5546f50b 14 14 15 15 int 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}$ 16 19 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}$ 22 23 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*}$ 27 27 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]); 33 31 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])); 37 34 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 ); 41 37 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]; 55 45 /* 56 46 -
doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa
rb64d0f4 r5546f50b 11 11 forall( T, [Nclients], [Ncosts] ) 12 12 struct request { 13 14 15 16 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; 17 17 }; 18 18 … … 41 41 forall( T, [Nclients], [Ncosts] ) 42 42 void summarize( request( T, Nclients, Ncosts ) & r ) { 43 44 45 46 47 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; 48 48 } 49 49 -
doc/theses/mike_brooks_MMath/programs/hello-array.cfa
rb64d0f4 r5546f50b 10 10 forall( [N] ) // array bound 11 11 array(bool, N) & f( array(float, N) & a, array(float, N) & b ) { 12 13 14 15 16 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; 17 17 } 18 18 … … 29 29 30 30 int main( int argc, char * argv[] ) { 31 32 33 34 35 36 37 38 39 40 41 42 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 43 43 } 44 44 /* … … 52 52 array(float, 10) a; 53 53 array(float, 20) b; 54 55 56 54 f( a, a ); 55 f( b, b ); 56 f( a, b ); 57 57 } 58 58 … … 60 60 forall( [M], [N] ) 61 61 void bad( array(float, M) &a, array(float, N) &b ) { 62 63 64 62 f( a, a ); // ok 63 f( b, b ); // ok 64 f( a, b ); // error 65 65 } 66 66 #endif … … 70 70 forall( [M], [N] ) 71 71 void bad_fixed( array(float, M) & a, array(float, N) & b ) { 72 73 74 72 if ( M == N ) { 73 f( a, (array(float, M) &)b ); // cast b to matching type 74 } 75 75 } -
doc/theses/mike_brooks_MMath/programs/hello-md.cfa
rb64d0f4 r5546f50b 60 60 forall( [N] ) 61 61 void print1d_cstyle( array(float, N) & c ) { 62 63 64 65 62 for ( i; N ) { 63 sout | c[i] | nonl; 64 } 65 sout | nl; 66 66 } 67 67 … … 79 79 forall( [N], C & | ar( C, float, N ) ) 80 80 void print1d( C & c ) { 81 82 83 84 81 for( i; N ) { 82 sout | c[i] | nonl; 83 } 84 sout | nl; 85 85 } 86 86 … … 99 99 100 100 void fill( array(float, 5, 7) & a ) { 101 102 103 104 105 106 107 108 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; 109 109 } 110 110 … … 125 125 4.0 4.1 4.2 4.3 4.4 4.5 4.6 126 126 */ 127 127 128 128 129 129 -
doc/theses/mike_brooks_MMath/programs/lst-features-intro.run.cfa
rb64d0f4 r5546f50b 19 19 20 20 struct req { 21 22 21 int pri, rqr; 22 inline dlink(req); 23 23 }; 24 24 … … 26 26 27 27 req 28 29 28 r1 = {1, 42}, 29 r2 = {2, 42}; 30 30 31 31 insert_first(reqs, r2); … … 51 51 52 52 while( req & cur = reqs`elems; cur`moveNext ) 53 53 printf("{%d %d} ", cur.pri, cur.rqr); 54 54 printf("\n"); 55 55 -
doc/theses/mike_brooks_MMath/programs/lst-features-multidir.run.cfa
rb64d0f4 r5546f50b 19 19 20 20 struct req { 21 22 23 21 int pri, rqr; 22 inline struct by_pri { inline dlink(req); }; 23 inline struct by_rqr { inline dlink(req); }; 24 24 }; 25 25 … … 44 44 45 45 struct req 46 47 48 49 50 51 46 r42a = {1, 42}, 47 r42b = {2, 42}, 48 r17a = {2, 17}, 49 r17b = {3, 17}, 50 r17c = {4, 17}, 51 r99a = {3, 99}; 52 52 53 53 insert_first(reqs_pri_global, r17c); … … 75 75 76 76 with(DLINK_VIA(req, req.by_pri)) { 77 78 79 77 while( req & cur = reqs_pri_global`elems; cur`moveNext ) 78 printf("{%d %d} ", cur.pri, cur.rqr); 79 printf("| "); 80 80 } 81 81 82 82 with(DLINK_VIA(req, req.by_rqr)) { 83 84 85 86 87 88 89 90 91 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"); 92 92 } 93 93 -
doc/theses/mike_brooks_MMath/programs/lst-issues-attach-reduction.hpp
rb64d0f4 r5546f50b 100 100 template<typename El> 101 101 class list { 102 103 104 105 106 107 102 struct node { 103 LIST_ENTRY(node) links; 104 El elem; 105 }; 106 LIST_HEAD(Impl, node); 107 Impl impl; 108 108 public: 109 110 111 112 113 114 115 116 117 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 118 118 119 119 … … 129 129 130 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 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); } 146 146 147 147 -
doc/theses/mike_brooks_MMath/programs/lst-issues-intrusive.run.c
rb64d0f4 r5546f50b 21 21 22 22 struct req { 23 24 23 int pri, rqr; 24 LIST_ENTRY(req) x; 25 25 }; 26 26 … … 31 31 32 32 struct req 33 34 33 r1 = {1, 42}, 34 r2 = {2, 42}; 35 35 36 36 LIST_INSERT_HEAD( 37 37 &reqs, &r2, x); 38 38 LIST_INSERT_HEAD( 39 39 &reqs, &r1, x); 40 40 41 41 … … 51 51 struct req *cur; 52 52 LIST_FOREACH(cur, &reqs, x) 53 53 printf("{%d %d} ", cur->pri, cur->rqr); 54 54 printf("\n"); 55 55 -
doc/theses/mike_brooks_MMath/programs/lst-issues-multi-static.run.c
rb64d0f4 r5546f50b 19 19 20 20 struct req { 21 22 23 21 int pri, rqr; 22 LIST_ENTRY(req) by_pri; 23 LIST_ENTRY(req) by_rqr; 24 24 }; 25 25 … … 37 37 38 38 struct req 39 40 41 42 43 44 39 r42a = {1, 42}, 40 r42b = {2, 42}, 41 r17a = {2, 17}, 42 r17b = {3, 17}, 43 r17c = {4, 17}, 44 r99a = {3, 99}; 45 45 46 46 LIST_INSERT_HEAD(&reqs_pri_global, &r17c, by_pri); … … 68 68 struct req *cur; 69 69 LIST_FOREACH(cur, &reqs_pri_global, by_pri) 70 70 printf("{%d %d} ", cur->pri, cur->rqr); 71 71 printf("| "); 72 72 LIST_FOREACH(cur, &reqs_rqr_42, by_rqr) 73 73 printf("{%d %d} ", cur->pri, cur->rqr); 74 74 printf("| "); 75 75 LIST_FOREACH(cur, &reqs_rqr_17, by_rqr) 76 76 printf("{%d %d} ", cur->pri, cur->rqr); 77 77 printf("| "); 78 78 LIST_FOREACH(cur, &reqs_rqr_99, by_rqr) 79 79 printf("{%d %d} ", cur->pri, cur->rqr); 80 80 printf("\n"); 81 81 -
doc/theses/mike_brooks_MMath/programs/lst-issues-wrapped-byref.run.cpp
rb64d0f4 r5546f50b 21 21 22 22 struct req { 23 23 int pri, rqr; 24 24 }; 25 25 … … 31 31 32 32 req 33 34 33 r1 = {1, 42}, 34 r2 = {2, 42}; 35 35 36 36 reqs.push_front( 37 37 &r2); 38 38 reqs.push_front( 39 39 &r1); 40 40 41 41 … … 53 53 54 54 for (auto const& cur : reqs) 55 55 printf("{%d %d} ", cur->pri, cur->rqr); 56 56 printf("\n"); 57 57 -
doc/theses/mike_brooks_MMath/programs/lst-issues-wrapped-emplaced.run.cpp
rb64d0f4 r5546f50b 21 21 22 22 struct req { 23 23 int pri, rqr; 24 24 }; 25 25 … … 35 35 36 36 reqs.emplace_front( 37 37 2, 42); 38 38 reqs.emplace_front( 39 39 1, 42); 40 40 41 41 … … 53 53 54 54 for (auto const& cur : reqs) 55 55 printf("{%d %d} ", cur.pri, cur.rqr); 56 56 printf("\n"); 57 57 -
doc/theses/mike_brooks_MMath/programs/sharectx-demo.cfa
rb64d0f4 r5546f50b 19 19 20 20 void helper2() { 21 22 23 21 c(); 22 string_sharectx c = {NEW_SHARING}; 23 d(); 24 24 } 25 25 void helper1() { 26 27 28 29 30 26 a(); 27 string_sharectx c = {NO_SHARING}; 28 b(); 29 helper2(); 30 e(); 31 31 } 32 32 int main() { 33 33 helper1(); 34 34 } 35 35 -
doc/theses/mike_brooks_MMath/programs/sharing-demo.cfa
rb64d0f4 r5546f50b 37 37 assert( s1 == "a+c" ); 38 38 sout | xstr(S1s1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 39 39 40 40 #define S1As1 s1a[1] = '-' 41 41 S1As1; 42 42 assert( s1a == "a-c" ); 43 43 sout | xstr(S1As1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 44 44 45 45 #define S2s1 s2 [1] = '|' 46 46 S2s1; … … 49 49 sout | "\\end{tabular}"; 50 50 sout | "\\par\\noindent"; 51 51 52 52 sout | "Assignment of a value is just a modificiation." 53 53 "\nThe aliasing relationship is established at construction and is unaffected by assignment of a value."; … … 61 61 assert( s1 == "qrs" ); 62 62 sout | xstr(S1qrs) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 63 63 64 64 #define S1Atuv s1a = "tuv" 65 65 S1Atuv; 66 66 assert( s1a == "tuv" ); 67 67 sout | xstr(S1Atuv) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 68 68 69 69 #define S2wxy s2 = "wxy" 70 70 S2wxy; … … 87 87 assert( s2 == "wxy" ); 88 88 sout | xstr(S1S2) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 89 89 90 90 #define S1aaa s1 = "aaa" 91 91 S1aaa; … … 94 94 assert( s2 == "wxy" ); 95 95 sout | xstr(S1aaa) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 96 96 97 97 #define S2S1 s2 = s1 98 98 S2S1; … … 101 101 assert( s2 == "aaa" ); 102 102 sout | xstr(S2S1) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 103 103 104 104 #define S2bbb s2 = "bbb" 105 105 S2bbb; … … 191 191 sout | "\t\t\t\t& @s1@\t& @s1_mid@\t& @s2@\t\\\\"; 192 192 sout | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\"; 193 193 194 194 #define D2_s1mid_ff s1_mid = "ff" 195 195 D2_s1mid_ff; … … 207 207 sout | "\\end{tabular}"; 208 208 sout | "\\par\\noindent"; 209 209 210 210 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."; 211 211 sout | "\\par"; … … 233 233 assert( s1_mid == "i" ); 234 234 sout | xstr(D2_s1mid_i) | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\"; 235 235 236 236 #define D2_s1mid_empty s1_mid = "" 237 237 D2_s1mid_empty; … … 247 247 sout | "\\end{tabular}"; 248 248 sout | "\\par\\noindent"; 249 249 250 250 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."; 251 251 sout | "\\par\\noindent"; … … 279 279 sout | "\\begin{tabular}{llllll}"; 280 280 sout | "\t\t\t\t& @s1@\t& @s1_bgn@\t& @s1_crs@\t& @s1_mid@\t& @s1_end@\t\\\\"; 281 281 282 282 #define D2_s1crs_s1 string s1_crs = s1(3, 2)`shareEdits 283 283 D2_s1crs_s1; … … 288 288 assert( s1_end == "d" ); 289 289 sout | xstr(D2_s1crs_s1) | "\t& " | s1 | "\t& " | s1_bgn | "\t& " | s1_crs | "\t& " | s1_mid | "\t& " | s1_end | "\t\\\\"; 290 290 291 291 #define D2_s1crs_ppp s1_crs = "+++" 292 292 D2_s1crs_ppp; … … 316 316 317 317 // "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 319 319 string all = "They said hello again"; 320 320 string greet = all(10,5)`shareEdits; … … 327 327 assert( greet_end == "o" ); 328 328 329 329 330 330 greet = "sup"; 331 331 assert( all == "They said sup again" ); … … 334 334 // assert( greet_end == "" ); 335 335 336 336 337 337 338 338 … … 342 342 343 343 344 344 345 345 greet_bgn = "what"; 346 346 … … 353 353 // assert( greet_end == "" ); ------ Should be so, but fails 354 354 355 355 356 356 greet_end = "..."; 357 357 … … 365 365 assert( greet_end == "..." ); 366 366 367 367 368 368 369 369
Note: See TracChangeset
for help on using the changeset viewer.