about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--074list.mu9
-rw-r--r--chessboard.mu47
-rw-r--r--edit/004-programming-environment.mu6
-rw-r--r--edit/005-sandbox.mu13
-rw-r--r--edit/008-sandbox-test.mu2
-rw-r--r--edit/010-errors.mu9
-rw-r--r--sandbox/004-programming-environment.mu6
-rw-r--r--sandbox/005-sandbox.mu13
-rw-r--r--sandbox/008-sandbox-test.mu2
-rw-r--r--sandbox/010-errors.mu9
10 files changed, 38 insertions, 78 deletions
diff --git a/074list.mu b/074list.mu
index 856c5e9c..6cb7a9a1 100644
--- a/074list.mu
+++ b/074list.mu
@@ -83,11 +83,7 @@ def to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:add
   next:address:shared:list:_elem <- rest in
   nextn:number <- copy next
   return-unless next
-  space:character <- copy 32/space
-  buf <- append buf, space:character
-  s:address:shared:array:character <- new [-> ]
-  n:number <- length *s
-  buf <- append buf, s
+  buf <- append buf, [ -> ]
   # and recurse
   remaining:number, optional-ingredient-found?:boolean <- next-ingredient
   {
@@ -104,8 +100,7 @@ def to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:add
     return
   }
   # past recursion depth; insert ellipses and stop
