about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-03-14 13:00:21 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-03-14 13:00:21 -0700
commit44bab2e4b4c8252b20c848108fa7bf9e33e2b26a (patch)
tree59312503c564a69b33105fe5801e5f79db65587e
parent3c393fd2449ebdd362f39873106199f089ed6718 (diff)
downloadmu-44bab2e4b4c8252b20c848108fa7bf9e33e2b26a.tar.gz
2782 - directly use string literals everywhere
-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
   }
 ]