diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/088file.mu.html | 65 | ||||
-rw-r--r-- | html/090scenario_filesystem_test.mu.html | 17 | ||||
-rw-r--r-- | html/092socket.mu.html | 2 | ||||
-rw-r--r-- | html/101run_sandboxed.cc.html | 2 | ||||
-rw-r--r-- | html/102persist.cc.html | 154 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 81 | ||||
-rw-r--r-- | html/edit/005-sandbox.mu.html | 170 | ||||
-rw-r--r-- | html/edit/006-sandbox-copy.mu.html | 128 | ||||
-rw-r--r-- | html/edit/007-sandbox-delete.mu.html | 42 | ||||
-rw-r--r-- | html/edit/008-sandbox-edit.mu.html | 108 | ||||
-rw-r--r-- | html/edit/009-sandbox-test.mu.html | 45 | ||||
-rw-r--r-- | html/edit/010-sandbox-trace.mu.html | 90 | ||||
-rw-r--r-- | html/edit/011-errors.mu.html | 341 |
13 files changed, 602 insertions, 643 deletions
diff --git a/html/088file.mu.html b/html/088file.mu.html index 49801745..aae7cae6 100644 --- a/html/088file.mu.html +++ b/html/088file.mu.html @@ -33,6 +33,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <pre id='vimCodeElement'> <span class="Comment"># Wrappers around file system primitives that take a 'resources' object and</span> <span class="Comment"># are thus easier to test.</span> +<span class="Comment">#</span> +<span class="Comment"># - start-reading - asynchronously open a file, returning a channel source for</span> +<span class="Comment"># receiving the results</span> +<span class="Comment"># - start-writing - asynchronously open a file, returning a channel sink for</span> +<span class="Comment"># the data to write</span> +<span class="Comment"># - slurp - synchronously read from a file</span> +<span class="Comment"># - dump - synchronously write to a file</span> <span class="muData">container</span> resources [ lock:bool @@ -44,25 +51,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color contents:text ] -<span class="muRecipe">def</span> start-reading resources:&:resources, filename:text<span class="muRecipe"> -> </span>contents:&:source:char [ +<span class="muRecipe">def</span> start-reading resources:&:resources, filename:text<span class="muRecipe"> -> </span>contents:&:source:char, error?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + error? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> resources <span class="Comment"># fake file system</span> - contents <span class="Special"><-</span> start-reading-from-fake-resources resources, filename + contents, error? <span class="Special"><-</span> start-reading-from-fake-resource resources, filename <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># real file system</span> file:num <span class="Special"><-</span> $open-file-for-reading filename - assert file, <span class="Constant">[file not found]</span> + <span class="muControl">return-unless</span> file, <span class="Constant">0/contents</span>, <span class="Constant">1/error?</span> contents:&:source:char, sink:&:sink:char <span class="Special"><-</span> new-channel<span class="Constant"> 30</span> start-running receive-from-file file, sink ] -<span class="muRecipe">def</span> start-reading-from-fake-resources resources:&:resources, resource:text<span class="muRecipe"> -> </span>contents:&:source:char [ +<span class="muRecipe">def</span> slurp resources:&:resources, filename:text<span class="muRecipe"> -> </span>contents:text, error?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + source:&:source:char, error?:bool <span class="Special"><-</span> start-reading resources, filename + <span class="muControl">return-if</span> error?, <span class="Constant">0/contents</span> + buf:&:buffer <span class="Special"><-</span> new-buffer <span class="Constant">30/capacity</span> + <span class="Delimiter">{</span> + c:char, done?:bool, source <span class="Special"><-</span> read source + <span class="muControl">break-if</span> done? + buf <span class="Special"><-</span> append buf, c + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + contents <span class="Special"><-</span> buffer-to-array buf +] + +<span class="muRecipe">def</span> start-reading-from-fake-resource resources:&:resources, resource:text<span class="muRecipe"> -> </span>contents:&:source:char, error?:bool [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + error? <span class="Special"><-</span> copy <span class="Constant">0/no-error</span> i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> data:&:@:resource <span class="Special"><-</span> get *resources, <span class="Constant">data:offset</span> len:num <span class="Special"><-</span> length *data @@ -79,7 +103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color start-running receive-from-text curr-contents, sink <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="muControl">return</span> <span class="Constant">0/not-found</span> + <span class="muControl">return</span> <span class="Constant">0/not-found</span>, <span class="Constant">1/error</span> ] <span class="muRecipe">def</span> receive-from-file file:num, sink:&:sink:char<span class="muRecipe"> -> </span>sink:&:sink:char [ @@ -111,18 +135,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink <span class="Special"><-</span> close sink ] -<span class="muRecipe">def</span> start-writing resources:&:resources, filename:text<span class="muRecipe"> -> </span>sink:&:sink:char, routine-id:num [ +<span class="muRecipe">def</span> start-writing resources:&:resources, filename:text<span class="muRecipe"> -> </span>sink:&:sink:char, routine-id:num, error?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + error? <span class="Special"><-</span> copy <span class="Constant">0/false</span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> new-channel<span class="Constant"> 30</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> resources <span class="Comment"># fake file system</span> - routine-id <span class="Special"><-</span> start-running transmit-to-fake-file resources, filename, source + routine-id <span class="Special"><-</span> start-running transmit-to-fake-resource resources, filename, source <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># real file system</span> file:num <span class="Special"><-</span> $open-file-for-writing filename + <span class="muControl">return-unless</span> file, <span class="Constant">0/sink</span>, <span class="Constant">0/routine-id</span>, <span class="Constant">1/error?</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> file msg:text <span class="Special"><-</span> append <span class="Constant">[no such file: ]</span> filename @@ -131,6 +157,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color routine-id <span class="Special"><-</span> start-running transmit-to-file file, source ] +<span class="muRecipe">def</span> dump resources:&:resources, filename:text, contents:text<span class="muRecipe"> -> </span>resources:&:resources, error?:bool [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + <span class="Comment"># todo: really create an empty file</span> + <span class="muControl">return-unless</span> contents, resources, <span class="Constant">0/no-error</span> + sink-file:&:sink:char, write-routine:num, error?:bool <span class="Special"><-</span> start-writing resources, filename + <span class="muControl">return-if</span> error? + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *contents + <span class="Delimiter">{</span> + done?:bool <span class="Special"><-</span> greater-or-equal i, len + <span class="muControl">break-if</span> done? + c:char <span class="Special"><-</span> index *contents, i + sink-file <span class="Special"><-</span> write sink-file, c + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + close sink-file + <span class="Comment"># make sure to wait for the file to be actually written to disk</span> + <span class="Comment"># (Mu practices structured concurrency: <a href="http://250bpm.com/blog:71)">http://250bpm.com/blog:71)</a></span> + wait-for-routine write-routine +] + <span class="muRecipe">def</span> transmit-to-file file:num, source:&:source:char<span class="muRecipe"> -> </span>source:&:source:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -143,7 +192,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file <span class="Special"><-</span> $close-file file ] -<span class="muRecipe">def</span> transmit-to-fake-file resources:&:resources, filename:text, source:&:source:char<span class="muRecipe"> -> </span>resources:&:resources, source:&:source:char [ +<span class="muRecipe">def</span> transmit-to-fake-resource resources:&:resources, filename:text, source:&:source:char<span class="muRecipe"> -> </span>resources:&:resources, source:&:source:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> lock:location <span class="Special"><-</span> get-location *resources, <span class="Constant">lock:offset</span> diff --git a/html/090scenario_filesystem_test.mu.html b/html/090scenario_filesystem_test.mu.html index 91d039bb..20aad6a6 100644 --- a/html/090scenario_filesystem_test.mu.html +++ b/html/090scenario_filesystem_test.mu.html @@ -13,12 +13,9 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } -.Delimiter { color: #800080; } -.muControl { color: #c0a020; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } -.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } --> </style> @@ -130,20 +127,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># other files also continue to persist unchanged</span> ] ] - -<span class="muRecipe">def</span> slurp resources:&:resources, filename:text<span class="muRecipe"> -> </span>contents:text [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - source:&:source:char <span class="Special"><-</span> start-reading resources, filename - buf:&:buffer <span class="Special"><-</span> new-buffer <span class="Constant">30/capacity</span> - <span class="Delimiter">{</span> - c:char, done?:bool, source <span class="Special"><-</span> read source - <span class="muControl">break-if</span> done? - buf <span class="Special"><-</span> append buf, c - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - contents <span class="Special"><-</span> buffer-to-array buf -] </pre> </body> </html> diff --git a/html/092socket.mu.html b/html/092socket.mu.html index f33fb8bd..cbff28cc 100644 --- a/html/092socket.mu.html +++ b/html/092socket.mu.html @@ -111,7 +111,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> resources <span class="Comment"># fake network</span> - contents <span class="Special"><-</span> start-reading-from-fake-resources resources, uri + contents <span class="Special"><-</span> start-reading-from-fake-resource resources, uri <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># real network</span> diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index 7b5da51b..0090e189 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -463,8 +463,8 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim <span class="Normal">if</span> <span class="Delimiter">(</span>*--p<span class="Delimiter">-></span>contents<span class="Delimiter">.</span>end<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out << <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> - <span class="Normal">if</span> <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="Normal">if</span> <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> <span class="Identifier">return</span> new_mu_text<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Delimiter">}</span> diff --git a/html/102persist.cc.html b/html/102persist.cc.html deleted file mode 100644 index 863546d2..00000000 --- a/html/102persist.cc.html +++ /dev/null @@ -1,154 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 102persist.cc</title> -<meta name="Generator" content="Vim/7.4"> -<meta name="plugin-version" content="vim7.4_v2"> -<meta name="syntax" content="cpp"> -<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> -<meta name="colorscheme" content="minimal"> -<style type="text/css"> -<!-- -pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } -body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -* { font-size: 12pt; font-size: 1em; } -.Constant { color: #00a0a0; } -.Comment { color: #9090ff; } -.Delimiter { color: #800080; } -.cSpecial { color: #008000; } -.Identifier { color: #c0a020; } -.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } ---> -</style> - -<script type='text/javascript'> -<!-- - ---> -</script> -</head> -<body> -<pre id='vimCodeElement'> -<span class="Comment">//: Dead simple persistence.</span> -<span class="Comment">//: 'restore' - reads string from a file</span> -<span class="Comment">//: 'save' - writes string to a file</span> - -<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -RESTORE<span class="Delimiter">,</span> -<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"restore"</span><span class="Delimiter">,</span> RESTORE<span class="Delimiter">);</span> -<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> RESTORE: <span class="Delimiter">{</span> - <span class="Normal">if</span> <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 << 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> << <span class="Constant">"'restore' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - string filename<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal_text<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> - <span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<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> - <span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Delimiter">{</span> - raise << 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> << <span class="Constant">"first ingredient of 'restore' should be a string, but got '"</span> << to_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="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << 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 "End Primitive Recipe Implementations")</span> -<span class="Normal">case</span> RESTORE: <span class="Delimiter">{</span> - string filename<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal_text<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> <span class="Delimiter">{</span> - filename = 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> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<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> <span class="Delimiter">{</span> - filename = read_mu_text<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> - <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// do nothing in tests</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><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - string contents = slurp<span class="Delimiter">(</span><span class="Constant">"lesson/"</span>+filename<span class="Delimiter">);</span> - products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>contents<span class="Delimiter">.</span>empty<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> - <span class="Normal">else</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>new_mu_text<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -<span class="Delimiter">:(code)</span> -<span class="Comment">// <a href="http://cpp.indi.frih.net/blog/2014/09/how-to-read-an-entire-file-into-memory-in-cpp">http://cpp.indi.frih.net/blog/2014/09/how-to-read-an-entire-file-into-memory-in-cpp</a></span> -string slurp<span class="Delimiter">(</span><span class="Normal">const</span> string& filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> - ifstream fin<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> - fin<span class="Delimiter">.</span>peek<span class="Delimiter">();</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!fin<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> <span class="Comment">// don't bother checking errno</span> - ostringstream result<span class="Delimiter">;</span> - result << fin<span class="Delimiter">.</span>rdbuf<span class="Delimiter">();</span> - fin<span class="Delimiter">.</span>close<span class="Delimiter">();</span> - <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span class="Delimiter">}</span> - -<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -SAVE<span class="Delimiter">,</span> -<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"save"</span><span class="Delimiter">,</span> SAVE<span class="Delimiter">);</span> -<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> SAVE: <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << 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> << <span class="Constant">"'save' requires exactly two ingredients, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << 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_literal_text<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> - <span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<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> - <span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Delimiter">{</span> - raise << 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> << <span class="Constant">"first ingredient of 'save' should be a string, but got '"</span> << to_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="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << 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>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << 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> << <span class="Constant">"second ingredient of 'save' should be an address:@:char, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << 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 "End Primitive Recipe Implementations")</span> -<span class="Normal">case</span> SAVE: <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// do nothing in tests</span> - string filename<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal_text<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> <span class="Delimiter">{</span> - filename = 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> - <span class="Delimiter">}</span> - <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<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> <span class="Delimiter">{</span> - filename = read_mu_text<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> - <span class="Delimiter">}</span> - ofstream fout<span class="Delimiter">((</span><span class="Constant">"lesson/"</span>+filename<span class="Delimiter">).</span>c_str<span class="Delimiter">());</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!fout<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - string contents = read_mu_text<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - fout << contents<span class="Delimiter">;</span> - fout<span class="Delimiter">.</span>close<span class="Delimiter">();</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!exists<span class="Delimiter">(</span><span class="Constant">"lesson/.git"</span><span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Comment">// bug in git: git diff -q messes up --exit-code</span> - <span class="Comment">// explicitly say '--all' for git 1.9</span> - <span class="Normal">int</span> status = system<span class="Delimiter">(</span><span class="Constant">"cd lesson; git add --all .; git diff HEAD --exit-code >/dev/null || git commit -a -m . >/dev/null"</span><span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>status != <span class="Constant">0</span><span class="Delimiter">)</span> - raise << <span class="Constant">"error in commit: contents "</span> << contents << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -<span class="Delimiter">:(code)</span> -<span class="Normal">bool</span> exists<span class="Delimiter">(</span><span class="Normal">const</span> string& filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">struct</span> stat dummy<span class="Delimiter">;</span> - <span class="Identifier">return</span> <span class="Constant">0</span> == stat<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &dummy<span class="Delimiter">);</span> -<span class="Delimiter">}</span> -</pre> -</body> -</html> -<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 776c336e..9cbe6f6f 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -41,12 +41,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text <span class="Special"><-</span> restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text <span class="Special"><-</span> new <span class="Constant">[]</span> - hide-screen <span class="Constant">0/screen</span> - env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/filesystem</span>, <span class="Constant">0/screen</span> render-all <span class="Constant">0/screen</span>, env, render - event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env + event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env, <span class="Constant">0/filesystem</span> <span class="Comment"># never gets here</span> ] @@ -56,24 +53,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sandbox-in-focus?:bool <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">def</span> new-programming-environment screen:&:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -> </span>result:&:environment [ +<span class="muRecipe">def</span> new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text<span class="muRecipe"> -> </span>result:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> width:num <span class="Special"><-</span> screen-width screen result <span class="Special"><-</span> new <span class="Constant">environment:type</span> <span class="Comment"># recipe editor on the left</span> + initial-recipe-contents:text <span class="Special"><-</span> slurp resources, <span class="Constant">[lesson/recipes.mu]</span> <span class="Comment"># ignore errors</span> divider:num, _ <span class="Special"><-</span> divide-with-remainder width,<span class="Constant"> 2</span> recipes:&:editor <span class="Special"><-</span> new-editor initial-recipe-contents, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> sandbox-left:num <span class="Special"><-</span> add divider,<span class="Constant"> 1</span> - current-sandbox:&:editor <span class="Special"><-</span> new-editor initial-sandbox-contents, sandbox-left, width/right + current-sandbox:&:editor <span class="Special"><-</span> new-editor test-sandbox-editor-contents, sandbox-left, width/right *result <span class="Special"><-</span> put *result, <span class="Constant">recipes:offset</span>, recipes *result <span class="Special"><-</span> put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox *result <span class="Special"><-</span> put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> <span class="Constant"> <programming-environment-initialization></span> ] -<span class="muRecipe">def</span> event-loop screen:&:screen, console:&:console, env:&:environment<span class="muRecipe"> -> </span>screen:&:screen, console:&:console, env:&:environment [ +<span class="muRecipe">def</span> event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources<span class="muRecipe"> -> </span>screen:&:screen, console:&:console, env:&:environment, resources:&:resources [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> @@ -321,7 +319,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ +<span class="Constant"> |abc|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[def]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># focus on both sides</span> assume-console [ left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> @@ -329,7 +332,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen, console, env + event-loop screen, console, env, resources recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-column:offset</span> sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> @@ -346,7 +349,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ +<span class="Constant"> |abc|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[def]</span> <span class="Comment"># contents of sandbox</span> render-all screen, env, render <span class="Comment"># type one letter in each of them</span> assume-console [ @@ -356,7 +364,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-column:offset</span> sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> @@ -365,7 +373,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> <span class="Constant"> .a0bc ╎d1ef .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎──────────────.</span> + <span class="Constant"> . ╎──────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] memory-should-contain [ @@ -380,39 +389,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .a0bc ╎d1␣f .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎──────────────.</span> + <span class="Constant"> . ╎──────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] ] -<span class="muScenario">scenario</span> multiple-editors-cover-only-their-own-areas [ - <span class="Constant">local-scope</span> - trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> - assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> - run [ - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> - render-all screen, env, render - ] - <span class="Comment"># divider isn't messed up</span> - screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .abc ╎def .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────.</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> . ╎ .</span> - ] -] - <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ +<span class="Constant"> |abc|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[def]</span> render-all screen, env, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -420,7 +417,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣bc ╎def .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎──────────────.</span> + <span class="Constant"> . ╎──────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] <span class="Comment"># now try typing a letter</span> @@ -428,7 +426,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[z]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -436,7 +434,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .z␣bc ╎def .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎──────────────.</span> + <span class="Constant"> . ╎──────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] ] @@ -445,10 +444,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> + assume-resources [ + ] <span class="Comment"># initialize sandbox side with two lines</span> - s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> + test-sandbox-editor-contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, s:text + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, test-sandbox-editor-contents render-all screen, env, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -463,7 +464,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index b7afa986..095fa72d 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -45,13 +45,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text <span class="Special"><-</span> restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text <span class="Special"><-</span> new <span class="Constant">[]</span> - hide-screen <span class="Constant">0/screen</span> - env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/filesystem</span>, <span class="Constant">0/screen</span> env <span class="Special"><-</span> restore-sandboxes env render-all <span class="Constant">0/screen</span>, env, render - event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env + event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env, <span class="Constant">0/filesystem</span> <span class="Comment"># never gets here</span> ] @@ -81,14 +78,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> + assume-resources [ + ] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[divide-with-remainder 11, 3]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -138,7 +137,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that screen prints both sandboxes</span> screen-should-contain [ @@ -164,7 +163,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color do-run?:bool <span class="Special"><-</span> equal k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? screen <span class="Special"><-</span> update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> - error?:bool, env, screen <span class="Special"><-</span> run-sandboxes env, screen + error?:bool <span class="Special"><-</span> run-sandboxes env, resources, screen <span class="Comment"># F4 might update warnings and results on both sides</span> screen <span class="Special"><-</span> render-all screen, env, render <span class="Delimiter">{</span> @@ -176,10 +175,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> run-sandboxes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ +<span class="muRecipe">def</span> run-sandboxes env:&:environment, resources:&:resources, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - errors-found?:bool, env, screen <span class="Special"><-</span> update-recipes env, screen + errors-found?:bool <span class="Special"><-</span> update-recipes env, resources, screen <span class="muControl">return-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> <span class="Constant"> <run-sandboxes-begin></span> @@ -205,7 +204,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init <span class="Delimiter">}</span> <span class="Comment"># save all sandboxes before running, just in case we die when running</span> - save-sandboxes env + save-sandboxes env, resources <span class="Comment"># run all sandboxes</span> curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> @@ -219,14 +218,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <run-sandboxes-end></span> ] -<span class="Comment"># copy code from recipe editor, persist to disk, load</span> +<span class="Comment"># load code from disk</span> <span class="Comment"># replaced in a later layer (whereupon errors-found? will actually be set)</span> -<span class="muRecipe">def</span> update-recipes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ +<span class="muRecipe">def</span> update-recipes env:&:environment, resources:&:resources, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> in:text <span class="Special"><-</span> editor-contents recipes - save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> + resources <span class="Special"><-</span> dump resources, <span class="Constant">[lesson/recipes.mu]</span>, in reload in errors-found? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] @@ -248,7 +247,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen <span class="Special"><-</span> print screen, msg, color, <span class="Constant">238/grey/background</span> ] -<span class="muRecipe">def</span> save-sandboxes env:&:environment [ +<span class="muRecipe">def</span> save-sandboxes env:&:environment, resources:&:resources<span class="muRecipe"> -> </span>resources:&:resources [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> @@ -259,8 +258,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr data:text <span class="Special"><-</span> get *curr, <span class="Constant">data:offset</span> - filename:text <span class="Special"><-</span> to-text idx - save filename, data + filename:text <span class="Special"><-</span> append <span class="Constant">[lesson/]</span>, idx + resources <span class="Special"><-</span> dump resources, filename, data <span class="Constant"> <end-save-sandbox></span> idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> curr <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> @@ -450,7 +449,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span> -<span class="muRecipe">def</span> restore-sandboxes env:&:environment<span class="muRecipe"> -> </span>env:&:environment [ +<span class="muRecipe">def</span> restore-sandboxes env:&:environment, resources:&:resources<span class="muRecipe"> -> </span>env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> @@ -458,8 +457,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color curr:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> prev:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - filename:text <span class="Special"><-</span> to-text idx - contents:text <span class="Special"><-</span> restore filename + filename:text <span class="Special"><-</span> append <span class="Constant">[lesson/]</span>, idx + contents:text <span class="Special"><-</span> slurp resources, filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># todo: handle empty sandbox</span> <span class="Comment"># create new sandbox for file</span> @@ -554,27 +553,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant">local-scope</span> -<span class="Constant">z:num <- add 2, 2</span> -<span class="Constant">reply z</span> -<span class="Constant">]</span>] + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ +<span class="Constant"> ||</span> + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | z:num <- add 2, 2|</span> +<span class="Constant"> | reply z|</span> +<span class="Constant"> |]</span>| + ] + ] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .local-scope ╎0 edit copy delete .</span> - <span class="Constant"> .z:num <- add 2, 2 ╎foo .</span> - <span class="Constant"> .reply z ╎4 .</span> + <span class="Constant"> . local-scope ╎0 edit copy delete .</span> + <span class="Constant"> . z:num <- add 2, 2 ╎foo .</span> + <span class="Constant"> . reply z ╎4 .</span> <span class="Constant"> .] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] @@ -586,17 +590,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .local-scope ╎0 edit copy delete .</span> - <span class="Constant"> .z:num <- add 2, 3 ╎foo .</span> - <span class="Constant"> .reply z ╎5 .</span> + <span class="Constant"> . local-scope ╎0 edit copy delete .</span> + <span class="Constant"> . z:num <- add 2, 3 ╎foo .</span> + <span class="Constant"> . reply z ╎5 .</span> <span class="Constant"> .] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] @@ -606,15 +611,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> - <span class="Comment"># left editor is empty</span> - <span class="Comment"># right editor contains an instruction</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + <span class="Comment"># sandbox editor contains an instruction</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># run the code in the editor</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ @@ -677,13 +684,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter press down-arrow ] - event-loop screen, console, env + event-loop screen, console, env, resources <span class="Comment"># no scroll</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -698,14 +707,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter press up-arrow press down-arrow <span class="Comment"># while cursor isn't at bottom</span> ] - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># cursor moves back to bottom</span> @@ -776,7 +787,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render assume-console [ <span class="Comment"># add a line</span> @@ -786,7 +799,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># try to scroll</span> press page-down <span class="Comment"># or ctrl-f</span> ] - event-loop screen, console, env + event-loop screen, console, env, resources <span class="Comment"># no scroll, and cursor remains at top line</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -801,7 +814,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[ab</span> <span class="Constant">cd]</span> render-all screen, env, render assume-console [ @@ -812,7 +827,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># move cursor</span> press down-arrow ] - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># no scroll on recipe side, cursor moves on sandbox side</span> @@ -831,14 +846,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># initialize sandbox side</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> + <span class="Comment"># initialize</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ <span class="Comment"># create a sandbox</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -852,7 +869,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -870,7 +887,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -959,30 +976,33 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> curr ] -<span class="muScenario">scenario</span> scrolling-down-on-recipe-side [ +<span class="muScenario">scenario</span> scrolling-down-past-bottom-on-recipe-side [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">||</span> <span class="Comment"># file containing just a newline</span> + ] + ] <span class="Comment"># create a sandbox</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources <span class="Comment"># hit 'down' in recipe editor</span> assume-console [ press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] - <span class="Comment"># cursor moves down on recipe side</span> + <span class="Comment"># cursor doesn't move when the end is already on-screen</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ╎ .</span> @@ -997,7 +1017,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -1007,7 +1029,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor screen-should-contain [ @@ -1027,7 +1049,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -1049,7 +1071,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># just second sandbox displayed</span> screen-should-contain [ @@ -1066,7 +1088,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># no change</span> screen-should-contain [ @@ -1083,7 +1105,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># back to displaying both sandboxes without editor</span> screen-should-contain [ @@ -1102,7 +1124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -1124,7 +1146,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] @@ -1148,7 +1170,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create a sandbox</span> assume-console [ @@ -1156,7 +1180,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -1172,7 +1196,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -1190,7 +1214,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> screen-should-contain [ @@ -1208,7 +1232,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 3459f1f2..b6e9f280 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -39,24 +39,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 1, 1]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -65,16 +63,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 69</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># it copies into editor</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> + <span class="Constant"> . ╎add 1, 1 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -83,15 +81,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎0foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> + <span class="Constant"> . ╎0add 1, 1 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -101,24 +99,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 1, 1]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -127,16 +123,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 84</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># it copies into editor</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> + <span class="Constant"> . ╎add 1, 1 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -145,15 +141,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎0foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> + <span class="Constant"> . ╎0add 1, 1 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -258,24 +254,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 1, 1]</span> <span class="Comment"># contents of sandbox editor</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -286,16 +280,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 70</span> <span class="Comment"># click 'copy' button</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># copy doesn't happen</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎0 .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -304,15 +298,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎01 .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 1, 1 .</span> + <span class="Constant"> . ╎2 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 48028d51..06dd8fc5 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -38,7 +38,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> <span class="Comment"># run a few commands</span> assume-console [ left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> @@ -47,7 +49,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 2, 2]</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -68,7 +70,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 7</span>,<span class="Constant"> 85</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -86,7 +88,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 99</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -185,7 +187,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -196,7 +200,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 press page-down ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> @@ -211,7 +215,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 6</span>,<span class="Constant"> 99</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -230,7 +234,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -241,7 +247,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 press page-down ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> @@ -256,7 +262,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -275,7 +281,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -287,7 +295,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down press page-down ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> @@ -302,7 +310,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># implicitly scroll up to first sandbox</span> screen-should-contain [ @@ -322,7 +330,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -332,7 +342,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -352,7 +362,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># shouldn't go past last sandbox</span> screen-should-contain [ diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 97ca51e3..3725c7ce 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -34,28 +34,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <pre id='vimCodeElement'> <span class="SalientComment">## editing sandboxes after they've been created</span> -<span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor [ +<span class="muScenario">scenario</span> clicking-on-sandbox-edit-button-moves-it-to-editor [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 2, 2]</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 2, 2 .</span> + <span class="Constant"> . ╎4 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -64,16 +62,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 55</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎ .</span> - <span class="Constant"> .] ╎ .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎add 2, 2 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] <span class="Comment"># cursor should be in the right place</span> @@ -81,41 +76,36 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎0foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎ .</span> - <span class="Constant"> .] ╎ .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎0add 2, 2 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] ] -<span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor-2 [ +<span class="muScenario">scenario</span> clicking-on-sandbox-edit-button-moves-it-to-editor-2 [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># empty recipes</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[add 2, 2]</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎0 edit copy delete .</span> + <span class="Constant"> . ╎add 2, 2 .</span> + <span class="Constant"> . ╎4 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -124,16 +114,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 68</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎ .</span> - <span class="Constant"> .] ╎ .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎add 2, 2 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] <span class="Comment"># cursor should be in the right place</span> @@ -141,15 +128,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎0foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎ .</span> - <span class="Constant"> .] ╎ .</span> - <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎0add 2, 2 .</span> +<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] ] @@ -212,13 +196,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Comment"># right editor contains an instruction</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + assume-resources [ + ] + <span class="Comment"># right editor contains a print instruction</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -239,7 +225,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 3</span>,<span class="Constant"> 65</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -255,7 +241,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -267,7 +255,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down press page-down ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> @@ -282,7 +270,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 2</span>,<span class="Constant"> 55</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -302,7 +290,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -312,7 +302,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -331,7 +321,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># no change in contents</span> screen-should-contain [ @@ -353,7 +343,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># screen should show just final sandbox with the right index (1)</span> screen-should-contain [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 30c731ea..b6e0ab9b 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -40,22 +40,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> reply 4</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes:text, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | reply 4|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> .recipe foo [ ╎ .</span> + <span class="Constant"> . reply 4 ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎0 edit copy delete .</span> + <span class="Constant"> . ╎foo .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> @@ -65,7 +68,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 5</span>,<span class="Constant"> 51</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -85,26 +88,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .␣ ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> .␣ecipe foo [ ╎ .</span> + <span class="Constant"> . reply 4 ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎0 edit copy delete .</span> + <span class="Constant"> . ╎foo .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎4 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> . ╎ .</span> ] <span class="Comment"># now change the result</span> <span class="Comment"># then rerun</span> assume-console [ - left-click<span class="Constant"> 3</span>,<span class="Constant"> 11</span> <span class="Comment"># cursor to end of line</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 11</span> <span class="Comment"># cursor to end of line</span> press backspace type <span class="Constant">[3]</span> press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -131,14 +132,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color expected-response:text <span class="Special"><-</span> get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response filename <span class="Special"><-</span> append filename, <span class="Constant">[.out]</span> - save filename, expected-response + resources <span class="Special"><-</span> dump resources, filename, expected-response <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><end-restore-sandbox></span> [ <span class="Delimiter">{</span> filename <span class="Special"><-</span> append filename, <span class="Constant">[.out]</span> - contents <span class="Special"><-</span> restore filename + contents <span class="Special"><-</span> slurp resources, filename <span class="muControl">break-unless</span> contents *curr <span class="Special"><-</span> put *curr, <span class="Constant">expected-response:offset</span>, contents <span class="Delimiter">}</span> @@ -163,7 +164,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its expected-response, and save session</span> sandbox <span class="Special"><-</span> toggle-expected-response sandbox - save-sandboxes env + save-sandboxes env, resources hide-screen screen screen <span class="Special"><-</span> render-sandbox-side screen, env, render screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 66943462..ab32cbf0 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -40,22 +40,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> stash [abc]</span> -]] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | stash [abc]</span>| +<span class="Constant"> |]|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . stash [abc] ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> .recipe foo [ ╎ .</span> + <span class="Constant"> . stash [abc] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎0 edit copy delete .</span> + <span class="Constant"> . ╎foo .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -64,17 +67,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .␣ ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . stash [abc] ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> .␣ecipe foo [ ╎ .</span> + <span class="Constant"> . stash [abc] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎0 edit copy delete .</span> + <span class="Constant"> . ╎foo .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎abc .</span> ] screen-should-contain-in-color <span class="Constant">245/grey</span>, [ @@ -90,16 +93,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources print screen, cursor ] <span class="Comment"># trace hidden again</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .␣ ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . stash [abc] ╎0 edit copy delete .</span> - <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> .␣ecipe foo [ ╎ .</span> + <span class="Constant"> . stash [abc] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎0 edit copy delete .</span> + <span class="Constant"> . ╎foo .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -110,24 +113,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> stash [abc]</span> - <span class="muControl">reply</span><span class="Constant"> 4</span> -]] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | stash [abc]</span>| + <span class="Constant">|</span> <span class="muControl">reply</span> 4| +<span class="Constant"> |]|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . stash [abc] ╎0 edit copy delete .</span> - <span class="Constant"> . reply 4 ╎foo .</span> - <span class="Constant"> .] ╎4 .</span> + <span class="Constant"> .recipe foo [ ╎ .</span> + <span class="Constant"> . stash [abc] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> + <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> . ╎4 .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> ] @@ -136,16 +142,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># trace now printed above result</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ╎ .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . stash [abc] ╎0 edit copy delete .</span> - <span class="Constant"> . reply 4 ╎foo .</span> - <span class="Constant"> .] ╎abc .</span> + <span class="Constant"> .recipe foo [ ╎ .</span> + <span class="Constant"> . stash [abc] ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . reply 4 ╎0 edit copy delete .</span> + <span class="Constant"> .] ╎foo .</span> + <span class="Constant"> . ╎abc .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎8 instructions run .</span> <span class="Constant"> . ╎4 .</span> <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> @@ -157,13 +163,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[stash 123456789]</span> <span class="Comment"># create and expand the trace</span> assume-console [ press F4 left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ╎ .</span> @@ -177,7 +185,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click<span class="Constant"> 5</span>,<span class="Constant"> 57</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># no change; doesn't die</span> screen-should-contain [ diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 91e48c57..72f21172 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -40,12 +40,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># copy code from recipe editor, persist to disk, load, save any errors</span> -<span class="muRecipe">def!</span> update-recipes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ +<span class="muRecipe">def!</span> update-recipes env:&:environment, resources:&:resources, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> in:text <span class="Special"><-</span> editor-contents recipes - save <span class="Constant">[recipes.mu]</span>, in + resources <span class="Special"><-</span> dump resources, <span class="Constant">[lesson/recipes.mu]</span>, in recipe-errors:text <span class="Special"><-</span> reload in *env <span class="Special"><-</span> put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors <span class="Comment"># if recipe editor has errors, stop</span> @@ -153,23 +153,36 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> get 123:num, foo:offset</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | get 123:num, foo:offset|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> + render-all screen, env, render + screen-should-contain [ + <span class="Constant"> . run (F4) .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . get 123:num, foo:offset ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎ .</span> + ] assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . get 123:num, foo:offset ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . get 123:num, foo:offset ╎─────────────────────────────────────────────────.</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: unknown element 'foo' in container 'number' ╎ .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩╎ .</span> <span class="Constant"> .ner, but got '123:num' ╎ .</span> @@ -193,7 +206,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> assume-console [ left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 1</span> @@ -204,7 +219,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># status line shows that error is in first sandbox</span> screen-should-contain [ @@ -216,7 +231,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[]</span> assume-console [ left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 2</span> @@ -230,7 +247,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># status line shows that error is in second sandbox</span> screen-should-contain [ @@ -242,13 +259,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + assume-resources [ + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> assume-console [ press F4 <span class="Comment"># generate error</span> ] - run [ - event-loop screen, console, env - ] + event-loop screen, console, env, resources assume-console [ left-click<span class="Constant"> 3</span>,<span class="Constant"> 58</span> press ctrl-k @@ -256,7 +273,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 <span class="Comment"># update sandbox</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># error should disappear</span> screen-should-contain [ @@ -276,26 +293,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> -<span class="Constant">local-scope</span> -<span class="Constant">load-ingredients</span> -<span class="Constant">y:&:num <- copy 0</span> -<span class="Constant">z <- add x, y</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 2]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo x:_elem<span class="muRecipe"> -> </span>z:_elem <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | load-ingredients|</span> +<span class="Constant"> | y:&:num <- copy 0|</span> +<span class="Constant"> | z <- add x, y|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo 2]</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ╎ .</span> - <span class="Constant"> .local-scope ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .load-ingredients ╎0 edit copy delete .</span> - <span class="Constant"> .y:&:num <- copy 0 ╎foo 2 .</span> - <span class="Constant"> .z <- add x, y ╎foo_2: 'add' requires number ingredients, but go↩.</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . load-ingredients ╎0 edit copy delete .</span> + <span class="Constant"> . y:&:num <- copy 0 ╎foo 2 .</span> + <span class="Constant"> . z <- add x, y ╎foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .] ╎t 'y' .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] <span class="Comment"># now rerun everything</span> @@ -303,18 +325,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># error should remain unchanged</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ╎ .</span> - <span class="Constant"> .local-scope ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .load-ingredients ╎0 edit copy delete .</span> - <span class="Constant"> .y:&:num <- copy 0 ╎foo 2 .</span> - <span class="Constant"> .z <- add x, y ╎foo_3: 'add' requires number ingredients, but go↩.</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . load-ingredients ╎0 edit copy delete .</span> + <span class="Constant"> . y:&:num <- copy 0 ╎foo 2 .</span> + <span class="Constant"> . z <- add x, y ╎foo_3: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .] ╎t 'y' .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] ] @@ -324,17 +347,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> -<span class="Constant">]</span>] + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> length l:&:list:_elem<span class="muRecipe"> -> </span>n:num <span class="Constant">[|</span> +<span class="Constant"> |]</span>| + ] + ] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - sandbox:text <span class="Special"><-</span> new <span class="Constant">[x:&:list:num <- copy 0</span> + test-sandbox:text <span class="Special"><-</span> new <span class="Constant">[x:&:list:num <- copy 0</span> <span class="Constant">to-text x]</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, sandbox + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, test-sandbox <span class="Comment"># run it once</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources <span class="Comment"># no errors anywhere on screen (can't check anything else, since to-text will return an address)</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ <span class="Constant"> . .</span> @@ -358,7 +385,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># still no errors</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -384,24 +411,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> x <- copy 0</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | x <- copy 0|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . x <- copy 0 ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . x <- copy 0 ╎─────────────────────────────────────────────────.</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: missing type for 'x' in 'x <- copy 0' ╎ .</span> + <span class="Constant"> .foo: can't copy '0' to 'x'; types don't match ╎ .</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> + <span class="Constant"> . ╎ .</span> ] ] @@ -410,22 +443,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo \\[</span> -<span class="Constant"> x <- copy 0</span> -<span class="Constant">]</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo \\\<span class="Constant">[|</span> +<span class="Constant"> | x <- copy 0|</span> +<span class="Constant"> ]</span> + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo \\[ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . x <- copy 0 ╎ .</span> + <span class="Constant"> .recipe foo \\[ ╎foo .</span> + <span class="Constant"> . x <- copy 0 ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . ╎ .</span> <span class="Constant"> .9: unbalanced '\\[' for recipe ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> @@ -437,27 +471,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> local-scope</span> -<span class="Constant"> x:&:point <- new point:type</span> -<span class="Constant"> get x:&:point, 1:offset</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | x:&:point <- new point:type|</span> +<span class="Constant"> | get x:&:point, 1:offset|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . local-scope ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . x:&:point <- new point:type ╎ .</span> <span class="Constant"> . get x:&:point, 1:offset ╎ .</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩╎ .</span> <span class="Constant"> .ner, but got 'x:&:point' ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> @@ -469,29 +506,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> local-scope</span> -<span class="Constant"> x:num <- copy 0</span> -<span class="Constant"> y:&:point <- new point:type</span> -<span class="Constant"> get *y:&:point, x:num</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | x:num <- copy 0|</span> +<span class="Constant"> | y:&:point <- new point:type|</span> +<span class="Constant"> | get *y:&:point, x:num|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . local-scope ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . x:num <- copy 0 ╎ .</span> <span class="Constant"> . y:&:point <- new point:type ╎ .</span> <span class="Constant"> . get *y:&:point, x:num ╎ .</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: second ingredient of 'get' should have type ↩╎ .</span> <span class="Constant"> .'offset', but got 'x:num' ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> @@ -502,25 +542,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-shows-errors-everytime [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> - <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> -<span class="Constant">recipe foo [</span> -<span class="Constant"> local-scope</span> -<span class="Constant"> x:num <- copy y:num</span> -<span class="Constant">]</span>] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># try to run a file with an error</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | x:num <- copy y:num|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . local-scope ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . x:num <- copy y:num ╎ .</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ .</span> <span class="Constant"> .py y:num' but it hasn't been written to yet ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> @@ -531,15 +574,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> - <span class="Constant"> . ╎foo .</span> - <span class="Constant"> .recipe foo [ ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> . local-scope ╎ .</span> + <span class="Constant"> .recipe foo [ ╎foo .</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> <span class="Constant"> . x:num <- copy y:num ╎ .</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> <span class="Constant"> .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ .</span> <span class="Constant"> .py y:num' but it hasn't been written to yet ╎ .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> @@ -551,15 +594,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text <span class="Special"><-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox - <span class="Comment"># run the code in the editors</span> + assume-resources [ + ] + <span class="Comment"># sandbox editor contains an illegal instruction</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[get 1234:num, foo:offset]</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ @@ -613,16 +656,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text <span class="Special"><-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox + assume-resources [ + ] + <span class="Comment"># sandbox editor contains an illegal instruction</span> + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[get 1234:num, foo:offset]</span> <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ @@ -643,20 +687,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> - <span class="Comment"># left editor is empty</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo [</span> -<span class="Constant"> {</span> -<span class="Constant"> loop</span> -<span class="Constant"> }</span> -<span class="Constant">]</span>] - <span class="Comment"># right editor contains an instruction</span> - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + <span class="Comment"># sandbox editor will trigger an infinite loop</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | {|</span> +<span class="Constant"> | loop|</span> +<span class="Constant"> | }|</span> +<span class="Constant"> |]</span>| + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> @@ -665,7 +712,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . loop ╎0 edit copy delete .</span> <span class="Constant"> . } ╎foo .</span> <span class="Constant"> .] ╎took too long! .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ .</span> <span class="Constant"> . ╎ .</span> ] ] @@ -675,51 +723,56 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a error</span> - recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo [</span> -<span class="Constant">local-scope</span> -<span class="Constant">a:num <- next-ingredient</span> -<span class="Constant">b:num <- next-ingredient</span> -<span class="Constant">stash [dividing by]</span>, b -_, c:num <span class="Special"><-</span> divide-with-remainder a, b -<span class="muControl">reply</span> b -]] - env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 4, 0]</span> + assume-resources [ + <span class="Constant">[lesson/recipes.mu]</span> <span class="Special"><-</span> [ + <span class="Constant">|recipe</span> foo <span class="Constant">[|</span> +<span class="Constant"> | local-scope|</span> +<span class="Constant"> | a:num <- next-ingredient|</span> +<span class="Constant"> | b:num <- next-ingredient|</span> +<span class="Constant"> | stash [dividing by]</span>, b| + <span class="Constant">|</span> _, c:num <span class="Special"><-</span> divide-with-remainder a, b| + <span class="Constant">|</span> <span class="muControl">reply</span> b| +<span class="Constant"> |]|</span> + ] + ] + env:&:environment <span class="Special"><-</span> new-programming-environment resources, screen, <span class="Constant">[foo 4, 0]</span> <span class="Comment"># run</span> assume-console [ press F4 ] - event-loop screen, console, env + event-loop screen, console, env, resources <span class="Comment"># screen prints error message</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ╎ .</span> - <span class="Constant"> .local-scope ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .a:num <- next-ingredient ╎0 edit copy delete .</span> - <span class="Constant"> .b:num <- next-ingredient ╎foo 4, 0 .</span> - <span class="Constant"> .stash [dividing by], b ╎foo: divide by zero in '_, c:num <- divide-with-↩.</span> - <span class="Constant"> ._, c:num <- divide-with-remainder a, b ╎remainder a, b' .</span> - <span class="Constant"> .reply b ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . a:num <- next-ingredient ╎0 edit copy delete .</span> + <span class="Constant"> . b:num <- next-ingredient ╎foo 4, 0 .</span> + <span class="Constant"> . stash [dividing by], b ╎foo: divide by zero in '_, c:num <- divide-with-↩.</span> + <span class="Constant"> . _, c:num <- divide-with-remainder a, b ╎remainder a, b' .</span> + <span class="Constant"> . reply b ╎─────────────────────────────────────────────────.</span> <span class="Constant"> .] ╎ .</span> + <span class="Constant"> . ╎ .</span> ] <span class="Comment"># click on the call in the sandbox</span> assume-console [ left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ - event-loop screen, console, env + event-loop screen, console, env, resources ] <span class="Comment"># screen should expand trace</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ╎ .</span> - <span class="Constant"> .local-scope ╎─────────────────────────────────────────────────.</span> - <span class="Constant"> .a:num <- next-ingredient ╎0 edit copy delete .</span> - <span class="Constant"> .b:num <- next-ingredient ╎foo 4, 0 .</span> - <span class="Constant"> .stash [dividing by], b ╎dividing by 0 .</span> - <span class="Constant"> ._, c:num <- divide-with-remainder a, b ╎14 instructions run .</span> - <span class="Constant"> .reply b ╎foo: divide by zero in '_, c:num <- divide-with-↩.</span> + <span class="Constant"> . local-scope ╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . a:num <- next-ingredient ╎0 edit copy delete .</span> + <span class="Constant"> . b:num <- next-ingredient ╎foo 4, 0 .</span> + <span class="Constant"> . stash [dividing by], b ╎dividing by 0 .</span> + <span class="Constant"> . _, c:num <- divide-with-remainder a, b ╎14 instructions run .</span> + <span class="Constant"> . reply b ╎foo: divide by zero in '_, c:num <- divide-with-↩.</span> <span class="Constant"> .] ╎remainder a, b' .</span> -<span class="Constant"> .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.</span> + <span class="Constant"> . ╎─────────────────────────────────────────────────.</span> ] ] </pre> |