about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--html/084console.mu.html24
-rw-r--r--html/085scenario_console.cc.html8
-rw-r--r--html/086scenario_console_test.mu.html8
-rw-r--r--html/091socket.cc.html2
-rw-r--r--html/092socket.mu.html35
-rw-r--r--html/edit/002-typing.mu.html2
-rw-r--r--html/edit/004-programming-environment.mu.html2
-rw-r--r--html/http-client.mu.html2
8 files changed, 58 insertions, 25 deletions
diff --git a/html/084console.mu.html b/html/084console.mu.html
index 3af59b06..42938cfe 100644
--- a/html/084console.mu.html
+++ b/html/084console.mu.html
@@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">events:offset</span>, events
 ]
 
-<span class="muRecipe">def</span> read-event console:&amp;:console<span class="muRecipe"> -&gt; </span>result:event, console:&amp;:console, found?:bool, quit?:bool [
+<span class="muRecipe">def</span> read-event console:&amp;:console<span class="muRecipe"> -&gt; </span>result:event, found?:bool, quit?:bool, console:&amp;:console [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Delimiter">{</span>
@@ -77,37 +77,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
       done?:bool<span class="Special"> &lt;- </span>greater-or-equal current-event-index, max
       <span class="muControl">break-unless</span> done?
       dummy:&amp;:event<span class="Special"> &lt;- </span>new <span class="Constant">event:type</span>
-      <span class="muControl">return</span> *dummy, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">1/quit</span>
+      <span class="muControl">return</span> *dummy, <span class="Constant">1/found</span>, <span class="Constant">1/quit</span>
     <span class="Delimiter">}</span>
     result<span class="Special"> &lt;- </span>index *buf, current-event-index
     current-event-index<span class="Special"> &lt;- </span>add current-event-index, <span class="Constant">1</span>
     *console<span class="Special"> &lt;- </span>put *console, <span class="Constant">current-event-index:offset</span>, current-event-index
-    <span class="muControl">return</span> result, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span>
+    <span class="muControl">return</span> result, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span>
   <span class="Delimiter">}</span>
   switch  <span class="Comment"># real event source is infrequent; avoid polling it too much</span>
   result:event, found?:bool<span class="Special"> &lt;- </span>check-for-interaction
-  <span class="muControl">return</span> result, console/same-as-ingredient:<span class="Constant">0</span>, found?, <span class="Constant">0/quit</span>
+  <span class="muControl">return</span> result, found?, <span class="Constant">0/quit</span>
 ]
 
 <span class="Comment"># variant of read-event for just keyboard events. Discards everything that</span>
 <span class="Comment"># isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get</span>
 <span class="Comment"># newlines, tabs, ctrl-d..</span>
-<span class="muRecipe">def</span> read-key console:&amp;:console<span class="muRecipe"> -&gt; </span>result:char, console:&amp;:console, found?:bool, quit?:bool [
+<span class="muRecipe">def</span> read-key console:&amp;:console<span class="muRecipe"> -&gt; </span>result:char, found?:bool, quit?:bool, console:&amp;:console [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  x:event, console, found?:bool, quit?:bool<span class="Special"> &lt;- </span>read-event console
-  <span class="muControl">return-if</span> quit?, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, found?, quit?
-  <span class="muControl">return-unless</span> found?, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, found?, quit?
+  x:event, found?:bool, quit?:bool, console<span class="Special"> &lt;- </span>read-event console
+  <span class="muControl">return-if</span> quit?, <span class="Constant">0</span>, found?, quit?
+  <span class="muControl">return-unless</span> found?, <span class="Constant">0</span>, found?, quit?
   c:char, converted?:bool<span class="Special"> &lt;- </span>maybe-convert x, <span class="Constant">text:variant</span>
-  <span class="muControl">return-unless</span> converted?, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/found</span>, <span class="Constant">0/quit</span>
-  <span class="muControl">return</span> c, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span>
+  <span class="muControl">return-unless</span> converted?, <span class="Constant">0</span>, <span class="Constant">0/found</span>, <span class="Constant">0/quit</span>
+  <span class="muControl">return</span> c, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span>
 ]
 
 <span class="muRecipe">def</span> send-keys-to-channel console:&amp;:console, chan:&amp;:sink:char, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>console:&amp;:console, chan:&amp;:sink:char, screen:&amp;:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Delimiter">{</span>
-    c:char, console, found?:bool, quit?:bool<span class="Special"> &lt;- </span>read-key console
+    c:char, found?:bool, quit?:bool, console<span class="Special"> &lt;- </span>read-key console
     <span class="muControl">loop-unless</span> found?
     <span class="muControl">break-if</span> quit?
     assert c, <span class="Constant">[invalid event, expected text]</span>
@@ -122,7 +122,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Delimiter">{</span>
-    _, console, found?:bool<span class="Special"> &lt;- </span>read-event console
+    _, found?:bool<span class="Special"> &lt;- </span>read-event console
     <span class="muControl">loop-unless</span> found?
   <span class="Delimiter">}</span>
 ]
diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html
index 02e4cbea..406135c9 100644
--- a/html/085scenario_console.cc.html
+++ b/html/085scenario_console.cc.html
@@ -49,10 +49,10 @@ recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class=
     type [abc]
   ]
   run [
-    <span class="Constant">1</span>:<span class="Normal">char</span><span class="Delimiter">,</span> console<span class="Delimiter">,</span> <span class="Constant">2</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">3</span>:<span class="Normal">char</span><span class="Delimiter">,</span> console<span class="Delimiter">,</span> <span class="Constant">4</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">5</span>:<span class="Normal">char</span><span class="Delimiter">,</span> console<span class="Delimiter">,</span> <span class="Constant">6</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">7</span>:<span class="Normal">char</span><span class="Delimiter">,</span> console<span class="Delimiter">,</span> <span class="Constant">8</span>:<span class="Normal">bool</span><span class="Delimiter">,</span> <span class="Constant">9</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">1</span>:<span class="Normal">char</span><span class="Delimiter">,</span> <span class="Constant">2</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">3</span>:<span class="Normal">char</span><span class="Delimiter">,</span> <span class="Constant">4</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">5</span>:<span class="Normal">char</span><span class="Delimiter">,</span> <span class="Constant">6</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">7</span>:<span class="Normal">char</span><span class="Delimiter">,</span> <span class="Constant">8</span>:<span class="Normal">bool</span><span class="Delimiter">,</span> <span class="Constant">9</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>read-key console
   ]
   memory-should-contain [
     <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
diff --git a/html/086scenario_console_test.mu.html b/html/086scenario_console_test.mu.html
index 47898aa1..b8922ca0 100644
--- a/html/086scenario_console_test.mu.html
+++ b/html/086scenario_console_test.mu.html
@@ -37,10 +37,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
     type <span class="Constant">[abc]</span>
   ]
   run [
-    <span class="Constant">1</span>:char, console, <span class="Constant">2</span>:bool<span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">3</span>:char, console, <span class="Constant">4</span>:bool<span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">5</span>:char, console, <span class="Constant">6</span>:bool<span class="Special"> &lt;- </span>read-key console
-    <span class="Constant">7</span>:char, console, <span class="Constant">8</span>:bool<span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">1</span>:char, <span class="Constant">2</span>:bool<span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">3</span>:char, <span class="Constant">4</span>:bool<span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">5</span>:char, <span class="Constant">6</span>:bool<span class="Special"> &lt;- </span>read-key console
+    <span class="Constant">7</span>:char, <span class="Constant">8</span>:bool<span class="Special"> &lt;- </span>read-key console
   ]
   memory-should-contain [
     <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
diff --git a/html/091socket.cc.html b/html/091socket.cc.html
index a81f4c79..67f11eb1 100644
--- a/html/091socket.cc.html
+++ b/html/091socket.cc.html
@@ -236,7 +236,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'$read-from-socket' requires exactly two product, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
+    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'$read-from-socket' requires exactly two products, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_text<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
diff --git a/html/092socket.mu.html b/html/092socket.mu.html
index 186c7c3b..b8c44663 100644
--- a/html/092socket.mu.html
+++ b/html/092socket.mu.html
@@ -92,12 +92,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   ]
 ]
 
-<span class="muRecipe">def</span> start-reading-from-network resources:&amp;:resources, host:text, path:text<span class="muRecipe"> -&gt; </span>contents:&amp;:source:char [
+<span class="muRecipe">def</span> start-reading-from-network resources:&amp;:resources, uri:text<span class="muRecipe"> -&gt; </span>contents:&amp;:source:char [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Delimiter">{</span>
     <span class="muControl">break-if</span> resources
     <span class="Comment"># real network</span>
+    host:text, path:text<span class="Special"> &lt;- </span>split-at uri, <span class="Constant">47/slash</span>
     socket:num<span class="Special"> &lt;- </span>$open-client-socket host, <span class="Constant">80/http-port</span>
     assert socket, <span class="Constant">[contents]</span>
     req:text<span class="Special"> &lt;- </span>interpolate <span class="Constant">[GET _ HTTP/1.1]</span>, path
@@ -230,6 +231,38 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
     <span class="muControl">loop</span>
   <span class="Delimiter">}</span>
 ]
