about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-22 12:08:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-22 12:08:10 -0700
commitada5eb55cb185edf30dcac48b25cc485d44677ef (patch)
treee147838f053a582e33146ac4fc4ab30ac8434e0e /edit
parenta6deb48067f8049922f16ed3489896f7749fd39f (diff)
downloadmu-ada5eb55cb185edf30dcac48b25cc485d44677ef.tar.gz
3552
Stop requiring jump instructions to explicitly provide a ':label' type
for jump targets.

This has been a source of repeated confusion for my students:
  a) They'd add the ':label' to the label definition rather than the
  jump target (label use)
  b) They'd spend time thinking about whether the initial '+' prefix was
  part of the label name.

In the process I cleaned up a couple of things:

  - the space of names is more cleanly partitioned into labels and
    non-labels (clarifying that '_' and '-' are non-label prefixes)
  - you can't use label names as regular variables anymore
  - you can infer the type of a label just from its name
Diffstat (limited to 'edit')
-rw-r--r--edit/001-editor.mu12
-rw-r--r--edit/002-typing.mu6
-rw-r--r--edit/003-shortcuts.mu2
-rw-r--r--edit/004-programming-environment.mu30
-rw-r--r--edit/005-sandbox.mu18
-rw-r--r--edit/006-sandbox-copy.mu2
-rw-r--r--edit/007-sandbox-delete.mu2
-rw-r--r--edit/008-sandbox-edit.mu2
-rw-r--r--edit/009-sandbox-test.mu4
-rw-r--r--edit/010-sandbox-trace.mu2
-rw-r--r--edit/011-errors.mu2
-rw-r--r--edit/012-editor-undo.mu8
12 files changed, 45 insertions, 45 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu
index bbe16390..82f4c4fa 100644
--- a/edit/001-editor.mu
+++ b/edit/001-editor.mu
@@ -180,7 +180,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc
       screen <- move-cursor screen, row, column
       curr <- next curr
       prev <- next prev
-      loop +next-character:label
+      loop +next-character
     }
     {
       # at right? wrap. even if there's only one more letter left; we need
@@ -194,7 +194,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc
       row <- add row, 1
       screen <- move-cursor screen, row, column
       # don't increment curr
-      loop +next-character:label
+      loop +next-character
     }
     print screen, c, color
     curr <- next curr
@@ -414,7 +414,7 @@ def get-color color:num, c:char -> color:num [
     break-unless starting-comment?
     trace 90, [app], [switch color back to blue]
     color <- copy 12/lightblue
-    jump +exit:label
+    jump +exit
   }
   # if color is blue and next character is newline, switch color to white
   {
@@ -424,7 +424,7 @@ def get-color color:num, c:char -> color:num [
     break-unless ending-comment?
     trace 90, [app], [switch color back to white]
     color <- copy 7/white
-    jump +exit:label
+    jump +exit
   }
   # if color is white (no comments) and next character is '<', switch color to red
   {
@@ -432,7 +432,7 @@ def get-color color:num, c:char -> color:num [
     starting-assignment?:bool <- equal c, 60/<
     break-unless starting-assignment?
     color <- copy 1/red
-    jump +exit:label
+    jump +exit
   }
   # if color is red and next character is space, switch color to white
   {
@@ -441,7 +441,7 @@ def get-color color:num, c:char -> color:num [
     ending-assignment?:bool <- equal c, 32/space
     break-unless ending-assignment?
     color <- copy 7/white
-    jump +exit:label
+    jump +exit
   }
   # otherwise no change
   +exit
diff --git a/edit/002-typing.mu b/edit/002-typing.mu
index 2f94f362..12448e18 100644
--- a/edit/002-typing.mu
+++ b/edit/002-typing.mu
@@ -29,7 +29,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> scr
     {
       break-unless is-touch?
       move-cursor-in-editor screen, editor, t
-      loop +next-event:label
+      loop +next-event
     }
     # keyboard events
     {
@@ -125,7 +125,7 @@ def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column:
       column <- copy left
       curr <- next curr
       prev <- next prev
-      loop +next-character:label
+      loop +next-character
     }
     {
       # at right? wrap. even if there's only one more letter left; we need
@@ -135,7 +135,7 @@ def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column:
       column <- copy left
       row <- add row, 1
       # don't increment curr/prev
-      loop +next-character:label
+      loop +next-character
     }
     curr <- next curr
     prev <- next prev
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu
index 2dbc481a..4c4caf38 100644
--- a/edit/003-shortcuts.mu
+++ b/edit/003-shortcuts.mu
@@ -1242,7 +1242,7 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor, go-
       no-motion?:bool <- equal next-line, before-cursor
       break-unless no-motion?
       scroll?:bool <- greater-than cursor-row, 1
-      break-if scroll?, +try-to-scroll:label
+      break-if scroll?, +try-to-scroll
       go-render? <- copy 0/false
       return
     }
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index 4355aaef..d7107b35 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -85,7 +85,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
       # todo: test this
       touch-type:num <- get t, type:offset
       is-left-click?:bool <- equal touch-type, 65513/mouse-left
-      loop-unless is-left-click?, +next-event:label
+      loop-unless is-left-click?, +next-event
       click-row:num <- get t, row:offset
       click-column:num <- get t, column:offset
       # later exceptions for non-editor touches will go here
@@ -95,7 +95,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
       sandbox-in-focus?:bool <- move-cursor-in-editor screen, current-sandbox, t
       *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus?
       screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-      loop +next-event:label
+      loop +next-event
     }
     # 'resize' event - redraw editor
     # todo: test this after supporting resize in assume-console
@@ -114,7 +114,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
         screen <- render-all screen, env, render-without-moving-cursor
         render-all-on-no-more-events? <- copy 0/false  # full render done
       }
