Changeset c3e41cda for doc/theses/mike_brooks_MMath/programs
- Timestamp:
- Nov 3, 2024, 9:13:16 PM (3 months ago)
- Branches:
- master
- Children:
- 7d95bce9
- Parents:
- 63a7394
- Location:
- doc/theses/mike_brooks_MMath/programs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/programs/hello-accordion.cfa
r63a7394 rc3e41cda 30 30 forall( [C], [S] ) 31 31 int getPref( @School( C, S ) & school@, int is, int pref ) { 32 33 32 for ( ic; C ) { 33 int curPref = @school.preferences@[ic][is]; $\C{// offset calculation implicit}$ 34 34 if ( curPref == pref ) return ic; 35 35 } 36 36 assert( false ); 37 37 } 38 38 … … 59 59 60 60 { string sv; 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 61 int iv; 62 // headers' row 63 sin | "\nc\\s"; 64 for ( is ; ns ) { 65 // column label 66 sin | sv; 67 school.student_ids[is] = sv; 68 } 69 // body rows 70 for ( ic ; nc ) { 71 // row label 72 sin | sv; 73 school.course_codes[ic] = sv; 74 for ( is ; ns ) { 75 // matrix item 76 sin | iv; 77 school.preferences[ic][is] = iv; 78 } 79 } 80 } 81 81 82 82 … … 91 91 sout | school.student_ids[is] | ": " | nonl; 92 92 for ( pref; 1 ~= nc ) { 93 94 93 int ic = getPref(school, is, pref); 94 sout | school.course_codes[ ic ] | nonl; 95 95 } 96 96 sout | nl; -
doc/theses/mike_brooks_MMath/programs/hello-array.cfa
r63a7394 rc3e41cda 114 114 f( y, y ); $\C{// ok}$ 115 115 if ( M == N ) 116 f( x, @(array( float, M ) &)@y ); $\C{// ok} $116 f( x, @(array( float, M ) &)@y ); $\C{// ok}\CRT$ 117 117 } 118 118 -
doc/theses/mike_brooks_MMath/programs/sharing-demo.cfa
r63a7394 rc3e41cda 108 108 assert( s2 == "bbb" ); 109 109 sout | xstr(S2bbb) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 110 111 110 111 #define S2S1a s2 = s1a 112 112 S2S1a; 113 113 assert( s1 == "aaa" ); … … 122 122 assert( s2 == "ccc" ); 123 123 sout | xstr(S2ccc) | "\t& " | s1 | "\t& " | s1a | "\t& " | s2 | "\t\\\\"; 124 124 125 125 #define S1xxx s1 = "xxx" 126 126 S1xxx; … … 149 149 150 150 #define D2_s2_s1 string s2 = s1(1,2) 151 D2_s2_s1; 151 D2_s2_s1; 152 152 assert( s1 == "abcd" ); 153 153 assert( s1_mid == "bc" ); … … 157 157 sout | "\\par\\noindent"; 158 158 159 159 sout | "Again, @`shareEdits@ passes changes in both directions; copy does not. Note the difference in index values, with the \\emph{b} position being 1 in the longer string and 0 in the shorter strings. In the case of s1 aliasing with @s1_mid@, the very same character is being accessed by different postitions."; 160 160 sout | "\\par\\noindent"; 161 161 sout | "\\begin{tabular}{llll}"; … … 176 176 assert( s2 == "bc" ); 177 177 sout | xstr(D2_s1mid_minus) | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\"; 178 179 178 179 #define D2_s2_pipe s2 [0] = '|' 180 180 D2_s2_pipe; 181 181 assert( s1 == "a-cd" ); … … 186 186 sout | "\\par\\noindent"; 187 187 188 188 sout | "Once again, assignment of a value is a modificiation that flows through the aliasing relationship, without affecting its structure."; 189 189 sout | "\\par\\noindent"; 190 190 sout | "\\begin{tabular}{llll}"; … … 198 198 assert( s2 == "|c" ); 199 199 sout | xstr(D2_s1mid_ff) | "\t& " | s1 | "\t& " | s1_mid | "\t& " | s2 | "\t\\\\"; 200 200 201 201 #define D2_s2_gg s2 = "gg" 202 202 D2_s2_gg; … … 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"; 212 212 213 213 214 214 sout | "Growth and shrinkage are natural extensions. An empty substring is a real thing, at a well-defined location, whose meaning is extrapolated from the examples so far. The intended metaphor is to operating a GUI text editor. Having an aliasing substring is like using the mouse to select a few words. Assigning onto an aliasign substring is like typing from having a few words selected: depending how much you type, the file being edited can get shorter or longer."; 215 215 sout | "\\par\\noindent"; 216 216 sout | "\\begin{tabular}{lll}"; … … 219 219 220 220 assert( s1 == "affd" ); 221 // assert( s1_mid == "fc" ); 221 // assert( s1_mid == "fc" ); // ????????? bug? 222 222 sout | xstr(D2_s2_gg) | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\"; 223 223 … … 227 227 assert( s1_mid == "hhhh" ); 228 228 sout | xstr(D2_s1mid_hhhh) | "\t& " | s1 | "\t& " | s1_mid | "\t\\\\"; 229 229 230 230 #define D2_s1mid_i s1_mid = "i" 231 231 D2_s1mid_i; … … 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"; 252 252 sout | "\\begin{tabular}{lllll}"; … … 264 264 assert( s1_end == "d" ); 265 265 sout | xstr(D2_s1end_s1) | "\t& " | s1 | "\t& " | s1_bgn | "\t& " | s1_mid | "\t& " | s1_end | "\t\\\\"; 266 266 267 267 #define D1_s1bgn_zzz s1_bgn = "zzzz" 268 268 D1_s1bgn_zzz; … … 275 275 sout | "\\par\\noindent"; 276 276 277 277 sout | "When an edit happens on an aliasing substring that overlaps another, an effect is unavoidable. Here, the passive party sees its selection shortened, to exclude the characters that were not part of the original selection."; 278 278 sout | "\\par\\noindent"; 279 279 sout | "\\begin{tabular}{llllll}"; … … 286 286 assert( s1_crs == "zj" ); 287 287 assert( s1_mid == "jj" ); 288 assert( s1_end == "d" ); 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 … … 301 301 sout | "TODO: finish typesetting the demo"; 302 302 303 303 // "This shortening behaviour means that a modification has to occur entirely inside a substring, to show up in that substring. Sharing changes through the intersection of partially overlapping aliases is still possible, so long as the receiver's boundary is not inside the edit." 304 304 305 305 string word = "Phi"; … … 309 309 assert( consonants == "Ph" ); 310 310 assert( miniscules == "hi" ); 311 311 312 312 consonants[1] = 's'; 313 313 assert( word == "Psi" ); … … 321 321 string greet_bgn = all(10,1)`shareEdits; 322 322 string greet_end = all(14,1)`shareEdits; 323 323 324 324 assert( all == "They said hello again" ); 325 325 assert( greet == "hello" ); 326 326 assert( greet_bgn == "h" ); 327 327 assert( greet_end == "o" ); 328 328 329 329 330 330 greet = "sup"; … … 333 333 // assert( greet_bgn == "" ); ------ Should be so, but fails 334 334 // assert( greet_end == "" ); 335 336 337 338 339 340 341 342 343 344 345 greet_bgn = "what"; 346 347 335 336 337 338 339 340 /* As in the earlier step where \emph{aj} becomes \emph{ajjd}, such empty substrings maintain their places in the total string, and can be used for filling it. Because @greet_bgn@ was orginally at the start of the edit, in the outcome, the empty @greet_bgn@ sits just before the written value. Similarly @greed_end@ goes after. Though not shown, an overwritten substring at neither side goes arbitrarily to the before side. */ 341 342 343 344 345 greet_bgn = "what"; 346 347 348 348 assert( all == "They said whatsup again" ); 349 349 350 350 assert( greet == "sup" ); 351 351 352 352 assert( greet_bgn == "what" ); 353 353 // assert( greet_end == "" ); ------ Should be so, but fails 354 355 356 greet_end = "..."; 357 358 354 355 356 greet_end = "..."; 357 358 359 359 assert( all == "They said whatsup... again" ); 360 360 361 361 assert( greet == "sup" ); 362 362 363 363 assert( greet_bgn == "what" ); 364 364 365 365 assert( greet_end == "..." ); 366 367 368 369 370 371 372 366 367 368 369 370 371 /* Though these empty substrings hold their places in the total string, an empty string only belongs to bigger strings when it occurs completely inside them. There is no such state as including an empty substring at an edge. For this reason, @word@ gains the characters added by assigning to @greet_bgn@ and @greet_end@, but the string @greet@ does not. */ 372 373 373 374 374 } … … 377 377 int main(int argc, char ** argv) { 378 378 379 380 381 379 demo1(); 380 demo2(); 381 printf("%% %s done running\n", argv[0]); 382 382 }
Note: See TracChangeset
for help on using the changeset viewer.