-  s:address:shared:array:character <- new [...]
-  append buf, s
+  append buf, [...]
 ]
 
 scenario stash-on-list-converts-to-text [
diff --git a/chessboard.mu b/chessboard.mu
index 0f400157..9c7f17e4 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -76,23 +76,19 @@ def chessboard screen:address:shared:screen, console:address:shared:console -> s
   buffered-stdin:address:shared:channel <- new-channel 10/capacity
   start-running buffer-lines, stdin, buffered-stdin
   {
-    msg:address:shared:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.
+    print screen, [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.
 ]
-    print screen, msg
     cursor-to-next-line screen
     print-board screen, board
     cursor-to-next-line screen
-    msg <- new [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
+    print screen, [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
 ]
-    print screen, msg
     cursor-to-next-line screen
-    msg <- new [Hit 'q' to exit.
+    print screen [Hit 'q' to exit.
 ]
-    print screen, msg
     {
       cursor-to-next-line screen
-      msg <- new [move: ]
-      screen <- print screen, msg
+      screen <- print screen, [move: ]
       m:address:shared:move, quit:boolean, error:boolean <- read-move buffered-stdin, screen
       break-if quit, +quit:label
       buffered-stdin <- clear-channel buffered-stdin  # cleanup after error. todo: test this?
@@ -102,7 +98,6 @@ def chessboard screen:address:shared:screen, console:address:shared:console -> s
     screen <- clear-screen screen
     loop
   }
-  msg <- copy 0
   +quit
 ]
 
@@ -157,8 +152,7 @@ def print-board screen:address:shared:screen, board:address:shared:array:address
     # print rank number as a legend
     rank:number <- add row, 1
     print-integer screen, rank
-    s:address:shared:array:character <- new [ | ]
-    print screen, s
+    print screen, [ | ]
     # print each square in the row
     col:number <- copy 0
     {
@@ -176,12 +170,10 @@ def print-board screen:address:shared:screen, board:address:shared:array:address
     loop
   }
   # print file letters as legend
-  s <- new [  +----------------]
-  print screen, s
-  screen <- cursor-to-next-line screen
-  s <- new [    a b c d e f g h]
-  screen <- print screen, s
-  screen <- cursor-to-next-line screen
+  print screen, [  +----------------]
+  cursor-to-next-line screen
+  print screen, [    a b c d e f g h]
+  cursor-to-next-line screen
 ]
 
 def initial-position -> board:address:shared:array:address:shared:array:character [
@@ -293,8 +285,7 @@ def read-file stdin:address:shared:channel, screen:address:shared:screen -> file
   {
     newline?:boolean <- equal c, 10/newline
     break-unless newline?
-    error-message:address:shared:array:character <- new [that's not enough]
-    print screen, error-message
+    print screen, [that's not enough]
     return 0/dummy, 0/quit, 1/error
   }
   file:number <- subtract c, 97/a
@@ -302,8 +293,7 @@ def read-file stdin:address:shared:channel, screen:address:shared:screen -> file
   {
     above-min:boolean <- greater-or-equal file, 0
     break-if above-min
-    error-message:address:shared:array:character <- new [file too low: ]
-    print screen, error-message
+    print screen, [file too low: ]
     print screen, c
     cursor-to-next-line screen
     return 0/dummy, 0/quit, 1/error
@@ -311,8 +301,7 @@ def read-file stdin:address:shared:channel, screen:address:shared:screen -> file
   {
     below-max:boolean <- lesser-than file, 8
     break-if below-max
-    error-message <- new [file too high: ]
-    print screen, error-message
+    print screen, [file too high: ]
     print screen, c
     return 0/dummy, 0/quit, 1/error
   }
@@ -337,8 +326,7 @@ def read-rank stdin:address:shared:channel, screen:address:shared:screen -> rank
   {
     newline?:boolean <- equal c, 10  # newline
     break-unless newline?
-    error-message:address:shared:array:character <- new [that's not enough]
-    print screen, error-message
+    print screen, [that's not enough]
     return 0/dummy, 0/quit, 1/error
   }
   rank:number <- subtract c, 49/'1'
@@ -346,16 +334,14 @@ def read-rank stdin:address:shared:channel, screen:address:shared:screen -> rank
   {
     above-min:boolean <- greater-or-equal rank, 0
     break-if above-min
-    error-message <- new [rank too low: ]
-    print screen, error-message
+    print screen, [rank too low: ]
     print screen, c
     return 0/dummy, 0/quit, 1/error
   }
   {
     below-max:boolean <- lesser-or-equal rank, 7
     break-if below-max
-    error-message <- new [rank too high: ]
-    print screen, error-message
+    print screen, [rank too high: ]
     print screen, c
     return 0/dummy, 0/quit, 1/error
   }
@@ -371,8 +357,7 @@ def expect-from-channel stdin:address:shared:channel, expected:character, screen
   {
     match?:boolean <- equal c, expected
     break-if match?
-    s:address:shared:array:character <- new [expected character not found]
-    print screen, s
+    print screen, [expected character not found]
   }
   result <- not match?
 ]
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index e8ff90d8..f43a44a7 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -33,8 +33,7 @@ def new-programming-environment screen:address:shared:screen, initial-recipe-con
   button-on-screen?:boolean <- greater-or-equal button-start, 0
   assert button-on-screen?, [screen too narrow for menu]
   screen <- move-cursor screen, 0/row, button-start
-  run-button:address:shared:array:character <- new [ run (F4) ]
-  print screen, run-button, 255/white, 161/reddish
+  print screen, [ run (F4) ], 255/white, 161/reddish
   # dotted line down the middle
   divider:number, _ <- divide-with-remainder width, 2
   draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted
@@ -385,8 +384,7 @@ def render-all screen:address:shared:screen, env:address:shared:programming-envi
   button-on-screen?:boolean <- greater-or-equal button-start, 0
   assert button-on-screen?, [screen too narrow for menu]
   screen <- move-cursor screen, 0/row, button-start
-  run-button:address:shared:array:character <- new [ run (F4) ]
-  print screen, run-button, 255/white, 161/reddish
+  print screen, [ run (F4) ], 255/white, 161/reddish
   # dotted line down the middle
   trace 11, [app], [render divider]
   divider:number, _ <- divide-with-remainder width, 2
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index 361a346f..95cc53b8 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -127,15 +127,13 @@ after <global-keypress> [
   {
     do-run?:boolean <- equal *k, 65532/F4
     break-unless do-run?
-    status:address:shared:array:character <- new [running...       ]
-    screen <- update-status screen, status, 245/grey
+    screen <- update-status screen, [running...       ], 245/grey
     error?:boolean, env, screen <- run-sandboxes env, screen
     # F4 might update warnings and results on both sides
     screen <- render-all screen, env
     {
       break-if error?
-      status:address:shared:array:character <- new [                 ]
-      screen <- update-status screen, status, 245/grey
+      screen <- update-status screen, [                 ], 245/grey
     }
     screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env
     loop +next-event:label
@@ -223,7 +221,6 @@ def save-sandboxes env:address:shared:programming-environment-data [
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
   curr:address:shared:sandbox-data <- get *env, sandbox:offset
-  suffix:address:shared:array:character <- new [.out]
   idx:number <- copy 0
   {
     break-unless curr
@@ -328,7 +325,6 @@ def restore-sandboxes env:address:shared:programming-environment-data -> env:add
   local-scope
   load-ingredients
   # read all scenarios, pushing them to end of a list of scenarios
-  suffix:address:shared:array:character <- new [.out]
   idx:number <- copy 0
   curr:address:address:shared:sandbox-data <- get-address *env, sandbox:offset
   {
@@ -341,7 +337,7 @@ def restore-sandboxes env:address:shared:programming-environment-data -> env:add
     *data <- copy contents
     # restore expected output for sandbox if it exists
     {
-      filename <- append filename, suffix
+      filename <- append filename, [.out]
       contents <- restore filename
       break-unless contents
       <end-restore-sandbox>
@@ -363,8 +359,7 @@ def render-screen screen:address:shared:screen, sandbox-screen:address:shared:sc
   load-ingredients
   return-unless sandbox-screen
   # print 'screen:'
-  header:address:shared:array:character <- new [screen:]
-  row <- render screen, header, left, right, 245/grey, row
+  row <- render screen, [screen:], left, right, 245/grey, row
   screen <- move-cursor screen, row, left
   # start printing sandbox-screen
   column:number <- copy left
diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu
index a3311891..7d479375 100644
--- a/edit/008-sandbox-test.mu
+++ b/edit/008-sandbox-test.mu
@@ -93,7 +93,7 @@ before <end-save-sandbox> [
   {
     expected-response:address:shared:array:character <- get *curr, expected-response:offset
     break-unless expected-response
-    filename <- append filename, suffix
+    filename <- append filename, [.out]
     save filename, expected-response
   }
 ]
diff --git a/edit/010-errors.mu b/edit/010-errors.mu
index d913302c..1a0dc812 100644
--- a/edit/010-errors.mu
+++ b/edit/010-errors.mu
@@ -16,8 +16,7 @@ def! update-recipes env:address:shared:programming-environment-data, screen:addr
   # if recipe editor has errors, stop
   {
     break-unless *recipe-errors
-    status:address:shared:array:character <- new [errors found     ]
-    update-status screen, status, 1/red
+    update-status screen, [errors found     ], 1/red
     errors-found? <- copy 1/true
     return
   }
@@ -29,8 +28,7 @@ before <render-components-end> [
   recipe-errors:address:shared:array:character <- get *env, recipe-errors:offset
   {
     break-unless recipe-errors
-    status:address:shared:array:character <- new [errors found     ]
-    update-status screen, status, 1/red
+    update-status screen, [errors found     ], 1/red
   }
 ]
 
@@ -70,9 +68,8 @@ before <render-components-end> [
     error-index:number <- get *env, error-index:offset
     sandboxes-completed-successfully?:boolean <- equal error-index, -1
     break-if sandboxes-completed-successfully?
-    status-template:address:shared:array:character <- new [errors found (_)    ]
     error-index-text:address:shared:array:character <- to-text error-index
-    status:address:shared:array:character <- interpolate status-template, error-index-text
+    status:address:shared:array:character <- interpolate [errors found (_)    ], error-index-text
     update-status screen, status, 1/red
   }
 ]
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index 8c6e58cb..bbbb45e2 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -31,8 +31,7 @@ def new-programming-environment screen:address:shared:screen, initial-sandbox-co
   button-on-screen?:boolean <- greater-or-equal button-start, 0
   assert button-on-screen?, [screen too narrow for menu]
   screen <- move-cursor screen, 0/row, button-start
-  run-button:address:shared:array:character <- new [ run (F4) ]
-  print screen, run-button, 255/white, 161/reddish
+  print screen, [ run (F4) ], 255/white, 161/reddish
   # sandbox editor
   current-sandbox:address:address:shared:editor-data <- get-address *result, current-sandbox:offset
   *current-sandbox <- new-editor initial-sandbox-contents, screen, 0, width/right
@@ -165,8 +164,7 @@ def render-all screen:address:shared:screen, env:address:shared:programming-envi
   button-on-screen?:boolean <- greater-or-equal button-start, 0
   assert button-on-screen?, [screen too narrow for menu]
   screen <- move-cursor screen, 0/row, button-start
-  run-button:address:shared:array:character <- new [ run (F4) ]
-  print screen, run-button, 255/white, 161/reddish
+  print screen, [ run (F4) ], 255/white, 161/reddish
   #
   screen <- render-sandbox-side screen, env
   <render-components-end>
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index a9c07e5e..57a4f5cf 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -112,8 +112,7 @@ after <global-keypress> [
   {
     do-run?:boolean <- equal *k, 65532/F4
     break-unless do-run?
-    status:address:shared:array:character <- new [running...       ]
-    screen <- update-status screen, status, 245/grey
+    screen <- update-status screen, [running...       ], 245/grey
     test-recipes:address:shared:array:character, _/optional <- next-ingredient
     error?:boolean, env, screen <- run-sandboxes env, screen, test-recipes
 #?     test-recipes <- copy 0  # abandon
@@ -121,8 +120,7 @@ after <global-keypress> [
     screen <- render-all screen, env
     {
       break-if error?
-      status:address:shared:array:character <- new [                 ]
-      screen <- update-status screen, status, 245/grey
+      screen <- update-status screen, [                 ], 245/grey
     }
     screen <- update-cursor screen, current-sandbox, env
     loop +next-event:label
@@ -214,7 +212,6 @@ def save-sandboxes env:address:shared:programming-environment-data [
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
   curr:address:shared:sandbox-data <- get *env, sandbox:offset
-  suffix:address:shared:array:character <- new [.out]
   idx:number <- copy 0
   {
     break-unless curr
@@ -320,7 +317,6 @@ def! restore-sandboxes env:address:shared:programming-environment-data -> env:ad
   local-scope
   load-ingredients
   # read all scenarios, pushing them to end of a list of scenarios
-  suffix:address:shared:array:character <- new [.out]
   idx:number <- copy 0
   curr:address:address:shared:sandbox-data <- get-address *env, sandbox:offset
   {
@@ -333,7 +329,7 @@ def! restore-sandboxes env:address:shared:programming-environment-data -> env:ad
     *data <- copy contents
     # restore expected output for sandbox if it exists
     {
-      filename <- append filename, suffix
+      filename <- append filename, [.out]
       contents <- restore filename
       break-unless contents
       <end-restore-sandbox>
@@ -355,8 +351,7 @@ def render-screen screen:address:shared:screen, sandbox-screen:address:shared:sc
   load-ingredients
   return-unless sandbox-screen
   # print 'screen:'
-  header:address:shared:array:character <- new [screen:]
-  row <- render screen, header, left, right, 245/grey, row
+  row <- render screen, [screen:], left, right, 245/grey, row
   screen <- move-cursor screen, row, left
   # start printing sandbox-screen
   column:number <- copy left
diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu
index a7010190..b64a5980 100644
--- a/sandbox/008-sandbox-test.mu
+++ b/sandbox/008-sandbox-test.mu
@@ -92,7 +92,7 @@ before <end-save-sandbox> [
   {
     expected-response:address:shared:array:character <- get *curr, expected-response:offset
     break-unless expected-response
-    filename <- append filename, suffix
+    filename <- append filename, [.out]
     save filename, expected-response
   }
 ]
diff --git a/sandbox/010-errors.mu b/sandbox/010-errors.mu
index 1a84764d..b76c9fc0 100644
--- a/sandbox/010-errors.mu
+++ b/sandbox/010-errors.mu
@@ -22,8 +22,7 @@ def! update-recipes env:address:shared:programming-environment-data, screen:addr
   # if recipe editor has errors, stop
   {
     break-unless *recipe-errors
-    status:address:shared:array:character <- new [errors found     ]
-    update-status screen, status, 1/red
+    update-status screen, [errors found     ], 1/red
     errors-found? <- copy 1/true
     return
   }
@@ -35,8 +34,7 @@ before <render-components-end> [
   recipe-errors:address:shared:array:character <- get *env, recipe-errors:offset
   {
     break-unless recipe-errors
-    status:address:shared:array:character <- new [errors found     ]
-    update-status screen, status, 1/red
+    update-status screen, [errors found     ], 1/red
   }
 ]
 
@@ -68,9 +66,8 @@ before <render-components-end> [
     error-index:number <- get *env, error-index:offset
     sandboxes-completed-successfully?:boolean <- equal error-index, -1
     break-if sandboxes-completed-successfully?
-    status-template:address:shared:array:character <- new [errors found (_)    ]
     error-index-text:address:shared:array:character <- to-text error-index
-    status:address:shared:array:character <- interpolate status-template, error-index-text
+    status:address:shared:array:character <- interpolate [errors found (_)    ], error-index-text
     update-status screen, status, 1/red
   }
 ]
@akkartik.com> 2018-12-01 14:13:33 -0800 4814' href='/akkartik/mu/commit/html/069hash.cc.html?h=main&id=e4ac3c9e6e5464a0fc0f8fd3763a572e0e180c04'>e4ac3c9e ^
805d58c6 ^


e4ac3c9e ^
5fe060d5 ^
805d58c6 ^







































204dae92 ^
805d58c6 ^

































5fe060d5 ^
805d58c6 ^






































































































































5fe060d5 ^


805d58c6 ^
5fe060d5 ^
805d58c6 ^



e4ac3c9e ^
805d58c6 ^


e4ac3c9e ^
805d58c6 ^


e4ac3c9e ^
805d58c6 ^





5fe060d5 ^
805d58c6 ^













204dae92 ^

dcc060c7 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432