about summary refs log tree commit diff stats
path: root/061text.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-17 00:05:38 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-17 00:29:22 -0700
commitdd66068298b0a11f2a1f195376cba98e0c8570b5 (patch)
tree06696728fd65cdf38a2ac571943e130e9d60c333 /061text.mu
parentb89b822439f47a490a1b764e14a1ed1b73059cba (diff)
downloadmu-dd66068298b0a11f2a1f195376cba98e0c8570b5.tar.gz
4261 - start using literals for 'true' and 'false'
They uncovered one bug: in edit/003-shortcuts.mu
  <scroll-down> was returning 0 for an address in one place where I
  thought it was returning 0 for a boolean.

Now we've eliminated this bad interaction between tangling and punning
literals.
Diffstat (limited to '061text.mu')
-rw-r--r--061text.mu20
1 files changed, 10 insertions, 10 deletions
diff --git a/061text.mu b/061text.mu
index ffc87140..8ef19a9d 100644
--- a/061text.mu
+++ b/061text.mu
@@ -5,15 +5,15 @@ def equal a:text, b:text -> result:bool [
   load-inputs
   an:num, bn:num <- deaddress a, b
   address-equal?:boolean <- equal an, bn
-  return-if address-equal?, 1/true
-  return-unless a, 0/false
-  return-unless b, 0/false
+  return-if address-equal?, true
+  return-unless a, false
+  return-unless b, false
   a-len:num <- length *a
   b-len:num <- length *b
   # compare lengths
   trace 99, [text-equal], [comparing lengths]
   length-equal?:bool <- equal a-len, b-len
-  return-unless length-equal?, 0/false
+  return-unless length-equal?, false
   # compare each corresponding character
   trace 99, [text-equal], [comparing characters]
   i:num <- copy 0
@@ -23,11 +23,11 @@ def equal a:text, b:text -> result:bool [
     a2:char <- index *a, i
     b2:char <- index *b, i
     chars-match?:bool <- equal a2, b2
-    return-unless chars-match?, 0/false
+    return-unless chars-match?, false
     i <- add i, 1
     loop
   }
-  return 1/true
+  return true
 ]
 
 scenario text-equal-reflexive [
@@ -358,7 +358,7 @@ def buffer-to-array in:&:buffer:_elem -> result:&:@:_elem [
 def blank? x:&:@:_elem -> result:bool [
   local-scope
   load-inputs
-  return-unless x, 1/true
+  return-unless x, true
   len:num <- length *x
   result <- equal len, 0
 ]
@@ -997,7 +997,7 @@ def match-at text:text, pattern:text, idx:num -> result:bool [
   x:num <- length *text
   x <- subtract x, pattern-len
   enough-room?:bool <- lesser-or-equal idx, x
-  return-unless enough-room?, 0/not-found
+  return-unless enough-room?, false/not-found
   # check each character of pattern
   pattern-idx:num <- copy 0
   {
@@ -1006,12 +1006,12 @@ def match-at text:text, pattern:text, idx:num -> result:bool [
     c:char <- index *text, idx
     exp:char <- index *pattern, pattern-idx
     match?:bool <- equal c, exp
-    return-unless match?, 0/not-found
+    return-unless match?, false/not-found
     idx <- add idx, 1
     pattern-idx <- add pattern-idx, 1
     loop
   }
-  return 1/found
+  return true/found
 ]
 
 scenario match-at-checks-pattern-at-index [