about summary refs log tree commit diff stats
path: root/html/081run_interactive.cc.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/081run_interactive.cc.html')
-rw-r--r--html/081run_interactive.cc.html287
1 files changed, 188 insertions, 99 deletions
diff --git a/html/081run_interactive.cc.html b/html/081run_interactive.cc.html
index 79db9059..3802f61a 100644
--- a/html/081run_interactive.cc.html
+++ b/html/081run_interactive.cc.html
@@ -13,8 +13,8 @@
 pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
 body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 * { font-size: 1.05em; }
-.cSpecial { color: #008000; }
 .traceContains { color: #008000; }
+.cSpecial { color: #008000; }
 .Comment { color: #9090ff; }
 .Delimiter { color: #a04060; }
 .Special { color: #ff6060; }
@@ -36,46 +36,53 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 
 <span class="Delimiter">:(scenario run_interactive_code)</span>
 recipe main [
+  <span class="Constant">1</span>:number/<span class="Special">raw &lt;- </span>copy <span class="Constant">0</span>
   <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new [<span class="Constant">1</span>:number/<span class="Special">raw &lt;- </span>copy <span class="Constant">34</span>]
   run-interactive <span class="Constant">2</span>:address:array:character
+  <span class="Constant">3</span>:number/<span class="Special">raw &lt;- </span>copy <span class="Constant">1</span>:number/<span class="Special">raw</span>
 ]
-<span class="traceContains">+mem: storing 34 in location 1</span>
+<span class="traceContains">+mem: storing 34 in location 3</span>
 
 <span class="Delimiter">:(scenario run_interactive_empty)</span>
 recipe main [
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">0</span>
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>/<span class="Special">raw</span>
+  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">1</span>:address:array:character
 ]
 <span class="Comment"># result is null</span>
-<span class="traceContains">+mem: storing 0 in location 1</span>
+<span class="traceContains">+mem: storing 0 in location 2</span>
 
-<span class="Comment">//: run code in 'interactive mode', i.e. with warnings off and return:</span>
+<span class="Comment">//: run code in 'interactive mode', i.e. with errors+warnings off and return:</span>
 <span class="Comment">//:   stringified output in case we want to print it to screen</span>
-<span class="Comment">//:   any warnings encountered</span>
+<span class="Comment">//:   any errors+warnings encountered</span>
 <span class="Comment">//:   simulated screen any prints went to</span>
 <span class="Comment">//:   any 'app' layer traces generated</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
 RUN_INTERACTIVE<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;run-interactive&quot;</span>] = RUN_INTERACTIVE<span class="Delimiter">;</span>
-<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;run-interactive&quot;</span><span class="Delimiter">,</span> RUN_INTERACTIVE<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
 case RUN_INTERACTIVE: <span class="Delimiter">{</span>
-  if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: 'run-interactive' requires exactly one ingredient, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    raise_error &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;'run-interactive' requires exactly one ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
-  if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
-    raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: first ingredient of 'run-interactive' should be a string, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>!is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
+    raise_error &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;first ingredient of 'run-interactive' should be a string, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
+case RUN_INTERACTIVE: <span class="Delimiter">{</span>
   bool new_code_pushed_to_stack = run_interactive<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
   if <span class="Delimiter">(</span>!new_code_pushed_to_stack<span class="Delimiter">)</span> <span class="Delimiter">{</span>
     products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">5</span><span class="Delimiter">);</span>
     products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
-    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_contents<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">));</span>
+    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_error_warning_contents<span class="Delimiter">());</span>
     products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
-    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_contents<span class="Delimiter">(</span><span class="Constant">&quot;app&quot;</span><span class="Delimiter">));</span>
+    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_app_contents<span class="Delimiter">());</span>
     products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>  <span class="Comment">// completed</span>
-    cleanup_run_interactive<span class="Delimiter">();</span>
+    run_code_end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>  <span class="Comment">// done with this instruction</span>
   <span class="Delimiter">}</span>
   else <span class="Delimiter">{</span>
@@ -85,6 +92,9 @@ case RUN_INTERACTIVE: <span class="Delimiter">{</span>
 
 <span class="Delimiter">:(before &quot;End Globals&quot;)</span>
 bool Track_most_recent_products = <span class="Constant">false</span><span class="Delimiter">;</span>
+<span class="Delimiter">:(before &quot;End Tracing&quot;)</span>
+trace_stream* Save_trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span>
+string Save_trace_file<span class="Delimiter">;</span>
 <span class="Delimiter">:(before &quot;End Setup&quot;)</span>
 Track_most_recent_products = <span class="Constant">false</span><span class="Delimiter">;</span>
 <span class="Delimiter">:(code)</span>
@@ -92,7 +102,7 @@ Track_most_recent_products = <span class="Constant">false</span><span class="Del
 <span class="Comment">// all warnings.</span>
 <span class="Comment">// returns true if successfully called (no errors found during load and transform)</span>
 bool run_interactive<span class="Delimiter">(</span>long long int address<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-  assert<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">)</span> != Recipe_ordinal<span class="Delimiter">.</span>end<span class="Delimiter">()</span> &amp;&amp; Recipe_ordinal[<span class="Constant">&quot;interactive&quot;</span>] != <span class="Constant">0</span><span class="Delimiter">);</span>
+  assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">)</span> &amp;&amp; get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">);</span>
   <span class="Comment">// try to sandbox the run as best you can</span>
   <span class="Comment">// todo: test this</span>
   if <span class="Delimiter">(</span>!Current_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span>
@@ -101,54 +111,83 @@ bool run_interactive<span class="Delimiter">(</span>long long int address<span c
   <span class="Delimiter">}</span>
   string command = trim<span class="Delimiter">(</span>strip_comments<span class="Delimiter">(</span>read_mu_string<span class="Delimiter">(</span>address<span class="Delimiter">)));</span>
   if <span class="Delimiter">(</span>command<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
-  Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recipe_ordinal[<span class="Constant">&quot;interactive&quot;</span>]<span class="Delimiter">);</span>
-  Name[Recipe_ordinal[<span class="Constant">&quot;interactive&quot;</span>]]<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
-  <span class="Comment">// stuff to undo later, in cleanup_run_interactive()</span>
-  Hide_warnings = <span class="Constant">true</span><span class="Delimiter">;</span>
-  if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    Trace_file = <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>  <span class="Comment">// if there wasn't already a stream we don't want to save it</span>
-    Trace_stream = new trace_stream<span class="Delimiter">;</span>
-    Trace_stream<span class="Delimiter">-&gt;</span>collect_layers<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">);</span>
-    Trace_stream<span class="Delimiter">-&gt;</span>collect_layers<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;app&quot;</span><span class="Delimiter">);</span>
-  <span class="Delimiter">}</span>
+  Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">));</span>
+  Name[get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">)</span>]<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
+  run_code_begin<span class="Delimiter">();</span>
+  <span class="Comment">// don't kill the current routine on parse errors</span>
+  routine* save_current_routine = Current_routine<span class="Delimiter">;</span>
+  Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span>
   <span class="Comment">// call run(string) but without the scheduling</span>
   load<span class="Delimiter">(</span>string<span class="Delimiter">(</span><span class="Constant">&quot;recipe interactive [</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">)</span> +
           <span class="Constant">&quot;local-scope</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
-          <span class="Constant">&quot;screen:address &lt;- next-ingredient</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
+          <span class="Constant">&quot;screen:address:screen &lt;- next-ingredient</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
           <span class="Constant">&quot;$start-tracking-products</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
           command + <span class="Constant">&quot;</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
           <span class="Constant">&quot;$stop-tracking-products</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
           <span class="Constant">&quot;reply screen</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
        <span class="Constant">&quot;]</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">);</span>
   transform_all<span class="Delimiter">();</span>
-  if <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">)</span> &gt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+  Current_routine = save_current_routine<span class="Delimiter">;</span>
+  if <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">&quot;error&quot;</span><span class="Delimiter">)</span> &gt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
   <span class="Comment">// now call 'sandbox' which will run 'interactive' in a separate routine,</span>
   <span class="Comment">// and wait for it</span>
-  Current_routine<span class="Delimiter">-&gt;</span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>Recipe_ordinal[<span class="Constant">&quot;sandbox&quot;</span>]<span class="Delimiter">));</span>
+  if <span class="Delimiter">(</span>Save_trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    ++Save_trace_stream<span class="Delimiter">-&gt;</span>callstack_depth<span class="Delimiter">;</span>
+    trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;trace&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;run-interactive: incrementing callstack depth to &quot;</span> &lt;&lt; Save_trace_stream<span class="Delimiter">-&gt;</span>callstack_depth &lt;&lt; end<span class="Delimiter">();</span>
+    assert<span class="Delimiter">(</span>Save_trace_stream<span class="Delimiter">-&gt;</span>callstack_depth &lt; <span class="Constant">9000</span><span class="Delimiter">);</span>  <span class="Comment">// 9998-101 plus cushion</span>
+  <span class="Delimiter">}</span>
+  Current_routine<span class="Delimiter">-&gt;</span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;sandbox&quot;</span><span class="Delimiter">)));</span>
   <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
 
+void run_code_begin<span class="Delimiter">()</span> <span class="Delimiter">{</span>
+  <span class="Comment">// stuff to undo later, in run_code_end()</span>
+  Hide_warnings = <span class="Constant">true</span><span class="Delimiter">;</span>
+  Hide_errors = <span class="Constant">true</span><span class="Delimiter">;</span>
+  Disable_redefine_warnings = <span class="Constant">true</span><span class="Delimiter">;</span>
+  Save_trace_stream = Trace_stream<span class="Delimiter">;</span>
+  Save_trace_file = Trace_file<span class="Delimiter">;</span>
+  Trace_file = <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>
+  Trace_stream = new trace_stream<span class="Delimiter">;</span>
+  Trace_stream<span class="Delimiter">-&gt;</span>collect_depth = App_depth<span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+
+void run_code_end<span class="Delimiter">()</span> <span class="Delimiter">{</span>
+  Hide_warnings = <span class="Constant">false</span><span class="Delimiter">;</span>
+  Hide_errors = <span class="Constant">false</span><span class="Delimiter">;</span>
+  Disable_redefine_warnings = <span class="Constant">false</span><span class="Delimiter">;</span>
+  delete Trace_stream<span class="Delimiter">;</span>
+  Trace_stream = Save_trace_stream<span class="Delimiter">;</span>
+  Save_trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span>
+  Trace_file = Save_trace_file<span class="Delimiter">;</span>
+  Save_trace_file<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
+<span class="Delimiter">}</span>
+
 <span class="Delimiter">:(before &quot;End Load Recipes&quot;)</span>
 load<span class="Delimiter">(</span>string<span class="Delimiter">(</span>
 <span class="Constant">&quot;recipe interactive [</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">)</span> +  <span class="Comment">// just a dummy version to initialize the Recipe_ordinal and so on</span>
 <span class="Constant">&quot;]</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
 <span class="Constant">&quot;recipe sandbox [</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;local-scope</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
-  <span class="Constant">&quot;screen:address/shared &lt;- new-fake-screen 30, 5</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
-  <span class="Constant">&quot;r:number/routine_id &lt;- start-running interactive:recipe, screen:address</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
+  <span class="Constant">&quot;screen:address:screen/shared &lt;- new-fake-screen 30, 5</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
+  <span class="Constant">&quot;r:number/routine_id &lt;- start-running interactive:recipe, screen</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;limit-time r, 100000/instructions</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;wait-for-routine r</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;sandbox-state:number &lt;- routine-state r/routine_id</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;completed?:boolean &lt;- equal sandbox-state, 1/completed</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;output:address:array:character &lt;- $most-recent-products</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
-  <span class="Constant">&quot;warnings:address:array:character &lt;- save-trace [warn]</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
-  <span class="Constant">&quot;stashes:address:array:character &lt;- save-trace [app]</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
+  <span class="Constant">&quot;warnings:address:array:character &lt;- save-errors-warnings</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
+  <span class="Constant">&quot;stashes:address:array:character &lt;- save-app-trace</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;$cleanup-run-interactive</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
   <span class="Constant">&quot;reply output, warnings, screen, stashes, completed?</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> +
 <span class="Constant">&quot;]</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">);</span>
 transform_all<span class="Delimiter">();</span>
 recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
 
+<span class="Comment">//: adjust errors/warnings in the sandbox</span>
+<span class="Delimiter">:(after &quot;string maybe(string s)&quot;)</span>
+  if <span class="Delimiter">(</span>s == <span class="Constant">&quot;interactive&quot;</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>
+
 <span class="Delimiter">:(scenario run_interactive_comments)</span>
 recipe main [
   <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new [<span class="Comment"># ab</span>
@@ -158,19 +197,14 @@ add <span class="Constant">2</span><span class="Delimiter">,</span> <span class=
 ]
 <span class="traceContains">+mem: storing 52 in location 4</span>
 
-<span class="Delimiter">:(scenario run_interactive_just_comments_without_trace)</span>
-recipe main [
-  $close-trace
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new [<span class="Comment"># ab</span>
-]
-  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">1</span>:address:array:character
-  <span class="Constant">3</span>:array:character<span class="Special"> &lt;- </span>copy *<span class="Constant">2</span>:address:array:character
-]
-
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
 _START_TRACKING_PRODUCTS<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;$start-tracking-products&quot;</span>] = _START_TRACKING_PRODUCTS<span class="Delimiter">;</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;$start-tracking-products&quot;</span><span class="Delimiter">,</span> _START_TRACKING_PRODUCTS<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case _START_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
 case _START_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
   Track_most_recent_products = <span class="Constant">true</span><span class="Delimiter">;</span>
@@ -180,7 +214,11 @@ case _START_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
 _STOP_TRACKING_PRODUCTS<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;$stop-tracking-products&quot;</span>] = _STOP_TRACKING_PRODUCTS<span class="Delimiter">;</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;$stop-tracking-products&quot;</span><span class="Delimiter">,</span> _STOP_TRACKING_PRODUCTS<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case _STOP_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
 case _STOP_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
   Track_most_recent_products = <span class="Constant">false</span><span class="Delimiter">;</span>
@@ -190,7 +228,11 @@ case _STOP_TRACKING_PRODUCTS: <span class="Delimiter">{</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
 _MOST_RECENT_PRODUCTS<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;$most-recent-products&quot;</span>] = _MOST_RECENT_PRODUCTS<span class="Delimiter">;</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;$most-recent-products&quot;</span><span class="Delimiter">,</span> _MOST_RECENT_PRODUCTS<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case _MOST_RECENT_PRODUCTS: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
 case _MOST_RECENT_PRODUCTS: <span class="Delimiter">{</span>
   products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
@@ -199,33 +241,47 @@ case _MOST_RECENT_PRODUCTS: <span class="Delimiter">{</span>
 <span class="Delimiter">}</span>
 
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
-SAVE_TRACE<span class="Delimiter">,</span>
+SAVE_ERRORS_WARNINGS<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;save-trace&quot;</span>] = SAVE_TRACE<span class="Delimiter">;</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;save-errors-warnings&quot;</span><span class="Delimiter">,</span> SAVE_ERRORS_WARNINGS<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case SAVE_ERRORS_WARNINGS: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
-case SAVE_TRACE: <span class="Delimiter">{</span>
+case SAVE_ERRORS_WARNINGS: <span class="Delimiter">{</span>
   products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
-  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_contents<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">));</span>
+  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_error_warning_contents<span class="Delimiter">());</span>
   <span class="Identifier">break</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
 
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
-_CLEANUP_RUN_INTERACTIVE<span class="Delimiter">,</span>
+SAVE_APP_TRACE<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;$cleanup-run-interactive&quot;</span>] = _CLEANUP_RUN_INTERACTIVE<span class="Delimiter">;</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;save-app-trace&quot;</span><span class="Delimiter">,</span> SAVE_APP_TRACE<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case SAVE_APP_TRACE: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
-case _CLEANUP_RUN_INTERACTIVE: <span class="Delimiter">{</span>
-  cleanup_run_interactive<span class="Delimiter">();</span>
+case SAVE_APP_TRACE: <span class="Delimiter">{</span>
+  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
+  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_app_contents<span class="Delimiter">());</span>
   <span class="Identifier">break</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
 
-<span class="Delimiter">:(code)</span>
-void cleanup_run_interactive<span class="Delimiter">()</span> <span class="Delimiter">{</span>
-  Hide_warnings = <span class="Constant">false</span><span class="Delimiter">;</span>
-  if <span class="Delimiter">(</span>Trace_stream &amp;&amp; Trace_stream<span class="Delimiter">-&gt;</span>is_narrowly_collecting<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>  <span class="Comment">// hack</span>
-    delete Trace_stream<span class="Delimiter">;</span>
-    Trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span>
-  <span class="Delimiter">}</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
+_CLEANUP_RUN_INTERACTIVE<span class="Delimiter">,</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;$cleanup-run-interactive&quot;</span><span class="Delimiter">,</span> _CLEANUP_RUN_INTERACTIVE<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
+case _CLEANUP_RUN_INTERACTIVE: <span class="Delimiter">{</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
+case _CLEANUP_RUN_INTERACTIVE: <span class="Delimiter">{</span>
+  run_code_end<span class="Delimiter">();</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
 
 <span class="Delimiter">:(scenario &quot;run_interactive_returns_stringified_result&quot;)</span>
@@ -242,9 +298,9 @@ recipe main [
 recipe main [
   <span class="Comment"># try to interactively add 2 and 2</span>
   <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new [
-    <span class="Constant">100</span>:address:array:character<span class="Special"> &lt;- </span>new [a]
-    <span class="Constant">101</span>:address:array:character<span class="Special"> &lt;- </span>new [b]
-    <span class="Constant">102</span>:address:array:character<span class="Special"> &lt;- </span>string-append <span class="Constant">100</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">101</span>:address:array:character
+    x:address:array:character<span class="Special"> &lt;- </span>new [a]
+    y:address:array:character<span class="Special"> &lt;- </span>new [b]
+    z:address:array:character<span class="Special"> &lt;- </span>string-append x:address:array:character<span class="Delimiter">,</span> y:address:array:character
   ]
   <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">1</span>:address:array:character
   <span class="Constant">10</span>:array:character<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>:address:array:character/lookup
@@ -253,18 +309,31 @@ recipe main [
 <span class="traceContains">+mem: storing 97 in location 11</span>
 <span class="traceContains">+mem: storing 98 in location 12</span>
 
-<span class="Delimiter">:(scenario &quot;run_interactive_returns_warnings&quot;)</span>
+<span class="Delimiter">:(scenario &quot;run_interactive_returns_errors&quot;)</span>
 recipe main [
-  <span class="Comment"># run a command that generates a warning</span>
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new [get <span class="Constant">1234</span>:number<span class="Delimiter">,</span> foo:offset]
+  <span class="Comment"># run a command that generates an error</span>
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new [x:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+get x:number<span class="Delimiter">,</span> foo:offset]
   <span class="Constant">2</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">1</span>:address:array:character
   <span class="Constant">10</span>:array:character<span class="Special"> &lt;- </span>copy <span class="Constant">3</span>:address:array:character/lookup
 ]
-<span class="Comment"># warning should be &quot;unknown element foo in container number&quot;</span>
+<span class="Comment"># error should be &quot;unknown element foo in container number&quot;</span>
 <span class="traceContains">+mem: storing 117 in location 11</span>
 <span class="traceContains">+mem: storing 110 in location 12</span>
 <span class="traceContains">+mem: storing 107 in location 13</span>
 <span class="traceContains">+mem: storing 110 in location 14</span>
+<span class="Comment"># ...</span>
+
+<span class="Delimiter">:(scenario run_interactive_with_comment)</span>
+recipe main [
+  <span class="Comment"># 2 instructions, with a comment after the first</span>
+  <span class="Constant">1</span>:address:array:number<span class="Special"> &lt;- </span>new [a:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># abc</span>
+b:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+]
+  <span class="Constant">2</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:array:character<span class="Special"> &lt;- </span>run-interactive <span class="Constant">1</span>:address:array:character
+]
+<span class="Comment"># no errors</span>
+<span class="traceContains">+mem: storing 0 in location 3</span>
 
 <span class="Delimiter">:(before &quot;End Globals&quot;)</span>
 string Most_recent_products<span class="Delimiter">;</span>
@@ -283,10 +352,10 @@ void track_most_recent_products<span class="Delimiter">(</span>const instruction
       if <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span>
         if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span>
           tb_shutdown<span class="Delimiter">();</span>
-          cerr &lt;&lt; read_mu_string<span class="Delimiter">(</span>trace_contents<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">))</span> &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
+          cerr &lt;&lt; read_mu_string<span class="Delimiter">(</span>trace_error_warning_contents<span class="Delimiter">())</span> &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
           cerr &lt;&lt; SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> &lt;&lt; <span class="Constant">&quot;: &quot;</span><span class="Delimiter">;</span>
           for <span class="Delimiter">(</span>long long int j = <span class="Constant">0</span><span class="Delimiter">;</span> j &lt; SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span>
-            cerr &lt;&lt; products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">' '</span><span class="Delimiter">;</span>
+            cerr &lt;&lt; no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> &lt;&lt; <span class="Constant">' '</span><span class="Delimiter">;</span>
           cerr &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
         <span class="Delimiter">}</span>
         assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)));</span>
@@ -296,7 +365,7 @@ void track_most_recent_products<span class="Delimiter">(</span>const instruction
       <span class="Comment">// End Record Product Special-cases</span>
     <span class="Delimiter">}</span>
     for <span class="Delimiter">(</span>long long int j = <span class="Constant">0</span><span class="Delimiter">;</span> j &lt; SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span>
-      out &lt;&lt; products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">' '</span><span class="Delimiter">;</span>
+      out &lt;&lt; no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> &lt;&lt; <span class="Constant">' '</span><span class="Delimiter">;</span>
     out &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
   Most_recent_products = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
@@ -310,7 +379,7 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim
       result &lt;&lt; in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
     <span class="Delimiter">}</span>
     else <span class="Delimiter">{</span>
-      while <span class="Delimiter">(</span>i &lt; SIZE<span class="Delimiter">(</span>in<span class="Delimiter">)</span> &amp;&amp; in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span>
+      while <span class="Delimiter">(</span>i+<span class="Constant">1</span> &lt; SIZE<span class="Delimiter">(</span>in<span class="Delimiter">)</span> &amp;&amp; in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i+<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span>
         ++i<span class="Delimiter">;</span>
     <span class="Delimiter">}</span>
   <span class="Delimiter">}</span>
@@ -320,21 +389,34 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim
 long long int stringified_value_of_location<span class="Delimiter">(</span>long long int address<span class="Delimiter">)</span> <span class="Delimiter">{</span>
   <span class="Comment">// convert to string</span>
   ostringstream out<span class="Delimiter">;</span>
-  out &lt;&lt; Memory[address]<span class="Delimiter">;</span>
+  out &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">));</span>
   <span class="Identifier">return</span> new_mu_string<span class="Delimiter">(</span>out<span class="Delimiter">.</span>str<span class="Delimiter">());</span>
 <span class="Delimiter">}</span>
 
-long long int trace_contents<span class="Delimiter">(</span>const string&amp; layer<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+long long int trace_error_warning_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span>
+  if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
+  ostringstream out<span class="Delimiter">;</span>
+  for <span class="Delimiter">(</span>vector&lt;trace_line&gt;::iterator p = Trace_stream<span class="Delimiter">-&gt;</span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-&gt;</span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    if <span class="Delimiter">(</span>p<span class="Delimiter">-&gt;</span>depth &gt; Warning_depth<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
+    out &lt;&lt; p<span class="Delimiter">-&gt;</span>contents<span class="Delimiter">;</span>
+    if <span class="Delimiter">(</span>*--p<span class="Delimiter">-&gt;</span>contents<span class="Delimiter">.</span>end<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+  string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
+  truncate<span class="Delimiter">(</span>result<span class="Delimiter">);</span>
+  <span class="Identifier">return</span> new_mu_string<span class="Delimiter">(</span>result<span class="Delimiter">);</span>
+<span class="Delimiter">}</span>
+
+long long int trace_app_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span>
   if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
-  if <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span>layer<span class="Delimiter">)</span> &lt;= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
   ostringstream out<span class="Delimiter">;</span>
   for <span class="Delimiter">(</span>vector&lt;trace_line&gt;::iterator p = Trace_stream<span class="Delimiter">-&gt;</span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-&gt;</span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    if <span class="Delimiter">(</span>p<span class="Delimiter">-&gt;</span>label != layer<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
+    if <span class="Delimiter">(</span>p<span class="Delimiter">-&gt;</span>depth != App_depth<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
     out &lt;&lt; p<span class="Delimiter">-&gt;</span>contents<span class="Delimiter">;</span>
     if <span class="Delimiter">(</span>*--p<span class="Delimiter">-&gt;</span>contents<span class="Delimiter">.</span>end<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
   string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
-  assert<span class="Delimiter">(</span>!result<span class="Delimiter">.</span>empty<span class="Delimiter">());</span>
+  if <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
   truncate<span class="Delimiter">(</span>result<span class="Delimiter">);</span>
   <span class="Identifier">return</span> new_mu_string<span class="Delimiter">(</span>result<span class="Delimiter">);</span>
 <span class="Delimiter">}</span>
@@ -349,51 +431,58 @@ void truncate<span class="Delimiter">(</span>string&amp; x<span class="Delimiter
 <span class="Delimiter">}</span>
 
 <span class="Comment">//: simpler version of run-interactive: doesn't do any running, just loads</span>
-<span class="Comment">//: recipes and reports warnings.</span>
+<span class="Comment">//: recipes and reports errors+warnings.</span>
+
 <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
 RELOAD<span class="Delimiter">,</span>
 <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
-Recipe_ordinal[<span class="Constant">&quot;reload&quot;</span>] = RELOAD<span class="Delimiter">;</span>
-<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
+put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;reload&quot;</span><span class="Delimiter">,</span> RELOAD<span class="Delimiter">);</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
 case RELOAD: <span class="Delimiter">{</span>
-  if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: 'reload' requires exactly one ingredient, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    raise_error &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;'reload' requires exactly one ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
-  if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
-    raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: first ingredient of 'reload' should be a literal string, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>!is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
+    raise_error &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;first ingredient of 'reload' should be a string, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Identifier">break</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
-  if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    Trace_file = <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>  <span class="Comment">// if there wasn't already a stream we don't want to save it</span>
-    Trace_stream = new trace_stream<span class="Delimiter">;</span>
-    Trace_stream<span class="Delimiter">-&gt;</span>collect_layers<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">);</span>
-  <span class="Delimiter">}</span>
-  Hide_warnings = <span class="Constant">true</span><span class="Delimiter">;</span>
-  Disable_redefine_warnings = <span class="Constant">true</span><span class="Delimiter">;</span>
+  <span class="Identifier">break</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
+case RELOAD: <span class="Delimiter">{</span>
   <span class="Comment">// clear any containers in advance</span>
   for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>recently_added_types<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-    Type_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Type[recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span>]<span class="Delimiter">.</span>name<span class="Delimiter">);</span>
+    Type_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span>
     Type<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span>
   <span class="Delimiter">}</span>
   string code = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
+  run_code_begin<span class="Delimiter">();</span>
+  routine* save_current_routine = Current_routine<span class="Delimiter">;</span>
+  Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span>
   vector&lt;recipe_ordinal&gt; recipes_reloaded = load<span class="Delimiter">(</span>code<span class="Delimiter">);</span>
   for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>recipes_reloaded<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
     Name<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>recipes_reloaded<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span>
   <span class="Delimiter">}</span>
   transform_all<span class="Delimiter">();</span>
   Trace_stream<span class="Delimiter">-&gt;</span>newline<span class="Delimiter">();</span>  <span class="Comment">// flush trace</span>
-  Disable_redefine_warnings = <span class="Constant">false</span><span class="Delimiter">;</span>
-  Hide_warnings = <span class="Constant">false</span><span class="Delimiter">;</span>
+  Current_routine = save_current_routine<span class="Delimiter">;</span>
   products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
-  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_contents<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">));</span>
-  <span class="Comment">// hack: assume collect_layers isn't set anywhere else</span>
-  if <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-&gt;</span>is_narrowly_collecting<span class="Delimiter">(</span><span class="Constant">&quot;warn&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
-    delete Trace_stream<span class="Delimiter">;</span>
-    Trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span>
-  <span class="Delimiter">}</span>
+  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>trace_error_warning_contents<span class="Delimiter">());</span>
+  run_code_end<span class="Delimiter">();</span>  <span class="Comment">// wait until we're done with the trace contents</span>
   <span class="Identifier">break</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
+
+<span class="Delimiter">:(scenario reload_continues_past_error)</span>
+recipe main [
+  local-scope
+  x:address:array:character<span class="Special"> &lt;- </span>new [recipe foo [
+  get <span class="Constant">1234</span>:number<span class="Delimiter">,</span> foo:offset
+]]
+  reload x
+  <span class="Constant">1</span>:number/<span class="Special">raw &lt;- </span>copy <span class="Constant">34</span>
+]
+<span class="traceContains">+mem: storing 34 in location 1</span>
 </pre>
 </body>
 </html>