-      loop +next-event:label
+      loop +next-event
     }
     # if it's not global and not a touch event, send to appropriate editor
     {
@@ -129,7 +129,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
         {
           break-unless more-events?
           render-all-on-no-more-events? <- copy 1/true  # no rendering now, full rendering on some future event
-          jump +finish-event:label
+          jump +finish-event
         }
         {
           break-if more-events?
@@ -138,13 +138,13 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
             # no more events, and we have to force render
             screen <- render-all screen, env, render
             render-all-on-no-more-events? <- copy 0/false
-            jump +finish-event:label
+            jump +finish-event
           }
           # no more events, no force render
           {
             break-unless render?
             screen <- render-recipes screen, env, render
-            jump +finish-event:label
+            jump +finish-event
           }
         }
       }
@@ -157,7 +157,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
         {
           break-unless more-events?
           render-all-on-no-more-events? <- copy 1/true  # no rendering now, full rendering on some future event
-          jump +finish-event:label
+          jump +finish-event
         }
         {
           break-if more-events?
@@ -166,13 +166,13 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
             # no more events, and we have to force render
             screen <- render-all screen, env, render
             render-all-on-no-more-events? <- copy 0/false
-            jump +finish-event:label
+            jump +finish-event
           }
           # no more events, no force render
           {
             break-unless render?
             screen <- render-sandbox-side screen, env, render
-            jump +finish-event:label
+            jump +finish-event
           }
         }
       }
@@ -263,7 +263,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:nu
       screen <- move-cursor screen, row, column
       curr <- next curr
       prev <- next prev
-      loop +next-character:label
+      loop +next-character
     }
     {
       # at right? wrap. even if there's only one more letter left; we need
@@ -277,7 +277,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:nu
       row <- add row, 1
       screen <- move-cursor screen, row, column
       # don't increment curr
-      loop +next-character:label
+      loop +next-character
     }
     print screen, c, color
     curr <- next curr
@@ -564,7 +564,7 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num
       column <- copy left
       row <- add row, 1
       screen <- move-cursor screen, row, column
-      loop +next-character:label  # retry i
+      loop +next-character  # retry i
     }
     i <- add i, 1
     {
@@ -583,7 +583,7 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num
       row <- add row, 1
       column <- copy left
       screen <- move-cursor screen, row, column
-      loop +next-character:label
+      loop +next-character
     }
     print screen, c, color
     column <- add column, 1