+
+<span class="Comment"># like split-first, but don't eat the delimiter</span>
+<span class="muRecipe">def</span> split-at text:text, delim:char<span class="muRecipe"> -&gt; </span>x:text, y:text [
+  <span class="Constant">local-scope</span>
+  <span class="Constant">load-ingredients</span>
+  <span class="Comment"># empty text? return empty texts</span>
+  len:num<span class="Special"> &lt;- </span>length *text
+  <span class="Delimiter">{</span>
+    empty?:bool<span class="Special"> &lt;- </span>equal len, <span class="Constant">0</span>
+    <span class="muControl">break-unless</span> empty?
+    x:text<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+    y:text<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+    <span class="muControl">return</span>
+  <span class="Delimiter">}</span>
+  idx:num<span class="Special"> &lt;- </span>find-next text, delim, <span class="Constant">0</span>
+  x:text<span class="Special"> &lt;- </span>copy-range text, <span class="Constant">0</span>, idx
+  y:text<span class="Special"> &lt;- </span>copy-range text, idx, len
+]
+
+<span class="muScenario">scenario</span> text-split-at [
+  <span class="Constant">local-scope</span>
+  x:text<span class="Special"> &lt;- </span>new <span class="Constant">[a/b]</span>
+  run [
+    y:text, z:text<span class="Special"> &lt;- </span>split-at x, <span class="Constant">47/slash</span>
+    <span class="Constant">10</span>:@:char/<span class="Special">raw &lt;- </span>copy *y
+    <span class="Constant">20</span>:@:char/<span class="Special">raw &lt;- </span>copy *z
+  ]
+  memory-should-contain [
+    <span class="Constant">10</span>:array:character<span class="Special"> &lt;- </span><span class="Constant">[a]</span>
+    <span class="Constant">20</span>:array:character<span class="Special"> &lt;- </span><span class="Constant">[/b]</span>
+  ]
+]
 </pre>
 </body>
 </html>
diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html
index a84266ca..88274b46 100644
--- a/html/edit/002-typing.mu.html
+++ b/html/edit/002-typing.mu.html
@@ -55,7 +55,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
     cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span>
     cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span>
     screen<span class="Special"> &lt;- </span>move-cursor screen, cursor-row, cursor-column
-    e:event, console, found?:bool, quit?:bool<span class="Special"> &lt;- </span>read-event console
+    e:event, found?:bool, quit?:bool, console<span class="Special"> &lt;- </span>read-event console
     <span class="muControl">loop-unless</span> found?
     <span class="muControl">break-if</span> quit?  <span class="Comment"># only in tests</span>
     trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span>
diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html
index 0fa7c5d2..6d2d8421 100644
--- a/html/edit/004-programming-environment.mu.html
+++ b/html/edit/004-programming-environment.mu.html
@@ -96,7 +96,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Delimiter">{</span>
     <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span>
 <span class="Constant">    +next-event</span>
-    e:event, console, found?:bool, quit?:bool<span class="Special"> &lt;- </span>read-event console
+    e:event, found?:bool, quit?:bool, console<span class="Special"> &lt;- </span>read-event console
     <span class="muControl">loop-unless</span> found?
     <span class="muControl">break-if</span> quit?  <span class="Comment"># only in tests</span>
     trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span>
diff --git a/html/http-client.mu.html b/html/http-client.mu.html
index 96e87f5c..20691582 100644
--- a/html/http-client.mu.html
+++ b/html/http-client.mu.html
@@ -35,7 +35,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 
 <span class="muRecipe">def</span> main [
   <span class="Constant">local-scope</span>
-  google:&amp;:source:char<span class="Special"> &lt;- </span>start-reading-from-network <span class="Constant">0/real-resources</span>, <span class="Constant">[google.com]</span>, <span class="Constant">[/]</span>
+  google:&amp;:source:char<span class="Special"> &lt;- </span>start-reading-from-network <span class="Constant">0/real-resources</span>, <span class="Constant">[google.com/]</span>
   n:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   buf:&amp;:buffer<span class="Special"> &lt;- </span>new-buffer <span class="Constant">30</span>
   <span class="Delimiter">{</span>