about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-09 21:44:38 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-09 21:44:38 -0800
commitf20984f44aed4b961868feb0276d4635398ebbf8 (patch)
treed5923450df729fb10803d1403541201fdda6db66
parent7e4f8983f8d7357d576bc51a32f49159c0c82203 (diff)
downloadmu-f20984f44aed4b961868feb0276d4635398ebbf8.tar.gz
7220
Even this isn't enough. While shallow copies keep us from transferring
new bindings to callers, the screen object is still the same, so mutations
to bindings are contagious.

Basically I'm losing IQ points from programming in a language that encourages
mutation over copying.
-rw-r--r--apps/tile/environment.mu17
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index f392a6f6..0be875e9 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1342,7 +1342,10 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
         break-if-=
 #?         print-string 0, "sub 1 bindings: "
 #?         dump-table bindings
-        evaluate functions, bindings, first-line, prev-word, stack
+        var bindings2-storage: table
+        var bindings2/ebx: (addr table) <- address bindings2-storage
+        shallow-copy-table-values bindings, bindings2
+        evaluate functions, bindings2, first-line, prev-word, stack
       }
 #?       print-string 0, "sub 2 bindings: "
 #?       dump-table bindings
@@ -1454,14 +1457,18 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
 #?   dump-table bindings
   var max-width/esi: int <- copy 0
   {
-    # indent stack
-    var indented-col/ebx: int <- copy left-col
-    indented-col <- add 1  # margin-right
     # compute stack
     var stack: value-stack
     var stack-addr/edi: (addr value-stack) <- address stack
     initialize-value-stack stack-addr, 0x10  # max-words
-    evaluate functions, bindings, first-line, final-word, stack-addr
+    # copy bindings
+    var bindings2-storage: table
+    var bindings2/ebx: (addr table) <- address bindings2-storage
+    shallow-copy-table-values bindings, bindings2
+    evaluate functions, bindings2, first-line, final-word, stack-addr
+    # indent stack
+    var indented-col/ebx: int <- copy left-col
+    indented-col <- add 1  # margin-right
     # render stack
     var curr-row/edx: int <- copy top-row
     curr-row <- add 2  # stack-margin-top