@@ -606,7 +606,7 @@ after <global-type> [
     break-unless redraw-screen?
     screen <- render-all screen, env:&:environment, render
     sync-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
@@ -621,7 +621,7 @@ after <global-type> [
     sandbox-in-focus? <- not sandbox-in-focus?
     *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus?
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index 1b9343a5..bc0488f7 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -137,7 +137,7 @@ after <global-keypress> [
       screen <- update-status screen, [                 ], 245/grey
     }
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
@@ -380,7 +380,7 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num
       column <- copy left
       row <- add row, 1
       screen <- move-cursor screen, row, column
-      loop +next-character:label  # retry i
+      loop +next-character  # retry i
     }
     i <- add i, 1
     {
@@ -399,7 +399,7 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num
       row <- add row, 1
       column <- copy left
       screen <- move-cursor screen, row, column
-      loop +next-character:label
+      loop +next-character
     }
     print screen, c, color
     column <- add column, 1
@@ -706,7 +706,7 @@ after <global-keypress> [
     break-unless at-bottom-of-editor?
     more-to-scroll?:bool <- more-to-scroll? env, screen
     break-if more-to-scroll?
-    loop +next-event:label
+    loop +next-event
   }
   {
     break-if sandbox-in-focus?
@@ -714,7 +714,7 @@ after <global-keypress> [
     break-unless page-down?
     more-to-scroll?:bool <- more-to-scroll? env, screen
     break-if more-to-scroll?
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
@@ -725,7 +725,7 @@ after <global-type> [
     break-unless page-down?
     more-to-scroll?:bool <- more-to-scroll? env, screen
     break-if more-to-scroll?
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
@@ -863,14 +863,14 @@ after <global-keypress> [
       number-of-sandboxes:num <- get *env, number-of-sandboxes:offset
       max:num <- subtract number-of-sandboxes, 1
       at-end?:bool <- greater-or-equal render-from, max
-      jump-if at-end?, +finish-event:label  # render nothing
+      jump-if at-end?, +finish-event  # render nothing
       render-from <- add render-from, 1
       *env <- put *env, render-from:offset, render-from
     }
     hide-screen screen
     screen <- render-sandbox-side screen, env, render
     show-screen screen
-    jump +finish-event:label
+    jump +finish-event
   }
 ]
 
@@ -901,7 +901,7 @@ after <global-keypress> [
     hide-screen screen
     screen <- render-sandbox-side screen, env, render
     show-screen screen
-    jump +finish-event:label
+    jump +finish-event
   }
 ]
 
diff --git a/edit/006-sandbox-copy.mu b/edit/006-sandbox-copy.mu
index 404601cd..e3f7fe55 100644
--- a/edit/006-sandbox-copy.mu
+++ b/edit/006-sandbox-copy.mu
@@ -136,7 +136,7 @@ after <global-touch> [
     screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu
index 0458449e..c7c01451 100644
--- a/edit/007-sandbox-delete.mu
+++ b/edit/007-sandbox-delete.mu
@@ -74,7 +74,7 @@ after <global-touch> [
     screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
diff --git a/edit/008-sandbox-edit.mu b/edit/008-sandbox-edit.mu
index 0bdc7db5..5ca39e14 100644
--- a/edit/008-sandbox-edit.mu
+++ b/edit/008-sandbox-edit.mu
@@ -131,7 +131,7 @@ after <global-touch> [
     screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu
index 564c6cf9..fe9ef059 100644
--- a/edit/009-sandbox-test.mu
+++ b/edit/009-sandbox-test.mu
@@ -134,7 +134,7 @@ after <global-touch> [
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     # no change in cursor
     show-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
@@ -197,7 +197,7 @@ after <render-sandbox-response> [
       break-unless response-is-expected?:bool
       row, screen <- render-text screen, sandbox-response, left, right, 2/green, row
     }
-    jump +render-sandbox-end:label
+    jump +render-sandbox-end
   }
 ]
 
diff --git a/edit/010-sandbox-trace.mu b/edit/010-sandbox-trace.mu
index 1de23a3b..90ee417e 100644
--- a/edit/010-sandbox-trace.mu
+++ b/edit/010-sandbox-trace.mu
@@ -197,7 +197,7 @@ after <global-touch> [
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     # no change in cursor
     show-screen screen
-    loop +next-event:label
+    loop +next-event
   }
 ]
 
diff --git a/edit/011-errors.mu b/edit/011-errors.mu
index d53fa80d..c0d4a63b 100644
--- a/edit/011-errors.mu
+++ b/edit/011-errors.mu
@@ -110,7 +110,7 @@ after <render-sandbox-trace-done> [
     *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0  # no response
     row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row
     # don't try to print anything more for this sandbox
-    jump +render-sandbox-end:label
+    jump +render-sandbox-end
   }
 ]
 
diff --git a/edit/012-editor-undo.mu b/edit/012-editor-undo.mu
index 9ea67e03..d991b25f 100644
--- a/edit/012-editor-undo.mu
+++ b/edit/012-editor-undo.mu
@@ -162,7 +162,7 @@ before <insert-character-end> [
     typing <- put typing, after-column:offset, cursor-column
     typing <- put typing, after-top-of-screen:offset, top-after
     *op <- merge 0/insert-operation, typing
-    break +done-adding-insert-operation:label
+    break +done-adding-insert-operation
   }
   # if not, create a new operation
   insert-from:&:duplex-list:char <- next cursor-before
@@ -742,7 +742,7 @@ before <move-cursor-end> [
     move <- put move, after-column:offset, cursor-column
     move <- put move, after-top-of-screen:offset, top-after
     *op <- merge 1/move-operation, move
-    break +done-adding-move-operation:label
+    break +done-adding-move-operation
   }
   op:&:operation <- new operation:type
   *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag
@@ -1643,7 +1643,7 @@ before <backspace-character-end> [
       deletion <- put deletion, after-column:offset, cursor-column
       deletion <- put deletion, after-top-of-screen:offset, top-after
       *op <- merge 2/delete-operation, deletion
-      break +done-adding-backspace-operation:label
+      break +done-adding-backspace-operation
     }
     # if not, create a new operation
     op:&:operation <- new operation:type
@@ -1870,7 +1870,7 @@ before <delete-character-end> [
       deletion <- put deletion, after-column:offset, cursor-column
       deletion <- put deletion, after-top-of-screen:offset, top-after
       *op <- merge 2/delete-operation, deletion
-      break +done-adding-delete-operation:label
+      break +done-adding-delete-operation
     }
     # if not, create a new operation
     op:&:operation <- new operation:type