about summary refs log tree commit diff stats
path: root/archive/2.vm
diff options
context:
space:
mode:
Diffstat (limited to 'archive/2.vm')
-rw-r--r--archive/2.vm/000organization.cc136
-rw-r--r--archive/2.vm/001help.cc264
-rw-r--r--archive/2.vm/002test.cc104
-rw-r--r--archive/2.vm/003trace.cc501
-rw-r--r--archive/2.vm/003trace.test.cc126
-rw-r--r--archive/2.vm/010vm.cc900
-rw-r--r--archive/2.vm/011load.cc489
-rw-r--r--archive/2.vm/012transform.cc102
-rw-r--r--archive/2.vm/013update_operation.cc40
-rw-r--r--archive/2.vm/014literal_string.cc274
-rw-r--r--archive/2.vm/015literal_noninteger.cc51
-rw-r--r--archive/2.vm/016dilated_reagent.cc166
-rw-r--r--archive/2.vm/017parse_tree.cc124
-rw-r--r--archive/2.vm/018constant.cc79
-rw-r--r--archive/2.vm/019type_abbreviations.cc236
-rw-r--r--archive/2.vm/020run.cc571
-rw-r--r--archive/2.vm/021check_instruction.cc260
-rw-r--r--archive/2.vm/022arithmetic.cc1071
-rw-r--r--archive/2.vm/023boolean.cc224
-rw-r--r--archive/2.vm/024jump.cc237
-rw-r--r--archive/2.vm/025compare.cc624
-rw-r--r--archive/2.vm/026call.cc246
-rw-r--r--archive/2.vm/027call_ingredient.cc220
-rw-r--r--archive/2.vm/028call_return.cc197
-rw-r--r--archive/2.vm/029tools.cc326
-rw-r--r--archive/2.vm/030container.cc819
-rw-r--r--archive/2.vm/031merge.cc270
-rw-r--r--archive/2.vm/032array.cc635
-rw-r--r--archive/2.vm/033exclusive_container.cc554
-rw-r--r--archive/2.vm/034address.cc514
-rw-r--r--archive/2.vm/035lookup.cc664
-rw-r--r--archive/2.vm/036abandon.cc153
-rw-r--r--archive/2.vm/038new_text.cc288
-rw-r--r--archive/2.vm/040brace.cc566
-rw-r--r--archive/2.vm/041jump_target.cc220
-rw-r--r--archive/2.vm/042name.cc414
-rw-r--r--archive/2.vm/043space.cc331
-rw-r--r--archive/2.vm/044space_surround.cc79
-rw-r--r--archive/2.vm/045closure_name.cc204
-rw-r--r--archive/2.vm/046check_type_by_name.cc265
-rw-r--r--archive/2.vm/050scenario.cc1039
-rw-r--r--archive/2.vm/051scenario_test.mu70
-rw-r--r--archive/2.vm/052tangle.cc529
-rw-r--r--archive/2.vm/053recipe_header.cc793
-rw-r--r--archive/2.vm/054static_dispatch.cc683
-rw-r--r--archive/2.vm/055shape_shifting_container.cc773
-rw-r--r--archive/2.vm/056shape_shifting_recipe.cc1307
-rw-r--r--archive/2.vm/057immutable.cc715
-rw-r--r--archive/2.vm/058to_text.cc24
-rw-r--r--archive/2.vm/059to_text.mu48
-rw-r--r--archive/2.vm/060rewrite_literal_string.cc81
-rw-r--r--archive/2.vm/061text.mu1427
-rw-r--r--archive/2.vm/062convert_ingredients_to_text.cc212
-rw-r--r--archive/2.vm/063array.mu181
-rw-r--r--archive/2.vm/064list.mu366
-rw-r--r--archive/2.vm/065duplex_list.mu781
-rw-r--r--archive/2.vm/066stream.mu80
-rw-r--r--archive/2.vm/067random.cc34
-rw-r--r--archive/2.vm/068random.mu75
-rw-r--r--archive/2.vm/069hash.cc422
-rw-r--r--archive/2.vm/070table.mu109
-rw-r--r--archive/2.vm/072recipe.cc711
-rw-r--r--archive/2.vm/073scheduler.cc709
-rw-r--r--archive/2.vm/074wait.cc664
-rw-r--r--archive/2.vm/075channel.mu510
-rw-r--r--archive/2.vm/076continuation.cc406
-rw-r--r--archive/2.vm/080display.cc462
-rw-r--r--archive/2.vm/081print.mu914
-rw-r--r--archive/2.vm/082scenario_screen.cc458
-rw-r--r--archive/2.vm/083scenario_screen_test.mu47
-rw-r--r--archive/2.vm/084console.mu104
-rw-r--r--archive/2.vm/085scenario_console.cc317
-rw-r--r--archive/2.vm/086scenario_console_test.mu25
-rw-r--r--archive/2.vm/087file.cc225
-rw-r--r--archive/2.vm/088file.mu213
-rw-r--r--archive/2.vm/089scenario_filesystem.cc245
-rw-r--r--archive/2.vm/090scenario_filesystem_test.mu99
-rw-r--r--archive/2.vm/091socket.cc348
-rw-r--r--archive/2.vm/092socket.mu177
-rw-r--r--archive/2.vm/099hardware_checks.cc67
-rw-r--r--archive/2.vm/101run_sandboxed.cc711
-rw-r--r--archive/2.vm/998check_type_pointers.cc36
-rw-r--r--archive/2.vm/999spaces.cc86
-rw-r--r--archive/2.vm/Readme.md449
-rw-r--r--archive/2.vm/args.mu8
-rwxr-xr-xarchive/2.vm/build046
-rwxr-xr-xarchive/2.vm/build169
-rwxr-xr-xarchive/2.vm/build2175
-rwxr-xr-xarchive/2.vm/build3201
-rwxr-xr-xarchive/2.vm/build4297
-rwxr-xr-xarchive/2.vm/build_and_test_until18
-rw-r--r--archive/2.vm/cannot_write_tests_for17
-rw-r--r--archive/2.vm/channel.mu45
-rw-r--r--archive/2.vm/chessboard.mu572
-rwxr-xr-xarchive/2.vm/clean9
-rw-r--r--archive/2.vm/cleave/Readme1
-rw-r--r--archive/2.vm/cleave/cleave.cc243
-rw-r--r--archive/2.vm/console.mu16
-rw-r--r--archive/2.vm/continuation1.mu25
-rw-r--r--archive/2.vm/continuation2.mu37
-rw-r--r--archive/2.vm/continuation3.mu34
-rw-r--r--archive/2.vm/continuation4.mu47
-rw-r--r--archive/2.vm/continuation5.mu49
-rwxr-xr-xarchive/2.vm/copy_mu11
-rw-r--r--archive/2.vm/counters.mu29
-rw-r--r--archive/2.vm/display.mu25
-rw-r--r--archive/2.vm/edit/001-editor.mu464
-rw-r--r--archive/2.vm/edit/002-typing.mu1144
-rw-r--r--archive/2.vm/edit/003-shortcuts.mu4462
-rw-r--r--archive/2.vm/edit/004-programming-environment.mu549
-rw-r--r--archive/2.vm/edit/005-sandbox.mu1193
-rw-r--r--archive/2.vm/edit/006-sandbox-copy.mu395
-rw-r--r--archive/2.vm/edit/007-sandbox-delete.mu342
-rw-r--r--archive/2.vm/edit/008-sandbox-edit.mu325
-rw-r--r--archive/2.vm/edit/009-sandbox-test.mu231
-rw-r--r--archive/2.vm/edit/010-sandbox-trace.mu253
-rw-r--r--archive/2.vm/edit/011-errors.mu886
-rw-r--r--archive/2.vm/edit/012-editor-undo.mu2111
-rw-r--r--archive/2.vm/edit/Readme.md49
-rw-r--r--archive/2.vm/example1.mu7
-rw-r--r--archive/2.vm/exception1.mu61
-rw-r--r--archive/2.vm/exception2.mu62
-rw-r--r--archive/2.vm/exuberant_ctags_rc11
-rw-r--r--archive/2.vm/factorial.mu33
-rw-r--r--archive/2.vm/filesystem.mu20
-rw-r--r--archive/2.vm/fork.mu16
-rwxr-xr-xarchive/2.vm/git_log_filtered9
-rw-r--r--archive/2.vm/http-client.mu29
-rw-r--r--archive/2.vm/http-server.mu28
-rw-r--r--archive/2.vm/immutable-error.mu13
-rw-r--r--archive/2.vm/lambda-to-mu.mu590
-rwxr-xr-xarchive/2.vm/mu11
-rw-r--r--archive/2.vm/mu.vim98
-rw-r--r--archive/2.vm/mutable.mu13
-rwxr-xr-xarchive/2.vm/new_lesson15
-rw-r--r--archive/2.vm/nqueens.mu101
-rw-r--r--archive/2.vm/real-files.mu18
-rwxr-xr-xarchive/2.vm/relayout65
-rw-r--r--archive/2.vm/same-fringe.mu89
-rw-r--r--archive/2.vm/sandbox/001-editor.mu464
-rw-r--r--archive/2.vm/sandbox/002-typing.mu1144
-rw-r--r--archive/2.vm/sandbox/003-shortcuts.mu2800
-rw-r--r--archive/2.vm/sandbox/004-programming-environment.mu268
-rw-r--r--archive/2.vm/sandbox/005-sandbox.mu1081
-rw-r--r--archive/2.vm/sandbox/006-sandbox-copy.mu286
-rw-r--r--archive/2.vm/sandbox/007-sandbox-delete.mu345
-rw-r--r--archive/2.vm/sandbox/008-sandbox-edit.mu319
-rw-r--r--archive/2.vm/sandbox/009-sandbox-test.mu233
-rw-r--r--archive/2.vm/sandbox/010-sandbox-trace.mu243
-rw-r--r--archive/2.vm/sandbox/011-errors.mu687
-rw-r--r--archive/2.vm/sandbox/012-editor-undo.mu1907
-rw-r--r--archive/2.vm/sandbox/Readme.md33
-rwxr-xr-xarchive/2.vm/sandbox/mu_run16
-rw-r--r--archive/2.vm/sandbox/tmux.conf3
-rw-r--r--archive/2.vm/screen.mu29
-rwxr-xr-xarchive/2.vm/snapshot_lesson12
-rw-r--r--archive/2.vm/static-dispatch.mu29
-rw-r--r--archive/2.vm/tangle.mu36
-rw-r--r--archive/2.vm/termbox/COPYING19
-rw-r--r--archive/2.vm/termbox/Readme2
-rw-r--r--archive/2.vm/termbox/bytebuffer.inl79
-rw-r--r--archive/2.vm/termbox/input.inl185
-rw-r--r--archive/2.vm/termbox/output.inl320
-rw-r--r--archive/2.vm/termbox/termbox.c397
-rw-r--r--archive/2.vm/termbox/termbox.h190
-rw-r--r--archive/2.vm/termbox/utf8.c79
-rwxr-xr-xarchive/2.vm/test_layers88
-rw-r--r--archive/2.vm/vimrc.vim31
-rw-r--r--archive/2.vm/x.mu8
169 files changed, 0 insertions, 58276 deletions
diff --git a/archive/2.vm/000organization.cc b/archive/2.vm/000organization.cc
deleted file mode 100644
index 9a1938ff..00000000
--- a/archive/2.vm/000organization.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-//: You guessed right: the '000' prefix means you should start reading here.
-//:
-//: This project is set up to load all files with a numeric prefix. Just
-//: create a new file and start hacking.
-//:
-//: The first few files (00*) are independent of what this program does, an
-//: experimental skeleton that will hopefully make it both easier for others to
-//: understand and more malleable, easier to rewrite and remould into radically
-//: different shapes without breaking in subtle corner cases. The premise is
-//: that understandability and rewrite-friendliness are related in a virtuous
-//: cycle. Doing one well makes it easier to do the other.
-//:
-//: Lower down, this file contains a legal, bare-bones C++ program. It doesn't
-//: do anything yet; subsequent files will contain :(...) directives to insert
-//: lines into it. For example:
-//:   :(after "more events")
-//: This directive means: insert the following lines after a line in the
-//: program containing the words "more events".
-//:
-//: A simple tool is included to 'tangle' all the files together in sequence
-//: according to their directives into a single source file containing all the
-//: code for the project, and then feed the source file to the compiler.
-//: (It'll drop these comments starting with a '//:' prefix that only make
-//: sense before tangling.)
-//:
-//: Directives free up the programmer to order code for others to read rather
-//: than as forced by the computer or compiler. Each individual feature can be
-//: organized in a self-contained 'layer' that adds code to many different data
-//: structures and functions all over the program. The right decomposition into
-//: layers will let each layer make sense in isolation.
-//:
-//:   "If I look at any small part of it, I can see what is going on -- I don't
-//:   need to refer to other parts to understand what something is doing.
-//:
-//:   If I look at any large part in overview, I can see what is going on -- I
-//:   don't need to know all the details to get it.
-//:
-//:   Every level of detail is as locally coherent and as well thought-out as
-//:   any other level."
-//:
-//:       -- Richard Gabriel, "The Quality Without A Name"
-//:          (http://dreamsongs.com/Files/PatternsOfSoftware.pdf, page 42)
-//:
-//: Directives are powerful; they permit inserting or modifying any point in
-//: the program. Using them tastefully requires mapping out specific lines as
-//: waypoints for future layers to hook into. Often such waypoints will be in
-//: comments, capitalized to hint that other layers rely on their presence.
-//:
-//: A single waypoint might have many different code fragments hooking into
-//: it from all over the codebase. Use 'before' directives to insert
-//: code at a location in order, top to bottom, and 'after' directives to
-//: insert code in reverse order. By convention waypoints intended for insertion
-//: before begin with 'End'. Notice below how the layers line up above the "End
-//: Foo" waypoint.
-//:
-//:   File 001          File 002                File 003
-//:   ============      ===================     ===================
-//:   // Foo
-//:   ------------
-//:              <----  :(before "End Foo")
-//:                     ....
-//:                     ...
-//:   ------------
-//:              <----------------------------  :(before "End Foo")
-//:                                             ....
-//:                                             ...
-//:   // End Foo
-//:   ============
-//:
-//: Here's part of a layer in color: http://i.imgur.com/0eONnyX.png. Directives
-//: are shaded dark.
-//:
-//: Layers do more than just shuffle code around. In a well-organized codebase
-//: it should be possible to stop loading after any file/layer, build and run
-//: the program, and pass all tests for loaded features. (Relevant is
-//: http://youtube.com/watch?v=c8N72t7aScY, a scene from "2001: A Space
-//: Odyssey".) Get into the habit of running the included script called
-//: 'test_layers' before you commit any changes.
-//:
-//: This 'subsetting guarantee' ensures that this directory contains a
-//: cleaned-up narrative of the evolution of this codebase. Organizing
-//: autobiographically allows newcomers to rapidly orient themselves, reading
-//: the first few files to understand a simple gestalt of a program's core
-//: purpose and features, and later gradually working their way through other
-//: features as the need arises.
-//:
-//: Programmers shouldn't need to understand everything about a program to
-//: hack on it. But they shouldn't be prevented from a thorough understanding
-//: of each aspect either. The goal of layers is to reward curiosity.
-
-// Includes
-// End Includes
-
-// Types
-// End Types
-
-// Function prototypes are auto-generated in the 'build*' scripts; define your
-// functions in any order. Just be sure to declare each function header all on
-// one line, ending with the '{'. Our auto-generation scripts are too minimal
-// and simple-minded to handle anything else.
-#include "function_list"  // by convention, files ending with '_list' are auto-generated
-
-// Globals
-//
-// All statements in this section should always define a single variable on a
-// single line. The 'build*' scripts will simple-mindedly auto-generate extern
-// declarations for them. Remember to define (not just declare) constants with
-// extern linkage in this section, since C++ global constants have internal
-// linkage by default.
-//
-// End Globals
-
-int main(int argc, char* argv[]) {
-  atexit(reset);
-
-  // End One-time Setup
-
-  // Commandline Parsing
-  // End Commandline Parsing
-
-  return 0;  // End Main
-}
-
-// Unit Tests
-// End Unit Tests
-
-//: our first directive; insert the following header at the start of the program
-:(before "End Includes")
-#include <stdlib.h>
-
-//: Without directives or with the :(code) directive, lines get added at the
-//: end.
-:(code)
-void reset() {
-  // End Reset
-}
diff --git a/archive/2.vm/001help.cc b/archive/2.vm/001help.cc
deleted file mode 100644
index 78877561..00000000
--- a/archive/2.vm/001help.cc
+++ /dev/null
@@ -1,264 +0,0 @@
-//: Everything this project/binary supports.
-//: This should give you a sense for what to look forward to in later layers.
-
-:(before "End Commandline Parsing")
-if (argc <= 1 || is_equal(argv[1], "--help")) {
-  //: this is the functionality later layers will provide
-  // currently no automated tests for commandline arg parsing
-  if (argc <= 1) {
-    cerr << "Please provide a Mu program to run.\n"
-         << "\n";
-  }
-  cerr << "Usage:\n"
-       << "  mu [options] [test] [files]\n"
-       << "or:\n"
-       << "  mu [options] [test] [files] -- [ingredients for function/recipe 'main']\n"
-       << "Square brackets surround optional arguments.\n"
-       << "\n"
-       << "Examples:\n"
-       << "  To load files and run 'main':\n"
-       << "    mu file1.mu file2.mu ...\n"
-       << "  To run 'main' and dump a trace of all operations at the end:\n"
-       << "    mu --trace file1.mu file2.mu ...\n"
-       << "  To run all tests:\n"
-       << "    mu test\n"
-       << "  To load files and then run all tests:\n"
-       << "    mu test file1.mu file2.mu ...\n"
-       << "  To run a single Mu scenario:\n"
-       << "    mu test file1.mu file2.mu ... scenario\n"
-       << "  To run a single Mu scenario and dump a trace at the end:\n"
-       << "    mu --trace test file1.mu file2.mu ... scenario\n"
-       << "  To load files and run only the tests in explicitly loaded files (for apps):\n"
-       << "    mu --test-only-app test file1.mu file2.mu ...\n"
-       << "  To load all files with a numeric prefix in a directory:\n"
-       << "    mu directory1 directory2 ...\n"
-       << "  You can test directories just like files.\n"
-       << "    mu test directory1 directory2 ...\n"
-       << "  To pass ingredients to a mu program, provide them after '--':\n"
-       << "    mu file_or_dir1 file_or_dir2 ... -- ingredient1 ingredient2 ...\n"
-       << "  To see where a mu program is spending its time:\n"
-       << "    mu --profile file_or_dir1 file_or_dir2 ...\n"
-       << "  this slices and dices time spent in various profile.* output files\n"
-       << "  To print out the trace to stderr:\n"
-       << "    mu --dump file1.mu file2.mu ...\n"
-       << "  this is handy when you want to see sandboxed traces alongside the main one\n"
-       << "\n"
-       << "  To browse a trace generated by a previous run:\n"
-       << "    mu browse-trace file\n"
-       ;
-  return 0;
-}
-
-//: Support for option parsing.
-//: Options always begin with '--' and are always the first arguments. An
-//: option will never follow a non-option.
-:(before "End Commandline Parsing")
-char** arg = &argv[1];
-while (argc > 1 && starts_with(*arg, "--")) {
-  if (false)
-    ;  // no-op branch just so any further additions can consistently always start with 'else'
-  // End Commandline Options(*arg)
-  else
-    cerr << "skipping unknown option " << *arg << '\n';
-  --argc;  ++argv;  ++arg;
-}
-
-//:: Helper function used by the above fragment of code (and later layers too,
-//:: who knows?).
-//: The :(code) directive appends function definitions to the end of the
-//: project. Regardless of where functions are defined, we can call them
-//: anywhere we like as long as we format the function header in a specific
-//: way: put it all on a single line without indent, end the line with ') {'
-//: and no trailing whitespace. As long as functions uniformly start this
-//: way, our 'build*' scripts contain a little command to automatically
-//: generate declarations for them.
-:(code)
-bool is_equal(char* s, const char* lit) {
-  return strncmp(s, lit, strlen(lit)) == 0;
-}
-
-bool starts_with(const string& s, const string& pat) {
-  string::const_iterator a=s.begin(), b=pat.begin();
-  for (/*nada*/;  a!=s.end() && b!=pat.end();  ++a, ++b)
-    if (*a != *b) return false;
-  return b == pat.end();
-}
-
-//: I'll throw some style conventions here for want of a better place for them.
-//: As a rule I hate style guides. Do what you want, that's my motto. But since
-//: we're dealing with C/C++, the one big thing we want to avoid is undefined
-//: behavior. If a compiler ever encounters undefined behavior it can make
-//: your program do anything it wants.
-//:
-//: For reference, my checklist of undefined behaviors to watch out for:
-//:   out-of-bounds access
-//:   uninitialized variables
-//:   use after free
-//:   dereferencing invalid pointers: null, a new of size 0, others
-//:
-//:   casting a large number to a type too small to hold it
-//:
-//:   integer overflow
-//:   division by zero and other undefined expressions
-//:   left-shift by negative count
-//:   shifting values by more than or equal to the number of bits they contain
-//:   bitwise operations on signed numbers
-//:
-//:   Converting pointers to types of different alignment requirements
-//:     T* -> void* -> T*: defined
-//:     T* -> U* -> T*: defined if non-function pointers and alignment requirements are same
-//:     function pointers may be cast to other function pointers
-//:
-//:       Casting a numeric value into a value that can't be represented by the target type (either directly or via static_cast)
-//:
-//: To guard against these, some conventions:
-//:
-//: 0. Initialize all primitive variables in functions and constructors.
-//:
-//: 1. Minimize use of pointers and pointer arithmetic. Avoid 'new' and
-//: 'delete' as far as possible. Rely on STL to perform memory management to
-//: avoid use-after-free issues (and memory leaks).
-//:
-//: 2. Avoid naked arrays to avoid out-of-bounds access. Never use operator[]
-//: except with map. Use at() with STL vectors and so on.
-//:
-//: 3. Valgrind all the things.
-//:
-//: 4. Avoid unsigned numbers. Not strictly an undefined-behavior issue, but
-//: the extra range doesn't matter, and it's one less confusing category of
-//: interaction gotchas to worry about.
-//:
-//: Corollary: don't use the size() method on containers, since it returns an
-//: unsigned and that'll cause warnings about mixing signed and unsigned,
-//: yadda-yadda. Instead use this macro below to perform an unsafe cast to
-//: signed. We'll just give up immediately if a container's ever too large.
-//: Basically, Mu is not concerned about this being a little slower than it
-//: could be. (https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7)
-//:
-//: Addendum to corollary: We're going to uniformly use int everywhere, to
-//: indicate that we're oblivious to number size, and since Clang on 32-bit
-//: platforms doesn't yet support multiplication over 64-bit integers, and
-//: since multiplying two integers seems like a more common situation to end
-//: up in than integer overflow.
-:(before "End Includes")
-#define SIZE(X) (assert((X).size() < (1LL<<(sizeof(int)*8-2))), static_cast<int>((X).size()))
-
-//: 5. Integer overflow is guarded against at runtime using the -ftrapv flag
-//: to the compiler, supported by Clang (GCC version only works sometimes:
-//: http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work).
-:(before "atexit(reset)")
-initialize_signal_handlers();  // not always necessary, but doesn't hurt
-//? cerr << INT_MAX+1 << '\n';  // test overflow
-//? assert(false);  // test SIGABRT
-:(code)
-// based on https://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c
-void initialize_signal_handlers() {
-  struct sigaction action;
-  bzero(&action, sizeof(action));
-  action.sa_sigaction = dump_and_exit;
-  sigemptyset(&action.sa_mask);
-  sigaction(SIGABRT, &action, NULL);  // assert() failure or integer overflow on linux (with -ftrapv)
-  sigaction(SIGILL,  &action, NULL);  // integer overflow on OS X (with -ftrapv)
-}
-void dump_and_exit(int sig, siginfo_t* /*unused*/, void* /*unused*/) {
-  switch (sig) {
-    case SIGABRT:
-      #ifndef __APPLE__
-        cerr << "SIGABRT: might be an integer overflow if it wasn't an assert() failure or exception\n";
-        _Exit(1);
-      #endif
-      break;
-    case SIGILL:
-      #ifdef __APPLE__
-        cerr << "SIGILL: most likely caused by integer overflow\n";
-        _Exit(1);
-      #endif
-      break;
-    default:
-      break;
-  }
-}
-:(before "End Includes")
-#include <signal.h>
-
-//: For good measure we'll also enable SIGFPE.
-:(before "atexit(reset)")
-feenableexcept(FE_OVERFLOW | FE_UNDERFLOW);
-//? assert(sizeof(int) == 4 && sizeof(float) == 4);
-//? //                          | exp   |  mantissa
-//? int smallest_subnormal = 0b00000000000000000000000000000001;
-//? float smallest_subnormal_f = *reinterpret_cast<float*>(&smallest_subnormal);
-//? cerr << "ε: " << smallest_subnormal_f << '\n';
-//? cerr << "ε/2: " << smallest_subnormal_f/2 << " (underflow)\n";  // test SIGFPE
-:(before "End Includes")
-#include <fenv.h>
-:(code)
-#ifdef __APPLE__
-// Public domain polyfill for feenableexcept on OS X
-// http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
-int feenableexcept(unsigned int excepts) {
-  static fenv_t fenv;
-  unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
-  unsigned int old_excepts;
-  if (fegetenv(&fenv)) return -1;
-  old_excepts = fenv.__control & FE_ALL_EXCEPT;
-  fenv.__control &= ~new_excepts;
-  fenv.__mxcsr &= ~(new_excepts << 7);
-  return fesetenv(&fenv) ? -1 : old_excepts;
-}
-#endif
-
-//: 6. Map's operator[] being non-const is fucking evil.
-:(before "Globals")  // can't generate prototypes for these
-// from http://stackoverflow.com/questions/152643/idiomatic-c-for-reading-from-a-const-map
-template<typename T> typename T::mapped_type& get(T& map, typename T::key_type const& key) {
-  typename T::iterator iter(map.find(key));
-  assert(iter != map.end());
-  return iter->second;
-}
-template<typename T> typename T::mapped_type const& get(const T& map, typename T::key_type const& key) {
-  typename T::const_iterator iter(map.find(key));
-  assert(iter != map.end());
-  return iter->second;
-}
-template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) {
-  // map[key] requires mapped_type to have a zero-arg (default) constructor
-  map.insert(std::make_pair(key, value)).first->second = value;
-  return value;
-}
-template<typename T> bool contains_key(T& map, typename T::key_type const& key) {
-  return map.find(key) != map.end();
-}
-template<typename T> typename T::mapped_type& get_or_insert(T& map, typename T::key_type const& key) {
-  return map[key];
-}
-//: The contract: any container that relies on get_or_insert should never call
-//: contains_key.
-
-//: 7. istreams are a royal pain in the arse. You have to be careful about
-//: what subclass you try to putback into. You have to watch out for the pesky
-//: failbit and badbit. Just avoid eof() and use this helper instead.
-:(code)
-bool has_data(istream& in) {
-  return in && !in.eof();
-}
-
-:(before "End Includes")
-#include <assert.h>
-
-#include <iostream>
-using std::istream;
-using std::ostream;
-using std::iostream;
-using std::cin;
-using std::cout;
-using std::cerr;
-#include <iomanip>
-
-#include <string.h>
-#include <string>
-using std::string;
-
-#include <algorithm>
-using std::min;
-using std::max;
diff --git a/archive/2.vm/002test.cc b/archive/2.vm/002test.cc
deleted file mode 100644
index 817b0d47..00000000
--- a/archive/2.vm/002test.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-//: A simple test harness. To create new tests, define functions starting with
-//: 'test_'. To run all tests so defined, run:
-//:   $ ./mu test
-//:
-//: Every layer should include tests, and can reach into previous layers.
-//: However, it seems like a good idea never to reach into tests from previous
-//: layers. Every test should be a contract that always passes as originally
-//: written, regardless of any later layers. Avoid writing 'temporary' tests
-//: that are only meant to work until some layer.
-
-:(before "End Types")
-typedef void (*test_fn)(void);
-:(before "Globals")
-// move a global ahead into types that we can't generate an extern declaration for
-const test_fn Tests[] = {
-  #include "test_list"  // auto-generated; see 'build*' scripts
-};
-
-:(before "End Globals")
-bool Run_tests = false;
-bool Passed = true;  // set this to false inside any test to indicate failure
-
-:(before "End Includes")
-#define CHECK(X) \
-  if (Passed && !(X)) { \
-    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << '\n'; \
-    Passed = false; \
-    return;  /* Currently we stop at the very first failure. */ \
-  }
-
-#define CHECK_EQ(X, Y) \
-  if (Passed && (X) != (Y)) { \
-    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << " == " << #Y << '\n'; \
-    cerr << "  got " << (X) << '\n';  /* BEWARE: multiple eval */ \
-    Passed = false; \
-    return;  /* Currently we stop at the very first failure. */ \
-  }
-
-:(before "End Reset")
-Passed = true;
-
-:(before "End Commandline Parsing")
-if (argc > 1 && is_equal(argv[1], "test")) {
-  Run_tests = true;  --argc;  ++argv;  // shift 'test' out of commandline args
-}
-
-:(before "End Main")
-if (Run_tests) {
-  // Test Runs
-  // we run some tests and then exit; assume no state need be maintained afterward
-
-  long num_failures = 0;
-  // End Test Run Initialization
-  time_t t;  time(&t);
-  cerr << "C tests: " << ctime(&t);
-  for (size_t i=0;  i < sizeof(Tests)/sizeof(Tests[0]);  ++i) {
-//?     cerr << "running " << Test_names[i] << '\n';
-    run_test(i);
-    if (Passed) cerr << '.';
-    else ++num_failures;
-  }
-  cerr << '\n';
-  // End Tests
-  if (num_failures > 0) {
-    cerr << num_failures << " failure"
-         << (num_failures > 1 ? "s" : "")
-         << '\n';
-    return 1;
-  }
-  return 0;
-}
-
-:(code)
-void run_test(size_t i) {
-  if (i >= sizeof(Tests)/sizeof(Tests[0])) {
-    cerr << "no test " << i << '\n';
-    return;
-  }
-  reset();
-  // End Test Setup
-  (*Tests[i])();
-  // End Test Teardown
-}
-
-//: Convenience: run a single test
-:(before "Globals")
-// Names for each element of the 'Tests' global, respectively.
-const string Test_names[] = {
-  #include "test_name_list"  // auto-generated; see 'build*' scripts
-};
-:(after "Test Runs")
-string maybe_single_test_to_run = argv[argc-1];
-if (!starts_with(maybe_single_test_to_run, "test_"))
-  maybe_single_test_to_run.insert(0, "test_");
-for (size_t i=0;  i < sizeof(Tests)/sizeof(Tests[0]);  ++i) {
-  if (Test_names[i] == maybe_single_test_to_run) {
-    run_test(i);
-    if (Passed) cerr << ".\n";
-    return 0;
-  }
-}
-
-:(before "End Includes")
-#include <stdlib.h>
diff --git a/archive/2.vm/003trace.cc b/archive/2.vm/003trace.cc
deleted file mode 100644
index 18f15347..00000000
--- a/archive/2.vm/003trace.cc
+++ /dev/null
@@ -1,501 +0,0 @@
-//: The goal of layers is to make programs more easy to understand and more
-//: malleable, easy to rewrite in radical ways without accidentally breaking
-//: some corner case. Tests further both goals. They help understandability by
-//: letting one make small changes and get feedback. What if I wrote this line
-//: like so? What if I removed this function call, is it really necessary?
-//: Just try it, see if the tests pass. Want to explore rewriting this bit in
-//: this way? Tests put many refactorings on a firmer footing.
-//:
-//: But the usual way we write tests seems incomplete. Refactorings tend to
-//: work in the small, but don't help with changes to function boundaries. If
-//: you want to extract a new function you have to manually test-drive it to
-//: create tests for it. If you want to inline a function its tests are no
-//: longer valid. In both cases you end up having to reorganize code as well as
-//: tests, an error-prone activity.
-//:
-//: In response, this layer introduces the notion of domain-driven *white-box*
-//: testing. We focus on the domain of inputs the whole program needs to
-//: handle rather than the correctness of individual functions. All white-box
-//: tests invoke the program in a single way: by calling run() with some
-//: input. As the program operates on the input, it traces out a list of
-//: _facts_ deduced about the domain:
-//:   trace("label") << "fact 1: " << val;
-//:
-//: Tests can now check for these facts in the trace:
-//:   CHECK_TRACE_CONTENTS("label", "fact 1: 34\n"
-//:                                 "fact 2: 35\n");
-//:
-//: Since we never call anything but the run() function directly, we never have
-//: to rewrite the tests when we reorganize the internals of the program. We
-//: just have to make sure our rewrite deduces the same facts about the domain,
-//: and that's something we're going to have to do anyway.
-//:
-//: To avoid the combinatorial explosion of integration tests, each layer
-//: mainly logs facts to the trace with a common *label*. All tests in a layer
-//: tend to check facts with this label. Validating the facts logged with a
-//: specific label is like calling functions of that layer directly.
-//:
-//: To build robust tests, trace facts about your domain rather than details of
-//: how you computed them.
-//:
-//: More details: http://akkartik.name/blog/tracing-tests
-//:
-//: ---
-//:
-//: Between layers and domain-driven testing, programming starts to look like a
-//: fundamentally different activity. Instead of focusing on a) superficial,
-//: b) local rules on c) code [like say http://blog.bbv.ch/2013/06/05/clean-code-cheat-sheet],
-//: we allow programmers to engage with the a) deep, b) global structure of
-//: the c) domain. If you can systematically track discontinuities in the
-//: domain, you don't care if the code used gotos as long as it passed all
-//: tests. If tests become more robust to run, it becomes easier to try out
-//: radically different implementations for the same program. If code is
-//: super-easy to rewrite, it becomes less important what indentation style it
-//: uses, or that the objects are appropriately encapsulated, or that the
-//: functions are referentially transparent.
-//:
-//: Instead of plumbing, programming becomes building and gradually refining a
-//: map of the environment the program must operate under. Whether a program
-//: is 'correct' at a given point in time is a red herring; what matters is
-//: avoiding regression by monotonically nailing down the more 'eventful'
-//: parts of the terrain. It helps readers new and old, and rewards curiosity,
-//: to organize large programs in self-similar hierarchies of example tests
-//: colocated with the code that makes them work.
-//:
-//:   "Programming properly should be regarded as an activity by which
-//:   programmers form a mental model, rather than as production of a program."
-//:   -- Peter Naur (http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22)
-
-//:: == Core data structures
-
-:(before "End Globals")
-trace_stream* Trace_stream = NULL;
-
-:(before "End Types")
-struct trace_stream {
-  vector<trace_line> past_lines;
-  // End trace_stream Fields
-
-  trace_stream() {
-    // End trace_stream Constructor
-  }
-  ~trace_stream() {
-    // End trace_stream Destructor
-  }
-  // End trace_stream Methods
-};
-
-//:: == Adding to the trace
-
-//: Top-level method is trace() which can be used like an ostream. Usage:
-//:   trace(depth, label) << ... << end();
-//: Don't forget the 'end()' to actually append to the trace.
-:(before "End Includes")
-// No brackets around the expansion so that it prints nothing if Trace_stream
-// isn't initialized.
-#define trace(...)  !Trace_stream ? cerr : Trace_stream->stream(__VA_ARGS__)
-
-:(before "End trace_stream Fields")
-// accumulator for current trace_line
-ostringstream* curr_stream;
-string curr_label;
-int curr_depth;
-// other stuff
-int collect_depth;  // avoid tracing lower levels for speed
-ofstream null_stream;  // never opened, so writes to it silently fail
-
-//: Some constants.
-:(before "struct trace_stream")  // include constants in all cleaved compilation units
-const int Max_depth = 9999;
-:(before "End trace_stream Constructor")
-curr_stream = NULL;
-curr_depth = Max_depth;
-collect_depth = Max_depth;
-
-:(before "struct trace_stream")
-struct trace_line {
-  string contents;
-  string label;
-  int depth;  // 0 is 'sea level'; positive integers are progressively 'deeper' and lower level
-  trace_line(string c, string l) {
-    contents = c;
-    label = l;
-    depth = 0;
-  }
-  trace_line(string c, string l, int d) {
-    contents = c;
-    label = l;
-    depth = d;
-  }
-};
-
-//: Starting a new trace line.
-:(before "End trace_stream Methods")
-ostream& stream(string label) {
-  return stream(Max_depth, label);
-}
-
-ostream& stream(int depth, string label) {
-  if (depth > collect_depth) return null_stream;
-  curr_stream = new ostringstream;
-  curr_label = label;
-  curr_depth = depth;
-  return *curr_stream;
-}
-
-//: End of a trace line; append it to the trace.
-:(before "End Types")
-struct end {};
-:(code)
-ostream& operator<<(ostream& os, end /*unused*/) {
-  if (Trace_stream) Trace_stream->newline();
-  return os;
-}
-
-:(before "End trace_stream Methods")
-void newline();
-:(code)
-void trace_stream::newline() {
-  if (!curr_stream) return;
-  string curr_contents = curr_stream->str();
-  if (!curr_contents.empty()) {
-    past_lines.push_back(trace_line(curr_contents, trim(curr_label), curr_depth));  // preserve indent in contents
-    // maybe incrementally dump trace
-    trace_line& t = past_lines.back();
-    if (should_incrementally_print_trace()) {
-      cerr       << std::setw(4) << t.depth << ' ' << t.label << ": " << t.contents << '\n';
-    }
-    // End trace Commit
-  }
-
-  // clean up
-  delete curr_stream;
-  curr_stream = NULL;
-  curr_label.clear();
-  curr_depth = Max_depth;
-}
-
-//:: == Initializing the trace in tests
-
-:(before "End Includes")
-#define START_TRACING_UNTIL_END_OF_SCOPE  lease_tracer leased_tracer;
-:(before "End Test Setup")
-START_TRACING_UNTIL_END_OF_SCOPE
-
-//: Trace_stream is a resource, lease_tracer uses RAII to manage it.
-:(before "End Types")
-struct lease_tracer {
-  lease_tracer();
-  ~lease_tracer();
-};
-:(code)
-lease_tracer::lease_tracer() { Trace_stream = new trace_stream; }
-lease_tracer::~lease_tracer() {
-  delete Trace_stream;
-  Trace_stream = NULL;
-}
-
-//:: == Errors using traces
-
-:(before "End Includes")
-#define raise  (!Trace_stream ? (scroll_to_bottom_and_close_console(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
-
-//: Print errors to the screen by default.
-:(before "struct trace_stream")  // include constants in all cleaved compilation units
-const int Error_depth = 0;
-:(before "End Globals")
-int Hide_errors = false;  // if set, don't print errors to screen
-:(before "End Reset")
-Hide_errors = false;
-:(code)
-bool trace_stream::should_incrementally_print_trace() {
-  if (!Hide_errors && curr_depth == Error_depth) return true;
-  // End Incremental Trace Print Conditions
-  return false;
-}
-:(before "End trace_stream Methods")
-bool should_incrementally_print_trace();
-
-:(before "End Globals")
-int Trace_errors = 0;  // used only when Trace_stream is NULL
-
-// Fail tests that displayed (unexpected) errors.
-// Expected errors should always be hidden and silently checked for.
-:(before "End Test Teardown")
-if (Passed && !Hide_errors && trace_contains_errors()) {
-  Passed = false;
-}
-:(code)
-bool trace_contains_errors() {
-  return Trace_errors > 0 || trace_count("error") > 0;
-}
-
-:(before "End Includes")
-// If we aren't yet sure how to deal with some corner case, use assert_for_now
-// to indicate that it isn't an inviolable invariant.
-#define assert_for_now assert
-#define raise_for_now raise
-
-//: Automatically close the console in some situations.
-:(before "End One-time Setup")
-atexit(scroll_to_bottom_and_close_console);
-:(code)
-void scroll_to_bottom_and_close_console() {
-  if (!tb_is_active()) return;
-  // leave the screen in a relatively clean state
-  tb_set_cursor(tb_width()-1, tb_height()-1);
-  cout << "\r\n";
-  tb_shutdown();
-}
-:(before "End Includes")
-#include "termbox/termbox.h"
-
-//:: == Other assertions on traces
-//: Primitives:
-//:   - CHECK_TRACE_CONTENTS(lines)
-//:     Assert that the trace contains the given lines (separated by newlines)
-//:     in order. There can be other intervening lines between them.
-//:   - CHECK_TRACE_DOESNT_CONTAIN(line)
-//:   - CHECK_TRACE_DOESNT_CONTAIN(label, contents)
-//:     Assert that the trace doesn't contain the given (single) line.
-//:   - CHECK_TRACE_COUNT(label, count)
-//:     Assert that the trace contains exactly 'count' lines with the given
-//:     'label'.
-//:   - CHECK_TRACE_CONTAINS_ERRORS()
-//:   - CHECK_TRACE_DOESNT_CONTAIN_ERRORS()
-//:   - trace_count_prefix(label, prefix)
-//:     Count the number of trace lines with the given 'label' that start with
-//:     the given 'prefix'.
-
-:(before "End Includes")
-#define CHECK_TRACE_CONTENTS(...)  check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
-
-#define CHECK_TRACE_DOESNT_CONTAIN(...)  CHECK(trace_doesnt_contain(__VA_ARGS__))
-
-#define CHECK_TRACE_COUNT(label, count) \
-  if (Passed && trace_count(label) != (count)) { \
-    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
-    cerr << "  got " << trace_count(label) << '\n';  /* multiple eval */ \
-    DUMP(label); \
-    Passed = false; \
-    return;  /* Currently we stop at the very first failure. */ \
-  }
-
-#define CHECK_TRACE_CONTAINS_ERRORS()  CHECK(trace_contains_errors())
-#define CHECK_TRACE_DOESNT_CONTAIN_ERRORS() \
-  if (Passed && trace_contains_errors()) { \
-    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
-    DUMP("error"); \
-    Passed = false; \
-    return; \
-  }
-
-// Allow tests to ignore trace lines generated during setup.
-#define CLEAR_TRACE  delete Trace_stream, Trace_stream = new trace_stream
-
-:(code)
-bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {
-  if (!Passed) return false;
-  if (!Trace_stream) return false;
-  vector<string> expected_lines = split(expected, "\n");
-  int curr_expected_line = 0;
-  while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty())
-    ++curr_expected_line;
-  if (curr_expected_line == SIZE(expected_lines)) return true;
-  string label, contents;
-  split_label_contents(expected_lines.at(curr_expected_line), &label, &contents);
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin();  p != Trace_stream->past_lines.end();  ++p) {
-    if (label != p->label) continue;
-    if (contents != trim(p->contents)) continue;
-    ++curr_expected_line;
-    while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty())
-      ++curr_expected_line;
-    if (curr_expected_line == SIZE(expected_lines)) return true;
-    split_label_contents(expected_lines.at(curr_expected_line), &label, &contents);
-  }
-
-  if (line_exists_anywhere(label, contents)) {
-    cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n";
-    DUMP("");
-  }
-  else {
-    cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n";
-    DUMP(label);
-  }
-  Passed = false;
-  return false;
-}
-
-bool trace_doesnt_contain(string expected) {
-  vector<string> tmp = split_first(expected, ": ");
-  if (SIZE(tmp) == 1) {
-    raise << expected << ": missing label or contents in trace line\n" << end();
-    assert(false);
-  }
-  return trace_count(tmp.at(0), tmp.at(1)) == 0;
-}
-
-int trace_count(string label) {
-  return trace_count(label, "");
-}
-
-int trace_count(string label, string line) {
-  if (!Trace_stream) return 0;
-  long result = 0;
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin();  p != Trace_stream->past_lines.end();  ++p) {
-    if (label == p->label) {
-      if (line == "" || trim(line) == trim(p->contents))
-        ++result;
-    }
-  }
-  return result;
-}
-
-int trace_count_prefix(string label, string prefix) {
-  if (!Trace_stream) return 0;
-  long result = 0;
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin();  p != Trace_stream->past_lines.end();  ++p) {
-    if (label == p->label) {
-      if (starts_with(trim(p->contents), trim(prefix)))
-        ++result;
-    }
-  }
-  return result;
-}
-
-void split_label_contents(const string& s, string* label, string* contents) {
-  static const string delim(": ");
-  size_t pos = s.find(delim);
-  if (pos == string::npos) {
-    *label = "";
-    *contents = trim(s);
-  }
-  else {
-    *label = trim(s.substr(0, pos));
-    *contents = trim(s.substr(pos+SIZE(delim)));
-  }
-}
-
-bool line_exists_anywhere(const string& label, const string& contents) {
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin();  p != Trace_stream->past_lines.end();  ++p) {
-    if (label != p->label) continue;
-    if (contents == trim(p->contents)) return true;
-  }
-  return false;
-}
-
-vector<string> split(string s, string delim) {
-  vector<string> result;
-  size_t begin=0, end=s.find(delim);
-  while (true) {
-    if (end == string::npos) {
-      result.push_back(string(s, begin, string::npos));
-      break;
-    }
-    result.push_back(string(s, begin, end-begin));
-    begin = end+SIZE(delim);
-    end = s.find(delim, begin);
-  }
-  return result;
-}
-
-vector<string> split_first(string s, string delim) {
-  vector<string> result;
-  size_t end=s.find(delim);
-  result.push_back(string(s, 0, end));
-  if (end != string::npos)
-    result.push_back(string(s, end+SIZE(delim), string::npos));
-  return result;
-}
-
-//:: == Helpers for debugging using traces
-
-:(before "End Includes")
-// To debug why a test is failing, dump its trace using '?'.
-#define DUMP(label)  if (Trace_stream) cerr << Trace_stream->readable_contents(label);
-
-// To add temporary prints to the trace, use 'dbg'.
-// `git log` should never show any calls to 'dbg'.
-#define dbg trace(0, "a")
-
-//: Dump the entire trace to file where it can be browsed offline.
-//: Dump the trace as it happens; that way you get something even if the
-//: program crashes.
-
-:(before "End Globals")
-ofstream Trace_file;
-:(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--trace")) {
-  Trace_stream = new trace_stream;
-  cerr << "saving trace to 'last_run'\n";
-  Trace_file.open("last_run");
-  // Add a dummy line up top; otherwise the `browse_trace` tool currently has
-  // no way to expand any lines above an error.
-  Trace_file << "   0 dummy: start\n";
-}
-:(before "End trace Commit")
-if (Trace_file) {
-  Trace_file << std::setw(4) << t.depth << ' ' << t.label << ": " << t.contents << '\n';
-}
-:(before "End One-time Setup")
-atexit(cleanup_main);
-:(code)
-void cleanup_main() {
-  if (Trace_file) Trace_file.close();
-  // End cleanup_main
-}
-
-:(before "End trace_stream Methods")
-string readable_contents(string label) {
-  string trim(const string& s);  // prototype
-  ostringstream output;
-  label = trim(label);
-  for (vector<trace_line>::iterator p = past_lines.begin();  p != past_lines.end();  ++p)
-    if (label.empty() || label == p->label)
-      output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n';
-  return output.str();
-}
-
-//: Print traces to the screen as they happen.
-//: Particularly useful when juggling multiple trace streams, like when
-//: debugging sandboxes.
-:(before "End Globals")
-bool Dump_trace = false;
-:(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--dump")) {
-  Dump_trace = true;
-}
-:(before "End Incremental Trace Print Conditions")
-if (Dump_trace) return true;
-
-//: Miscellaneous helpers.
-
-:(code)
-string trim(const string& s) {
-  string::const_iterator first = s.begin();
-  while (first != s.end() && isspace(*first))
-    ++first;
-  if (first == s.end()) return "";
-
-  string::const_iterator last = --s.end();
-  while (last != s.begin() && isspace(*last))
-    --last;
-  ++last;
-  return string(first, last);
-}
-
-:(before "End Includes")
-#include <vector>
-using std::vector;
-#include <list>
-using std::list;
-#include <set>
-using std::set;
-
-#include <sstream>
-using std::istringstream;
-using std::ostringstream;
-
-#include <fstream>
-using std::ifstream;
-using std::ofstream;
diff --git a/archive/2.vm/003trace.test.cc b/archive/2.vm/003trace.test.cc
deleted file mode 100644
index 30f61b5a..00000000
--- a/archive/2.vm/003trace.test.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-void test_trace_check_compares() {
-  trace("test layer") << "foo" << end();
-  CHECK_TRACE_CONTENTS("test layer: foo");
-}
-
-void test_trace_check_ignores_other_layers() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 2") << "bar" << end();
-  CHECK_TRACE_CONTENTS("test layer 1: foo");
-  CHECK_TRACE_DOESNT_CONTAIN("test layer 2: foo");
-}
-
-void test_trace_check_ignores_leading_whitespace() {
-  trace("test layer 1") << " foo" << end();
-  CHECK_EQ(trace_count("test layer 1", /*too little whitespace*/"foo"), 1);
-  CHECK_EQ(trace_count("test layer 1", /*too much whitespace*/"  foo"), 1);
-}
-
-void test_trace_check_ignores_other_lines() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 1") << "bar" << end();
-  CHECK_TRACE_CONTENTS("test layer 1: foo");
-}
-
-void test_trace_check_ignores_other_lines2() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 1") << "bar" << end();
-  CHECK_TRACE_CONTENTS("test layer 1: bar");
-}
-
-void test_trace_ignores_trailing_whitespace() {
-  trace("test layer 1") << "foo\n" << end();
-  CHECK_TRACE_CONTENTS("test layer 1: foo");
-}
-
-void test_trace_ignores_trailing_whitespace2() {
-  trace("test layer 1") << "foo " << end();
-  CHECK_TRACE_CONTENTS("test layer 1: foo");
-}
-
-void test_trace_orders_across_layers() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 2") << "bar" << end();
-  trace("test layer 1") << "qux" << end();
-  CHECK_TRACE_CONTENTS("test layer 1: foo\n"
-                       "test layer 2: bar\n"
-                       "test layer 1: qux\n");
-}
-
-void test_trace_supports_count() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 1") << "foo" << end();
-  CHECK_EQ(trace_count("test layer 1", "foo"), 2);
-}
-
-void test_trace_supports_count2() {
-  trace("test layer 1") << "foo" << end();
-  trace("test layer 1") << "bar" << end();
-  CHECK_EQ(trace_count("test layer 1"), 2);
-}
-
-void test_trace_count_ignores_trailing_whitespace() {
-  trace("test layer 1") << "foo\n" << end();
-  CHECK_EQ(trace_count("test layer 1", "foo"), 1);
-}
-
-// pending: DUMP tests
-// pending: readable_contents() adds newline if necessary.
-// pending: raise also prints to stderr.
-// pending: raise doesn't print to stderr if Hide_errors is set.
-// pending: raise doesn't have to be saved if Hide_errors is set, just printed.
-// pending: raise prints to stderr if Trace_stream is NULL.
-// pending: raise prints to stderr if Trace_stream is NULL even if Hide_errors is set.
-
-// can't check trace because trace methods call 'split'
-
-void test_split_returns_at_least_one_elem() {
-  vector<string> result = split("", ",");
-  CHECK_EQ(result.size(), 1);
-  CHECK_EQ(result.at(0), "");
-}
-
-void test_split_returns_entire_input_when_no_delim() {
-  vector<string> result = split("abc", ",");
-  CHECK_EQ(result.size(), 1);
-  CHECK_EQ(result.at(0), "abc");
-}
-
-void test_split_works() {
-  vector<string> result = split("abc,def", ",");
-  CHECK_EQ(result.size(), 2);
-  CHECK_EQ(result.at(0), "abc");
-  CHECK_EQ(result.at(1), "def");
-}
-
-void test_split_works2() {
-  vector<string> result = split("abc,def,ghi", ",");
-  CHECK_EQ(result.size(), 3);
-  CHECK_EQ(result.at(0), "abc");
-  CHECK_EQ(result.at(1), "def");
-  CHECK_EQ(result.at(2), "ghi");
-}
-
-void test_split_handles_multichar_delim() {
-  vector<string> result = split("abc,,def,,ghi", ",,");
-  CHECK_EQ(result.size(), 3);
-  CHECK_EQ(result.at(0), "abc");
-  CHECK_EQ(result.at(1), "def");
-  CHECK_EQ(result.at(2), "ghi");
-}
-
-void test_trim() {
-  CHECK_EQ(trim(""), "");
-  CHECK_EQ(trim(" "), "");
-  CHECK_EQ(trim("  "), "");
-  CHECK_EQ(trim("a"), "a");
-  CHECK_EQ(trim(" a"), "a");
-  CHECK_EQ(trim("  a"), "a");
-  CHECK_EQ(trim("  ab"), "ab");
-  CHECK_EQ(trim("a "), "a");
-  CHECK_EQ(trim("a  "), "a");
-  CHECK_EQ(trim("ab  "), "ab");
-  CHECK_EQ(trim(" a "), "a");
-  CHECK_EQ(trim("  a  "), "a");
-  CHECK_EQ(trim("  ab  "), "ab");
-}
diff --git a/archive/2.vm/010vm.cc b/archive/2.vm/010vm.cc
deleted file mode 100644
index 42b867fc..00000000
--- a/archive/2.vm/010vm.cc
+++ /dev/null
@@ -1,900 +0,0 @@
-//: A Mu program is a book of 'recipes' (functions)
-:(before "End Globals")
-//: Each recipe is stored at a specific page number, or ordinal.
-map<recipe_ordinal, recipe> Recipe;
-//: You can also refer to each recipe by its name.
-map<string, recipe_ordinal> Recipe_ordinal;
-recipe_ordinal Next_recipe_ordinal = 1;
-
-//: Ordinals are like numbers, except you can't do arithmetic on them. Ordinal
-//: 1 is not less than 2, it's just different. Phone numbers are ordinals;
-//: adding two phone numbers is meaningless. Here each recipe does something
-//: incommensurable with any other recipe.
-:(after "Types")
-typedef int recipe_ordinal;
-
-:(before "End Types")
-// Recipes are lists of instructions. To perform or 'run' a recipe, the
-// computer runs its instructions.
-struct recipe {
-  recipe_ordinal ordinal;
-  string name;
-  vector<instruction> steps;
-  // End recipe Fields
-  recipe();
-};
-
-:(before "struct recipe")
-// Each instruction is either of the form:
-//   product1, product2, product3, ... <- operation ingredient1, ingredient2, ingredient3, ...
-// or just a single 'label' starting with a non-alphanumeric character
-//   +label
-// Labels don't do anything, they're just named locations in a recipe.
-struct instruction {
-  bool is_label;
-  string label;  // only if is_label
-  string name;  // only if !is_label
-  string original_string;  // for error messages
-  recipe_ordinal operation;  // get(Recipe_ordinal, name)
-  vector<reagent> ingredients;  // only if !is_label
-  vector<reagent> products;  // only if !is_label
-  // End instruction Fields
-  instruction();
-  void clear();
-  bool is_empty();
-};
-
-:(before "struct instruction")
-// Ingredients and products are a single species -- a reagent. Reagents refer
-// either to numbers or to locations in memory along with 'type' tags telling
-// us how to interpret them. They also can contain arbitrary other lists of
-// properties besides types, but we're getting ahead of ourselves.
-struct reagent {
-  string original_string;
-  string name;
-  type_tree* type;
-  vector<pair<string, string_tree*> > properties;  // can't be a map because the string_tree sometimes needs to be NULL, which can be confusing
-  double value;
-  bool initialized;
-  // End reagent Fields
-  reagent(const string& s);
-  reagent() :type(NULL), value(0), initialized(false) {}
-  reagent(type_tree* t) :type(t), value(0), initialized(false) {}
-  ~reagent();
-  void clear();
-  reagent(const reagent& original);
-  reagent& operator=(const reagent& original);
-  void set_value(double v) { value = v;  initialized = true; }
-};
-
-:(before "struct reagent")
-// Types can range from a simple type ordinal, to arbitrarily complex trees of
-// type parameters, like (map (address array character) (list number))
-struct type_tree {
-  bool atom;
-  string name;  // only if atom
-  type_ordinal value;  // only if atom
-  type_tree* left;  // only if !atom
-  type_tree* right;  // only if !atom
-  ~type_tree();
-  type_tree(const type_tree& original);
-  // atomic type ordinal
-  explicit type_tree(string name);
-  type_tree(string name, type_ordinal v) :atom(true), name(name), value(v), left(NULL), right(NULL) {}
-  // tree of type ordinals
-  type_tree(type_tree* l, type_tree* r) :atom(false), value(0), left(l), right(r) {}
-  type_tree& operator=(const type_tree& original);
-  bool operator==(const type_tree& other) const;
-  bool operator!=(const type_tree& other) const { return !operator==(other); }
-  bool operator<(const type_tree& other) const;
-  bool operator>(const type_tree& other) const { return other.operator<(*this); }
-};
-
-struct string_tree {
-  bool atom;
-  string value;  // only if atom
-  string_tree* left;  // only if !atom
-  string_tree* right;  // only if !atom
-  ~string_tree();
-  string_tree(const string_tree& original);
-  // atomic string
-  explicit string_tree(string v) :atom(true), value(v), left(NULL), right(NULL) {}
-  // tree of strings
-  string_tree(string_tree* l, string_tree* r) :atom(false), left(l), right(r) {}
-};
-
-// End type_tree Definition
-:(code)
-type_tree::type_tree(string name) :atom(true), name(name), value(get(Type_ordinal, name)), left(NULL), right(NULL) {}
-
-:(before "End Globals")
-// Locations refer to a common 'memory'. Each location can store a number.
-map<int, double> Memory;
-:(before "End Reset")
-Memory.clear();
-
-:(after "Types")
-// Mu types encode how the numbers stored in different parts of memory are
-// interpreted. A location tagged as a 'character' type will interpret the
-// value 97 as the letter 'a', while a different location of type 'number'
-// would not.
-//
-// Unlike most computers today, Mu stores types in a single big table, shared
-// by all the Mu programs on the computer. This is useful in providing a
-// seamless experience to help understand arbitrary Mu programs.
-typedef int type_ordinal;
-:(before "End Globals")
-map<string, type_ordinal> Type_ordinal;
-map<type_ordinal, type_info> Type;
-type_ordinal Next_type_ordinal = 1;
-type_ordinal Number_type_ordinal = 0;
-type_ordinal Boolean_type_ordinal = 0;
-type_ordinal Character_type_ordinal = 0;
-type_ordinal Address_type_ordinal = 0;
-type_ordinal Array_type_ordinal = 0;
-:(code)
-void setup_types() {
-  Type.clear();  Type_ordinal.clear();
-  put(Type_ordinal, "literal", 0);
-  Next_type_ordinal = 1;
-  // Mu Types Initialization
-  Number_type_ordinal = put(Type_ordinal, "number", Next_type_ordinal++);
-  get_or_insert(Type, Number_type_ordinal).name = "number";
-  put(Type_ordinal, "location", Number_type_ordinal);  // synonym of number for addresses we'll never look up
-  Address_type_ordinal = put(Type_ordinal, "address", Next_type_ordinal++);
-  get_or_insert(Type, Address_type_ordinal).name = "address";
-  Boolean_type_ordinal = put(Type_ordinal, "boolean", Next_type_ordinal++);
-  get_or_insert(Type, Boolean_type_ordinal).name = "boolean";
-  Character_type_ordinal = put(Type_ordinal, "character", Next_type_ordinal++);
-  get_or_insert(Type, Character_type_ordinal).name = "character";
-  // Array types are a special modifier to any other type. For example,
-  // array:number or array:address:boolean.
-  Array_type_ordinal = put(Type_ordinal, "array", Next_type_ordinal++);
-  get_or_insert(Type, Array_type_ordinal).name = "array";
-  // End Mu Types Initialization
-}
-void teardown_types() {
-  for (map<type_ordinal, type_info>::iterator p = Type.begin();  p != Type.end();  ++p) {
-    for (int i = 0;  i < SIZE(p->second.elements);  ++i)
-      p->second.elements.clear();
-  }
-  Type_ordinal.clear();
-}
-:(before "End One-time Setup")
-setup_types();
-atexit(teardown_types);
-
-:(before "End Types")
-// You can construct arbitrary new types. New types are either 'containers'
-// with multiple 'elements' of other types, or 'exclusive containers' containing
-// one of multiple 'variants'. (These are similar to C structs and unions,
-// respectively, though exclusive containers implicitly include a tag element
-// recording which variant they should be interpreted as.)
-//
-// For example, storing bank balance and name for an account might require a
-// container, but if bank accounts may be either for individuals or groups,
-// with different properties for each, that may require an exclusive container
-// whose variants are individual-account and joint-account containers.
-enum kind_of_type {
-  PRIMITIVE,
-  CONTAINER,
-  EXCLUSIVE_CONTAINER
-};
-
-struct type_info {
-  string name;
-  kind_of_type kind;
-  vector<reagent> elements;
-  // End type_info Fields
-  type_info() :kind(PRIMITIVE) {
-    // End type_info Constructor
-  }
-};
-
-enum primitive_recipes {
-  IDLE = 0,
-  COPY,
-  // End Primitive Recipe Declarations
-  MAX_PRIMITIVE_RECIPES,
-};
-:(code)
-//: It's all very well to construct recipes out of other recipes, but we need
-//: to know how to do *something* out of the box. For the following
-//: recipes there are only codes, no entries in the book, because Mu just knows
-//: what to do for them.
-void setup_recipes() {
-  Recipe.clear();  Recipe_ordinal.clear();
-  put(Recipe_ordinal, "idle", IDLE);
-  // Primitive Recipe Numbers
-  put(Recipe_ordinal, "copy", COPY);
-  // End Primitive Recipe Numbers
-}
-//: We could just reset the recipe table after every test, but that gets slow
-//: all too quickly. Instead, initialize the common stuff just once at
-//: startup. Later layers will carefully undo each test's additions after
-//: itself.
-:(before "End One-time Setup")
-setup_recipes();
-assert(MAX_PRIMITIVE_RECIPES < 200);  // level 0 is primitives; until 199
-Next_recipe_ordinal = 200;
-put(Recipe_ordinal, "main", Next_recipe_ordinal++);
-// Load Mu Prelude
-// End Mu Prelude
-:(before "End Commandline Parsing")
-assert(Next_recipe_ordinal < 1000);  // recipes being tested didn't overflow into test space
-:(before "End Reset")
-Next_recipe_ordinal = 1000;  // consistent new numbers for each test
-
-//: One final detail: tests can modify our global tables of recipes and types,
-//: so we need some way to clean up after each test is done so it doesn't
-//: influence later ones.
-:(before "End Globals")
-map<string, recipe_ordinal> Recipe_ordinal_snapshot;
-map<recipe_ordinal, recipe> Recipe_snapshot;
-map<string, type_ordinal> Type_ordinal_snapshot;
-map<type_ordinal, type_info> Type_snapshot;
-:(before "End One-time Setup")
-save_snapshots();
-:(before "End Reset")
-restore_snapshots();
-
-:(code)
-void save_snapshots() {
-  Recipe_ordinal_snapshot = Recipe_ordinal;
-  Recipe_snapshot = Recipe;
-  Type_ordinal_snapshot = Type_ordinal;
-  Type_snapshot = Type;
-  // End save_snapshots
-}
-
-void restore_snapshots() {
-  Recipe = Recipe_snapshot;
-  Recipe_ordinal = Recipe_ordinal_snapshot;
-  restore_non_recipe_snapshots();
-}
-// when running sandboxes in the edit/ app we'll want to restore everything except recipes defined in the app
-void restore_non_recipe_snapshots() {
-  Type_ordinal = Type_ordinal_snapshot;
-  Type = Type_snapshot;
-  // End restore_snapshots
-}
-
-//:: Helpers
-
-:(code)
-recipe::recipe() {
-  ordinal = -1;
-  // End recipe Constructor
-}
-
-instruction::instruction() :is_label(false), operation(IDLE) {
-  // End instruction Constructor
-}
-void instruction::clear() {
-  is_label=false;
-  label.clear();
-  name.clear();
-  operation=IDLE;
-  ingredients.clear();
-  products.clear();
-  original_string.clear();
-  // End instruction Clear
-}
-bool instruction::is_empty() { return !is_label && name.empty(); }
-
-// Reagents have the form <name>:<type>:<type>:.../<property>/<property>/...
-reagent::reagent(const string& s) :original_string(s), type(NULL), value(0), initialized(false) {
-  // Parsing reagent(string s)
-  istringstream in(s);
-  in >> std::noskipws;
-  // name and type
-  istringstream first_row(slurp_until(in, '/'));
-  first_row >> std::noskipws;
-  name = slurp_until(first_row, ':');
-  string_tree* type_names = parse_property_list(first_row);
-  // End Parsing Reagent Type Property(type_names)
-  type = new_type_tree(type_names);
-  delete type_names;
-  // special cases
-  if (is_integer(name) && type == NULL)
-    type = new type_tree("literal");
-  if (name == "_" && type == NULL)
-    type = new type_tree("literal");
-  // other properties
-  slurp_properties(in, properties);
-  // End Parsing reagent
-}
-
-void slurp_properties(istream& in, vector<pair<string, string_tree*> >& out) {
-  while (has_data(in)) {
-    istringstream row(slurp_until(in, '/'));
-    row >> std::noskipws;
-    string key = slurp_until(row, ':');
-    string_tree* value = parse_property_list(row);
-    out.push_back(pair<string, string_tree*>(key, value));
-  }
-}
-
-string_tree* parse_property_list(istream& in) {
-  skip_whitespace_but_not_newline(in);
-  if (!has_data(in)) return NULL;
-  string_tree* first = new string_tree(slurp_until(in, ':'));
-  if (!has_data(in)) return first;
-  string_tree* rest = parse_property_list(in);
-  if (!has_data(in) && rest->atom)
-    return new string_tree(first, new string_tree(rest, NULL));
-  return new string_tree(first, rest);
-}
-:(before "End Unit Tests")
-void test_parse_property_list_atom() {
-  istringstream in("a");
-  string_tree* x = parse_property_list(in);
-  CHECK(x->atom);
-  delete x;
-}
-void test_parse_property_list_list() {
-  istringstream in("a:b");
-  string_tree* x = parse_property_list(in);
-  CHECK(!x->atom);
-  CHECK(x->left->atom);
-  CHECK_EQ(x->left->value, "a");
-  CHECK(!x->right->atom);
-  CHECK(x->right->left->atom);
-  CHECK_EQ(x->right->left->value, "b");
-  CHECK(x->right->right == NULL);
-  delete x;
-}
-
-:(code)
-type_tree* new_type_tree(const string_tree* properties) {
-  if (!properties) return NULL;
-  if (properties->atom) {
-    const string& type_name = properties->value;
-    int value = 0;
-    if (contains_key(Type_ordinal, type_name))
-      value = get(Type_ordinal, type_name);
-    else if (is_integer(type_name))  // sometimes types will contain literal integers, like for the size of an array
-      value = 0;
-    else if (properties->value == "->")  // used in recipe types
-      value = 0;
-    else
-      value = -1;  // should never happen; will trigger errors later
-    return new type_tree(type_name, value);
-  }
-  return new type_tree(new_type_tree(properties->left),
-                       new_type_tree(properties->right));
-}
-
-//: avoid memory leaks for the type tree
-
-reagent::reagent(const reagent& other) {
-  original_string = other.original_string;
-  name = other.name;
-  value = other.value;
-  initialized = other.initialized;
-  for (int i = 0;  i < SIZE(other.properties);  ++i) {
-    properties.push_back(pair<string, string_tree*>(other.properties.at(i).first, copy(other.properties.at(i).second)));
-  }
-  type = copy(other.type);
-  // End reagent Copy Constructor
-}
-
-type_tree::type_tree(const type_tree& original) {
-  atom = original.atom;
-  name = original.name;
-  value = original.value;
-  left = copy(original.left);
-  right = copy(original.right);
-}
-
-type_tree& type_tree::operator=(const type_tree& original) {
-  atom = original.atom;
-  name = original.name;
-  value = original.value;
-  if (left) delete left;
-  left = copy(original.left);
-  if (right) delete right;
-  right = copy(original.right);
-  return *this;
-}
-
-bool type_tree::operator==(const type_tree& other) const {
-  if (atom != other.atom) return false;
-  if (atom)
-    return name == other.name && value == other.value;
-  return (left == other.left || *left == *other.left)
-      && (right == other.right || *right == *other.right);
-}
-
-// only constraint we care about: if a < b then !(b < a)
-bool type_tree::operator<(const type_tree& other) const {
-  if (atom != other.atom) return atom > other.atom;  // atoms before non-atoms
-  if (atom) return value < other.value;
-  // first location in one that's missing in the other makes that side 'smaller'
-  if (left && !other.left) return false;
-  if (!left && other.left) return true;
-  if (right && !other.right) return false;
-  if (!right && other.right) return true;
-  // now if either pointer is unequal neither side can be null
-  // if one side is equal that's easy
-  if (left == other.left || *left == *other.left) return right && *right < *other.right;
-  if (right == other.right || *right == *other.right) return left && *left < *other.left;
-  // if the two sides criss-cross, pick the side with the smaller lhs
-  if ((left == other.right || *left == *other.right)
-      && (right == other.left || *right == *other.left))
-    return *left < *other.left;
-  // now the hard case: both sides are not equal
-  // make sure we stay consistent between (a < b) and (b < a)
-  // just return the side with the smallest of the 4 branches
-  if (*left < *other.left && *left < *other.right) return true;
-  if (*right < *other.left && *right < *other.right) return true;
-  return false;
-}
-:(before "End Unit Tests")
-// These unit tests don't always use valid types.
-void test_compare_atom_types() {
-  reagent a("a:address"), b("b:boolean");
-  CHECK(*a.type < *b.type);
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_equal_atom_types() {
-  reagent a("a:address"), b("b:address");
-  CHECK(!(*a.type < *b.type));
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_atom_with_non_atom() {
-  reagent a("a:address:number"), b("b:boolean");
-  CHECK(!(*a.type < *b.type));
-  CHECK(*b.type < *a.type);
-}
-void test_compare_lists_with_identical_structure() {
-  reagent a("a:address:address"), b("b:address:boolean");
-  CHECK(*a.type < *b.type);
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_identical_lists() {
-  reagent a("a:address:boolean"), b("b:address:boolean");
-  CHECK(!(*a.type < *b.type));
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_list_with_extra_element() {
-  reagent a("a:address:address"), b("b:address:address:number");
-  CHECK(*a.type < *b.type);
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_list_with_smaller_left_but_larger_right() {
-  reagent a("a:number:character"), b("b:boolean:array");
-  CHECK(*a.type < *b.type);
-  CHECK(!(*b.type < *a.type));
-}
-void test_compare_list_with_smaller_left_but_larger_right_identical_types() {
-  reagent a("a:address:boolean"), b("b:boolean:address");
-  CHECK(*a.type < *b.type);
-  CHECK(!(*b.type < *a.type));
-}
-
-:(code)
-string_tree::string_tree(const string_tree& original) {
-  atom = original.atom;
-  value = original.value;
-  left = copy(original.left);
-  right = copy(original.right);
-}
-
-reagent& reagent::operator=(const reagent& other) {
-  original_string = other.original_string;
-  for (int i = 0;  i < SIZE(properties);  ++i)
-    if (properties.at(i).second) delete properties.at(i).second;
-  properties.clear();
-  for (int i = 0;  i < SIZE(other.properties);  ++i)
-    properties.push_back(pair<string, string_tree*>(other.properties.at(i).first, copy(other.properties.at(i).second)));
-  name = other.name;
-  value = other.value;
-  initialized = other.initialized;
-  if (type) delete type;
-  type = copy(other.type);
-  // End reagent Copy Operator
-  return *this;
-}
-
-reagent::~reagent() {
-  clear();
-}
-
-void reagent::clear() {
-  for (int i = 0;  i < SIZE(properties);  ++i) {
-    if (properties.at(i).second) {
-      delete properties.at(i).second;
-      properties.at(i).second = NULL;
-    }
-  }
-  delete type;
-  type = NULL;
-}
-type_tree::~type_tree() {
-  delete left;
-  delete right;
-}
-string_tree::~string_tree() {
-  delete left;
-  delete right;
-}
-
-void append(type_tree*& base, type_tree* extra) {
-  if (!base) {
-    base = extra;
-    return;
-  }
-  type_tree* curr = base;
-  while (curr->right) curr = curr->right;
-  curr->right = extra;
-}
-
-void append(string_tree*& base, string_tree* extra) {
-  if (!base) {
-    base = extra;
-    return;
-  }
-  string_tree* curr = base;
-  while (curr->right) curr = curr->right;
-  curr->right = extra;
-}
-
-string slurp_until(istream& in, char delim) {
-  ostringstream out;
-  char c;
-  while (in >> c) {
-    if (c == delim) {
-      // drop the delim
-      break;
-    }
-    out << c;
-  }
-  return out.str();
-}
-
-bool has_property(const reagent& x, const string& name) {
-  for (int i = 0;  i < SIZE(x.properties);  ++i) {
-    if (x.properties.at(i).first == name) return true;
-  }
-  return false;
-}
-
-string_tree* property(const reagent& r, const string& name) {
-  for (int p = 0;  p != SIZE(r.properties);  ++p) {
-    if (r.properties.at(p).first == name)
-      return r.properties.at(p).second;
-  }
-  return NULL;
-}
-
-string_tree* copy(const string_tree* x) {
-  if (x == NULL) return NULL;
-  return new string_tree(*x);
-}
-
-type_tree* copy(const type_tree* x) {
-  if (x == NULL) return NULL;
-  return new type_tree(*x);
-}
-
-:(before "End Globals")
-extern const string Ignore(",");  // commas are ignored in Mu except within [] strings
-:(code)
-void skip_whitespace_but_not_newline(istream& in) {
-  while (true) {
-    if (!has_data(in)) break;
-    else if (in.peek() == '\n') break;
-    else if (isspace(in.peek())) in.get();
-    else if (Ignore.find(in.peek()) != string::npos) in.get();
-    else break;
-  }
-}
-
-void dump_memory() {
-  for (map<int, double>::iterator p = Memory.begin();  p != Memory.end();  ++p) {
-    cerr << p->first << ": " << no_scientific(p->second) << '\n';
-  }
-}
-
-//:: Helpers for converting various values to string
-//: Use to_string() in trace(), and try to keep it stable from run to run.
-//: Use debug_string() while debugging, and throw everything into it.
-//: Use inspect() only for emitting a canonical format that can be parsed back
-//: into the value.
-
-string to_string(const recipe& r) {
-  ostringstream out;
-  out << "recipe " << r.name << " [\n";
-  for (int i = 0;  i < SIZE(r.steps);  ++i)
-    out << "  " << to_string(r.steps.at(i)) << '\n';
-  out << "]\n";
-  return out.str();
-}
-
-string to_original_string(const recipe& r) {
-  ostringstream out;
-  out << "recipe " << r.name << " [\n";
-  for (int i = 0;  i < SIZE(r.steps);  ++i)
-    out << "  " << to_original_string(r.steps.at(i)) << '\n';
-  out << "]\n";
-  return out.str();
-}
-
-string debug_string(const recipe& x) {
-  ostringstream out;
-  out << "- recipe " << x.name << '\n';
-  // Begin debug_string(recipe x)
-  for (int index = 0;  index < SIZE(x.steps);  ++index) {
-    const instruction& inst = x.steps.at(index);
-    out << "inst: " << to_string(inst) << '\n';
-    out << "  ingredients\n";
-    for (int i = 0;  i < SIZE(inst.ingredients);  ++i)
-      out << "    " << debug_string(inst.ingredients.at(i)) << '\n';
-    out << "  products\n";
-    for (int i = 0;  i < SIZE(inst.products);  ++i)
-      out << "    " << debug_string(inst.products.at(i)) << '\n';
-  }
-  return out.str();
-}
-
-string to_original_string(const instruction& inst) {
-  if (inst.is_label) return inst.label;
-  if (!inst.original_string.empty()) return inst.original_string;
-  ostringstream out;
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (i > 0) out << ", ";
-    out << inst.products.at(i).original_string;
-  }
-  if (!inst.products.empty()) out << " <- ";
-  out << inst.name;
-  if (!inst.ingredients.empty()) out << ' ';
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (i > 0) out << ", ";
-    out << inst.ingredients.at(i).original_string;
-  }
-  return out.str();
-}
-
-string to_string(const instruction& inst) {
-  if (inst.is_label) return inst.label;
-  ostringstream out;
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (i > 0) out << ", ";
-    out << to_string(inst.products.at(i));
-  }
-  if (!inst.products.empty()) out << " <- ";
-  out << inst.name << ' ';
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (i > 0) out << ", ";
-    out << to_string(inst.ingredients.at(i));
-  }
-  return out.str();
-}
-
-string to_string(const reagent& r) {
-  if (is_dummy(r)) return "_";
-  ostringstream out;
-  out << "{";
-  out << r.name << ": " << names_to_string(r.type);
-  if (!r.properties.empty()) {
-    for (int i = 0;  i < SIZE(r.properties);  ++i)
-      out << ", \"" << r.properties.at(i).first << "\": " << to_string(r.properties.at(i).second);
-  }
-  out << "}";
-  return out.str();
-}
-
-// special name for ignoring some products
-bool is_dummy(const reagent& x) {
-  return x.name == "_";
-}
-
-string debug_string(const reagent& x) {
-  ostringstream out;
-  out << x.name << ": " << x.value << ' ' << to_string(x.type) << " -- " << to_string(x);
-  return out.str();
-}
-
-string to_string(const string_tree* property) {
-  if (!property) return "()";
-  ostringstream out;
-  dump(property, out);
-  return out.str();
-}
-
-void dump(const string_tree* x, ostream& out) {
-  if (!x) return;
-  if (x->atom) {
-    out << '"' << x->value << '"';
-    return;
-  }
-  out << '(';
-  const string_tree* curr = x;
-  while (curr && !curr->atom) {
-    dump(curr->left, out);
-    if (curr->right) out << ' ';
-    curr = curr->right;
-  }
-  // check for dotted list; should never happen
-  if (curr) {
-    out << ". ";
-    dump(curr, out);
-  }
-  out << ')';
-}
-
-string to_string(const type_tree* type) {
-  if (type == NULL) return "()";
-  ostringstream out;
-  dump(type, out);
-  return out.str();
-}
-
-void dump(const type_tree* x, ostream& out) {
-  if (!x) return;
-  if (x->atom) {
-    dump(x->value, out);
-    return;
-  }
-  out << '(';
-  const type_tree* curr = x;
-  while (curr && !curr->atom) {
-    dump(curr->left, out);
-    if (curr->right) out << ' ';
-    curr = curr->right;
-  }
-  // check for dotted list; should never happen
-  if (curr) {
-    out << ". ";
-    dump(curr, out);
-  }
-  out << ')';
-}
-
-void dump(type_ordinal type, ostream& out) {
-  if (contains_key(Type, type))
-    out << get(Type, type).name;
-  else
-    out << "?" << type;
-}
-
-string names_to_string(const type_tree* type) {
-  if (type == NULL) return "()";  // should never happen
-  ostringstream out;
-  dump_names(type, out);
-  return out.str();
-}
-
-void dump_names(const type_tree* x, ostream& out) {
-  if (!x) return;
-  if (x->atom) {
-    out << '"' << x->name << '"';
-    return;
-  }
-  out << '(';
-  const type_tree* curr = x;
-  while (curr && !curr->atom) {
-    dump_names(curr->left, out);
-    if (curr->right) out << ' ';
-    curr = curr->right;
-  }
-  // check for dotted list; should never happen
-  if (curr) {
-    out << ". ";
-    dump_names(curr, out);
-  }
-  out << ')';
-}
-
-string names_to_string_without_quotes(const type_tree* type) {
-  if (type == NULL) return "()";
-  ostringstream out;
-  dump_names_without_quotes(type, out);
-  return out.str();
-}
-
-void dump_names_without_quotes(const type_tree* x, ostream& out) {
-  if (!x) return;
-  if (x->atom) {
-    out << x->name;
-    return;
-  }
-  out << '(';
-  const type_tree* curr = x;
-  while (curr && !curr->atom) {
-    dump_names_without_quotes(curr->left, out);
-    if (curr->right) out << ' ';
-    curr = curr->right;
-  }
-  // check for dotted list; should never happen
-  if (curr) {
-    out << ". ";
-    dump_names_without_quotes(curr, out);
-  }
-  out << ')';
-}
-
-bool is_integer(const string& s) {
-  return s.find_first_not_of("0123456789-") == string::npos  // no other characters
-      && s.find_first_of("0123456789") != string::npos  // at least one digit
-      && s.find('-', 1) == string::npos;  // '-' only at first position
-}
-
-int to_integer(string n) {
-  char* end = NULL;
-  // safe because string.c_str() is guaranteed to be null-terminated
-  int result = strtoll(n.c_str(), &end, /*any base*/0);
-  if (*end != '\0') cerr << "tried to convert " << n << " to number\n";
-  assert(*end == '\0');
-  return result;
-}
-
-void test_is_integer() {
-  CHECK(is_integer("1234"));
-  CHECK(is_integer("-1"));
-  CHECK(!is_integer("234.0"));
-  CHECK(is_integer("-567"));
-  CHECK(!is_integer("89-0"));
-  CHECK(!is_integer("-"));
-  CHECK(!is_integer("1e3"));  // not supported
-}
-
-//: helper to print numbers without excessive precision
-
-:(before "End Types")
-struct no_scientific {
-  double x;
-  explicit no_scientific(double y) :x(y) {}
-};
-
-:(code)
-ostream& operator<<(ostream& os, no_scientific x) {
-  if (!isfinite(x.x)) {
-    // Infinity or NaN
-    os << x.x;
-    return os;
-  }
-  ostringstream tmp;
-  // more accurate, but too slow
-//?   tmp.precision(308);  // for 64-bit numbers
-  tmp << std::fixed << x.x;
-  os << trim_floating_point(tmp.str());
-  return os;
-}
-
-string trim_floating_point(const string& in) {
-  if (in.empty()) return "";
-  if (in.find('.') == string::npos) return in;
-  int length = SIZE(in);
-  while (length > 1) {
-    if (in.at(length-1) != '0') break;
-    --length;
-  }
-  if (in.at(length-1) == '.') --length;
-  if (length == 0) return "0";
-  return in.substr(0, length);
-}
-
-void test_trim_floating_point() {
-  CHECK_EQ(trim_floating_point(""), "");
-  CHECK_EQ(trim_floating_point(".0"), "0");
-  CHECK_EQ(trim_floating_point("1.5000"), "1.5");
-  CHECK_EQ(trim_floating_point("1.000001"), "1.000001");
-  CHECK_EQ(trim_floating_point("23.000000"), "23");
-  CHECK_EQ(trim_floating_point("23.0"), "23");
-  CHECK_EQ(trim_floating_point("23."), "23");
-  CHECK_EQ(trim_floating_point("23"), "23");
-  CHECK_EQ(trim_floating_point("230"), "230");
-  CHECK_EQ(trim_floating_point("3.000000"), "3");
-  CHECK_EQ(trim_floating_point("3.0"), "3");
-  CHECK_EQ(trim_floating_point("3."), "3");
-  CHECK_EQ(trim_floating_point("3"), "3");
-}
-
-:(before "End Includes")
-#include <map>
-using std::map;
-#include <utility>
-using std::pair;
-#include <math.h>
diff --git a/archive/2.vm/011load.cc b/archive/2.vm/011load.cc
deleted file mode 100644
index 4bb06c36..00000000
--- a/archive/2.vm/011load.cc
+++ /dev/null
@@ -1,489 +0,0 @@
-//: Phase 1 of running Mu code: load it from a textual representation.
-//:
-//: The process of running Mu code:
-//:   load -> transform -> run
-
-void test_first_recipe() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-vector<recipe_ordinal> load(string form) {
-  istringstream in(form);
-  in >> std::noskipws;
-  return load(in);
-}
-
-vector<recipe_ordinal> load(istream& in) {
-  in >> std::noskipws;
-  vector<recipe_ordinal> result;
-  while (has_data(in)) {
-    skip_whitespace_and_comments(in);
-    if (!has_data(in)) break;
-    string command = next_word(in);
-    if (command.empty()) {
-      assert(!has_data(in));
-      break;
-    }
-    // Command Handlers
-    if (command == "recipe" || command == "def") {
-      recipe_ordinal r = slurp_recipe(in);
-      if (r > 0) result.push_back(r);
-    }
-    else if (command == "recipe!" || command == "def!") {
-      Disable_redefine_checks = true;
-      recipe_ordinal r = slurp_recipe(in);
-      if (r > 0) result.push_back(r);
-      Disable_redefine_checks = false;
-    }
-    // End Command Handlers
-    else {
-      raise << "unknown top-level command: " << command << '\n' << end();
-    }
-  }
-  return result;
-}
-
-// return the recipe ordinal slurped, or -1 if it failed
-int slurp_recipe(istream& in) {
-  recipe result;
-  result.name = next_word(in);
-  if (result.name.empty()) {
-    assert(!has_data(in));
-    raise << "file ended with 'recipe'\n" << end();
-    return -1;
-  }
-  // End Load Recipe Name
-  skip_whitespace_but_not_newline(in);
-  // End Recipe Refinements
-  if (result.name.empty())
-    raise << "empty result.name\n" << end();
-  trace(101, "parse") << "--- defining " << result.name << end();
-  if (!contains_key(Recipe_ordinal, result.name))
-    put(Recipe_ordinal, result.name, Next_recipe_ordinal);
-  result.ordinal = get(Recipe_ordinal, result.name);
-  ++Next_recipe_ordinal;
-  if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) {
-    trace(101, "parse") << "already exists" << end();
-    if (should_check_for_redefine(result.name))
-      raise << "redefining recipe " << result.name << "\n" << end();
-    Recipe.erase(get(Recipe_ordinal, result.name));
-  }
-  slurp_body(in, result);
-  // End Recipe Body(result)
-  put(Recipe, get(Recipe_ordinal, result.name), result);
-  return get(Recipe_ordinal, result.name);
-}
-
-void slurp_body(istream& in, recipe& result) {
-  in >> std::noskipws;
-  skip_whitespace_but_not_newline(in);
-  if (in.get() != '[')
-    raise << result.name << ": recipe body must begin with '['\n" << end();
-  skip_whitespace_and_comments(in);  // permit trailing comment after '['
-  instruction curr;
-  while (next_instruction(in, &curr)) {
-    curr.original_string = to_original_string(curr);
-    // End Rewrite Instruction(curr, recipe result)
-    trace(102, "load") << "after rewriting: " << to_string(curr) << end();
-    if (!curr.is_empty()) result.steps.push_back(curr);
-  }
-}
-
-bool next_instruction(istream& in, instruction* curr) {
-  curr->clear();
-  skip_whitespace_and_comments(in);
-  if (!has_data(in)) {
-    raise << "incomplete recipe at end of file (0)\n" << end();
-    return false;
-  }
-
-  vector<string> words;
-  while (has_data(in) && in.peek() != '\n') {
-    skip_whitespace_but_not_newline(in);
-    if (!has_data(in)) {
-      raise << "incomplete recipe at end of file (1)\n" << end();
-      return false;
-    }
-    string word = next_word(in);
-    if (word.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete recipe at end of file (2)\n" << end();
-      return false;
-    }
-    words.push_back(word);
-    skip_whitespace_but_not_newline(in);
-  }
-  skip_whitespace_and_comments(in);
-  if (SIZE(words) == 1 && words.at(0) == "]")
-    return false;  // end of recipe
-
-  if (SIZE(words) == 1 && is_label_word(words.at(0))) {
-    curr->is_label = true;
-    curr->label = words.at(0);
-    trace(103, "parse") << "label: " << curr->label << end();
-    if (!has_data(in)) {
-      raise << "incomplete recipe at end of file (3)\n" << end();
-      return false;
-    }
-    return true;
-  }
-
-  vector<string>::iterator p = words.begin();
-  if (find(words.begin(), words.end(), "<-") != words.end()) {
-    for (;  *p != "<-";  ++p)
-      curr->products.push_back(reagent(*p));
-    ++p;  // skip <-
-  }
-
-  if (p == words.end()) {
-    raise << "instruction prematurely ended with '<-'\n" << end();
-    return false;
-  }
-  curr->name = *p;  ++p;
-  // curr->operation will be set at transform time
-
-  for (;  p != words.end();  ++p)
-    curr->ingredients.push_back(reagent(*p));
-
-  trace(103, "parse") << "instruction: " << curr->name << end();
-  trace(103, "parse") << "  number of ingredients: " << SIZE(curr->ingredients) << end();
-  for (vector<reagent>::iterator p = curr->ingredients.begin();  p != curr->ingredients.end();  ++p)
-    trace(103, "parse") << "  ingredient: " << to_string(*p) << end();
-  for (vector<reagent>::iterator p = curr->products.begin();  p != curr->products.end();  ++p)
-    trace(103, "parse") << "  product: " << to_string(*p) << end();
-  if (!has_data(in)) {
-    raise << "9: unbalanced '[' for recipe\n" << end();
-    return false;
-  }
-  // End next_instruction(curr)
-  return true;
-}
-
-// can return empty string -- only if 'in' has no more data
-string next_word(istream& in) {
-  skip_whitespace_but_not_newline(in);
-  // End next_word Special-cases
-  ostringstream out;
-  slurp_word(in, out);
-  skip_whitespace_and_comments_but_not_newline(in);
-  string result = out.str();
-  if (result != "[" && ends_with(result, '['))
-    raise << "insert a space before '[' in '" << result << "'\n" << end();
-  return result;
-}
-
-bool is_label_word(const string& word) {
-  if (word.empty()) return false;  // error raised elsewhere
-  return !isalnum(word.at(0)) && string("$_*@&,=-[]()").find(word.at(0)) == string::npos;
-}
-
-bool ends_with(const string& s, const char c) {
-  if (s.empty()) return false;
-  return *s.rbegin() == c;
-}
-
-:(before "End Globals")
-// word boundaries
-extern const string Terminators("(){}");
-:(code)
-void slurp_word(istream& in, ostream& out) {
-  char c;
-  if (has_data(in) && Terminators.find(in.peek()) != string::npos) {
-    in >> c;
-    out << c;
-    return;
-  }
-  while (in >> c) {
-    if (isspace(c) || Terminators.find(c) != string::npos || Ignore.find(c) != string::npos) {
-      in.putback(c);
-      break;
-    }
-    out << c;
-  }
-}
-
-void skip_whitespace_and_comments(istream& in) {
-  while (true) {
-    if (!has_data(in)) break;
-    if (isspace(in.peek())) in.get();
-    else if (Ignore.find(in.peek()) != string::npos) in.get();
-    else if (in.peek() == '#') skip_comment(in);
-    else break;
-  }
-}
-
-// confusing; move to the next line only to skip a comment, but never otherwise
-void skip_whitespace_and_comments_but_not_newline(istream& in) {
-  while (true) {
-    if (!has_data(in)) break;
-    if (in.peek() == '\n') break;
-    if (isspace(in.peek())) in.get();
-    else if (Ignore.find(in.peek()) != string::npos) in.get();
-    else if (in.peek() == '#') skip_comment(in);
-    else break;
-  }
-}
-
-void skip_comment(istream& in) {
-  if (has_data(in) && in.peek() == '#') {
-    in.get();
-    while (has_data(in) && in.peek() != '\n') in.get();
-  }
-}
-
-void test_recipe_instead_of_def() {
-  load(
-      "recipe main [\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_comment_outside_recipe() {
-  load(
-      "# comment\n"
-      "def main [\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_comment_amongst_instruction() {
-  load(
-      "def main [\n"
-      "  # comment\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_comment_amongst_instruction_2() {
-  load(
-      "def main [\n"
-      "  # comment\n"
-      "  1:number <- copy 23\n"
-      "  # comment\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_comment_amongst_instruction_3() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 23\n"
-      "  # comment\n"
-      "  2:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {2: \"number\"}\n"
-  );
-}
-
-void test_parse_comment_after_instruction() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 23  # comment\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_label() {
-  load(
-      "def main [\n"
-      "  +foo\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: label: +foo\n"
-  );
-}
-
-void test_parse_dollar_as_recipe_name() {
-  load(
-      "def main [\n"
-      "  $foo\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: $foo\n"
-  );
-}
-
-void test_parse_multiple_properties() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 23/foo:bar:baz\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\", \"foo\": (\"bar\" \"baz\")}\n"
-      "parse:   product: {1: \"number\"}\n"
-  );
-}
-
-void test_parse_multiple_products() {
-  load(
-      "def main [\n"
-      "  1:number, 2:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-      "parse:   product: {2: \"number\"}\n"
-  );
-}
-
-void test_parse_multiple_ingredients() {
-  load(
-      "def main [\n"
-      "  1:number, 2:number <- copy 23, 4:number\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   ingredient: {4: \"number\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-      "parse:   product: {2: \"number\"}\n"
-  );
-}
-
-void test_parse_multiple_types() {
-  load(
-      "def main [\n"
-      "  1:number, 2:address:number <- copy 23, 4:number\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: instruction: copy\n"
-      "parse:   ingredient: {23: \"literal\"}\n"
-      "parse:   ingredient: {4: \"number\"}\n"
-      "parse:   product: {1: \"number\"}\n"
-      "parse:   product: {2: (\"address\" \"number\")}\n"
-  );
-}
-
-void test_parse_properties() {
-  load(
-      "def main [\n"
-      "  1:address:number/lookup <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: (\"address\" \"number\"), \"lookup\": ()}\n"
-  );
-}
-
-void test_parse_comment_terminated_by_eof() {
-  load("recipe main [\n"
-       "  a:number <- copy 34\n"
-       "]\n"
-       "# abc");  // no newline after comment
-  cerr << ".";  // termination = success
-}
-
-void test_warn_on_missing_space_before_bracket() {
-  Hide_errors = true;
-  load(
-      "def main[\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: insert a space before '[' in 'main['\n"
-  );
-}
-
-//: Warn if a recipe gets redefined, because large codebases can accidentally
-//: step on their own toes. But there'll be many occasions later where
-//: we'll want to disable the errors.
-:(before "End Globals")
-bool Disable_redefine_checks = false;
-:(before "End Reset")
-Disable_redefine_checks = false;
-:(code)
-bool should_check_for_redefine(const string& recipe_name) {
-  if (Disable_redefine_checks) return false;
-  return true;
-}
-
-void test_forbid_redefining_recipes() {
-  Hide_errors = true;
-  load(
-      "def main [\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-      "def main [\n"
-      "  1:number <- copy 24\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: redefining recipe main\n"
-  );
-}
-
-void test_permit_forcibly_redefining_recipes() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 23\n"
-      "]\n"
-      "def! main [\n"
-      "  1:number <- copy 24\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: redefining recipe main");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-// for debugging
-void show_rest_of_stream(istream& in) {
-  cerr << '^';
-  char c;
-  while (in >> c)
-    cerr << c;
-  cerr << "$\n";
-  exit(0);
-}
diff --git a/archive/2.vm/012transform.cc b/archive/2.vm/012transform.cc
deleted file mode 100644
index 758a286c..00000000
--- a/archive/2.vm/012transform.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-//: Phase 2: Filter loaded recipes through an extensible list of 'transforms'.
-//:
-//:   The process of running Mu code:
-//:     load -> transform -> run
-//:
-//: The hope is that this framework of transform tools will provide a
-//: deconstructed alternative to conventional compilers.
-//:
-//: We're going to have many transforms in Mu, and getting their order right
-//: (not the same as ordering of layers) is a well-known problem. Some tips:
-//:   a) Design each layer to rely on as few previous layers as possible.
-//:
-//:   b) When positioning transforms, try to find the tightest constraint in
-//:   each transform relative to previous layers.
-//:
-//:   c) Even so you'll periodically need to try adjusting each transform
-//:   relative to those in previous layers to find a better arrangement.
-
-:(before "End recipe Fields")
-int transformed_until;
-:(before "End recipe Constructor")
-transformed_until = -1;
-
-:(before "End Types")
-typedef void (*transform_fn)(const recipe_ordinal);
-
-:(before "End Globals")
-vector<transform_fn> Transform;
-
-:(before "End One-time Setup")
-initialize_transforms();
-:(code)
-void initialize_transforms() {
-  // Begin Transforms
-    // Begin Instruction Inserting/Deleting Transforms
-    // End Instruction Inserting/Deleting Transforms
-
-    // Begin Instruction Modifying Transforms
-    // End Instruction Modifying Transforms
-  // End Transforms
-
-  // Begin Checks
-  // End Checks
-}
-
-void transform_all() {
-  trace(100, "transform") << "=== transform_all()" << end();
-  // Begin transform_all
-  for (int t = 0;  t < SIZE(Transform);  ++t) {
-    for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin();  p != Recipe.end();  ++p) {
-      recipe& r = p->second;
-      if (r.transformed_until != t-1) continue;
-      // End Transform Checks
-      (*Transform.at(t))(/*recipe_ordinal*/p->first);
-      r.transformed_until = t;
-    }
-  }
-  parse_int_reagents();  // do this after all other transforms have run
-  // End transform_all
-}
-
-//: Even though a run will involve many calls to transform_all() for tests,
-//: our logical model is to load all code, then transform all code, then run.
-//: If you load new code that should cause already-transformed recipes to
-//: change, that's not supported. To help detect such situations and raise
-//: helpful errors we track a count of the number of calls made to
-//: transform_all().
-:(before "End Globals")
-int Num_calls_to_transform_all = 0;
-:(after "void transform_all()")
-  ++Num_calls_to_transform_all;
-
-:(code)
-void parse_int_reagents() {
-  trace(101, "transform") << "--- parsing any uninitialized reagents as integers" << end();
-  for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin();  p != Recipe.end();  ++p) {
-    recipe& r = p->second;
-    if (r.steps.empty()) continue;
-    for (int index = 0;  index < SIZE(r.steps);  ++index) {
-      instruction& inst = r.steps.at(index);
-      for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-        populate_value(inst.ingredients.at(i));
-      }
-      for (int i = 0;  i < SIZE(inst.products);  ++i) {
-        populate_value(inst.products.at(i));
-      }
-    }
-  }
-}
-
-void populate_value(reagent& r) {
-  if (r.initialized) return;
-  // End Reagent-parsing Exceptions
-  if (!is_integer(r.name)) return;
-  r.set_value(to_integer(r.name));
-}
-
-// helper for tests -- temporarily suppress run
-void transform(string form) {
-  load(form);
-  transform_all();
-}
diff --git a/archive/2.vm/013update_operation.cc b/archive/2.vm/013update_operation.cc
deleted file mode 100644
index ffe3dbb9..00000000
--- a/archive/2.vm/013update_operation.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-//: Once all code is loaded, save operation ids of instructions and check that
-//: nothing's undefined.
-
-:(before "End Instruction Modifying Transforms")
-Transform.push_back(update_instruction_operations);  // idempotent
-
-:(code)
-void update_instruction_operations(const recipe_ordinal r) {
-  trace(101, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end();
-  recipe& caller = get(Recipe, r);
-//?   cerr << "--- compute instruction operations for recipe " << caller.name << '\n';
-  for (int index = 0;  index < SIZE(caller.steps);  ++index) {
-    instruction& inst = caller.steps.at(index);
-    if (inst.is_label) continue;
-    if (!contains_key(Recipe_ordinal, inst.name)) {
-      raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe in '" << to_original_string(inst) << "'\n" << end();
-      continue;
-    }
-    inst.operation = get(Recipe_ordinal, inst.name);
-    // End Instruction Operation Checks
-  }
-}
-
-// hook to suppress inserting recipe name into errors
-string maybe(string recipe_name) {
-  // End maybe(recipe_name) Special-cases
-  return recipe_name + ": ";
-}
-
-void test_missing_arrow() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  1:number , copy 0\n"  // typo: ',' instead of '<-'
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: instruction '1:number' has no recipe in '1:number copy, 0'\n"
-  );
-}
diff --git a/archive/2.vm/014literal_string.cc b/archive/2.vm/014literal_string.cc
deleted file mode 100644
index 84dbe8d0..00000000
--- a/archive/2.vm/014literal_string.cc
+++ /dev/null
@@ -1,274 +0,0 @@
-//: For convenience, some instructions will take literal arrays of characters
-//: (text or strings).
-//:
-//: Instead of quotes, we'll use [] to delimit strings. That'll reduce the
-//: need for escaping since we can support nested brackets. And we can also
-//: imagine that 'recipe' might one day itself be defined in Mu, doing its own
-//: parsing.
-
-void test_string_literal() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [abc def]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"abc def\": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_with_colons() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [abc:def/ghi]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"abc:def/ghi\": \"literal-string\"}\n"
-  );
-}
-
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "literal-string", 0);
-
-:(before "End next_word Special-cases")
-if (in.peek() == '[') {
-  string result = slurp_quoted(in);
-  skip_whitespace_and_comments_but_not_newline(in);
-  return result;
-}
-
-:(code)
-string slurp_quoted(istream& in) {
-  ostringstream out;
-  assert(has_data(in));  assert(in.peek() == '[');  out << static_cast<char>(in.get());  // slurp the '['
-  if (is_code_string(in, out))
-    slurp_quoted_comment_aware(in, out);
-  else
-    slurp_quoted_comment_oblivious(in, out);
-  return out.str();
-}
-
-// A string is a code string (ignores comments when scanning for matching
-// brackets) if it contains a newline at the start before any non-whitespace.
-bool is_code_string(istream& in, ostream& out) {
-  while (has_data(in)) {
-    char c = in.get();
-    if (!isspace(c)) {
-      in.putback(c);
-      return false;
-    }
-    out << c;
-    if (c == '\n') {
-      return true;
-    }
-  }
-  return false;
-}
-
-// Read a regular string. Regular strings can only contain other regular
-// strings.
-void slurp_quoted_comment_oblivious(istream& in, ostream& out) {
-  int brace_depth = 1;
-  while (has_data(in)) {
-    char c = in.get();
-    if (c == '\\') {
-      slurp_one_past_backslashes(in, out);
-      continue;
-    }
-    out << c;
-    if (c == '[') ++brace_depth;
-    if (c == ']') --brace_depth;
-    if (brace_depth == 0) break;
-  }
-  if (!has_data(in) && brace_depth > 0) {
-    raise << "unbalanced '['\n" << end();
-    out.clear();
-  }
-}
-
-// Read a code string. Code strings can contain either code or regular strings.
-void slurp_quoted_comment_aware(istream& in, ostream& out) {
-  char c;
-  while (in >> c) {
-    if (c == '\\') {
-      slurp_one_past_backslashes(in, out);
-      continue;
-    }
-    if (c == '#') {
-      out << c;
-      while (has_data(in) && in.peek() != '\n') out << static_cast<char>(in.get());
-      continue;
-    }
-    if (c == '[') {
-      in.putback(c);
-      // recurse
-      out << slurp_quoted(in);
-      continue;
-    }
-    out << c;
-    if (c == ']') return;
-  }
-  raise << "unbalanced '['\n" << end();
-  out.clear();
-}
-
-:(after "Parsing reagent(string s)")
-if (starts_with(s, "[")) {
-  if (*s.rbegin() != ']') return;  // unbalanced bracket; handled elsewhere
-  name = s;
-  // delete [] delimiters
-  name.erase(0, 1);
-  strip_last(name);
-  type = new type_tree("literal-string", 0);
-  return;
-}
-
-//: Unlike other reagents, escape newlines in literal strings to make them
-//: more friendly to trace().
-
-:(after "string to_string(const reagent& r)")
-  if (is_literal_text(r))
-    return emit_literal_string(r.name);
-
-:(code)
-bool is_literal_text(const reagent& x) {
-  return x.type && x.type->name == "literal-string";
-}
-
-string emit_literal_string(string name) {
-  size_t pos = 0;
-  while (pos != string::npos)
-    pos = replace(name, "\n", "\\n", pos);
-  return "{\""+name+"\": \"literal-string\"}";
-}
-
-size_t replace(string& str, const string& from, const string& to, size_t n) {
-  size_t result = str.find(from, n);
-  if (result != string::npos)
-    str.replace(result, from.length(), to);
-  return result;
-}
-
-void strip_last(string& s) {
-  if (!s.empty()) s.erase(SIZE(s)-1);
-}
-
-void slurp_one_past_backslashes(istream& in, ostream& out) {
-  // When you encounter a backslash, strip it out and pass through any
-  // following run of backslashes. If we 'escaped' a single following
-  // character, then the character '\' would be:
-  //   '\\' escaped once
-  //   '\\\\' escaped twice
-  //   '\\\\\\\\' escaped thrice (8 backslashes)
-  // ..and so on. With our approach it'll be:
-  //   '\\' escaped once
-  //   '\\\' escaped twice
-  //   '\\\\' escaped thrice
-  // This only works as long as backslashes aren't also overloaded to create
-  // special characters. So Mu doesn't follow C's approach of overloading
-  // backslashes both to escape quote characters and also as a notation for
-  // unprintable characters like '\n'.
-  while (has_data(in)) {
-    char c = in.get();
-    out << c;
-    if (c != '\\') break;
-  }
-}
-
-void test_string_literal_nested() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [abc [def]]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"abc [def]\": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_escaped() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [abc \\[def]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"abc [def\": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_escaped_twice() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [\n"
-      "abc \\\\[def]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"\\nabc \\[def\": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_and_comment() {
-  load(
-      "def main [\n"
-      "  1:address:array:character <- copy [abc]  # comment\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: --- defining main\n"
-      "parse: instruction: copy\n"
-      "parse:   number of ingredients: 1\n"
-      "parse:   ingredient: {\"abc\": \"literal-string\"}\n"
-      "parse:   product: {1: (\"address\" \"array\" \"character\")}\n"
-  );
-}
-
-void test_string_literal_escapes_newlines_in_trace() {
-  load(
-      "def main [\n"
-      "  copy [abc\n"
-      "def]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"abc\\ndef\": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_can_skip_past_comments() {
-  load(
-      "def main [\n"
-      "  copy [\n"
-      "    # ']' inside comment\n"
-      "    bar\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"\\n    # ']' inside comment\\n    bar\\n  \": \"literal-string\"}\n"
-  );
-}
-
-void test_string_literal_empty() {
-  load(
-      "def main [\n"
-      "  copy []\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {\"\": \"literal-string\"}\n"
-  );
-}
-
-void test_multiple_unfinished_recipes() {
-  Hide_errors = true;
-  load(
-      "def f1 [\n"
-      "def f2 [\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: unbalanced '['\n"
-  );
-}
diff --git a/archive/2.vm/015literal_noninteger.cc b/archive/2.vm/015literal_noninteger.cc
deleted file mode 100644
index 12f24586..00000000
--- a/archive/2.vm/015literal_noninteger.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-//: Support literal non-integers.
-
-void test_noninteger_literal() {
-  load(
-      "def main [\n"
-      "  1:number <- copy 3.14159\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {3.14159: \"literal-fractional-number\"}\n"
-  );
-}
-
-:(after "Parsing reagent(string s)")
-if (is_noninteger(s)) {
-  name = s;
-  type = new type_tree("literal-fractional-number", 0);
-  set_value(to_double(s));
-  return;
-}
-
-:(code)
-bool is_noninteger(const string& s) {
-  return s.find_first_not_of("0123456789-.") == string::npos  // no other characters
-      && s.find_first_of("0123456789") != string::npos  // at least one digit
-      && s.find('-', 1) == string::npos  // '-' only at first position
-      && std::count(s.begin(), s.end(), '.') == 1;  // exactly one decimal point
-}
-
-double to_double(string n) {
-  char* end = NULL;
-  // safe because string.c_str() is guaranteed to be null-terminated
-  double result = strtod(n.c_str(), &end);
-  assert(*end == '\0');
-  return result;
-}
-
-void test_is_noninteger() {
-  CHECK(!is_noninteger("1234"));
-  CHECK(!is_noninteger("1a2"));
-  CHECK(is_noninteger("234.0"));
-  CHECK(!is_noninteger("..."));
-  CHECK(!is_noninteger("."));
-  CHECK(is_noninteger("2."));
-  CHECK(is_noninteger(".2"));
-  CHECK(is_noninteger("-.2"));
-  CHECK(is_noninteger("-2."));
-  CHECK(!is_noninteger("--.2"));
-  CHECK(!is_noninteger(".-2"));
-  CHECK(!is_noninteger("..2"));
-}
diff --git a/archive/2.vm/016dilated_reagent.cc b/archive/2.vm/016dilated_reagent.cc
deleted file mode 100644
index 1354ba45..00000000
--- a/archive/2.vm/016dilated_reagent.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-//: An alternative syntax for reagents that permits whitespace in properties,
-//: grouped by brackets. We'll use this ability in the next layer, when we
-//: generalize types from lists to trees of properties.
-
-void test_dilated_reagent() {
-  load(
-      "def main [\n"
-      "  {1: number, foo: bar} <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: \"number\", \"foo\": \"bar\"}\n"
-  );
-}
-
-void test_load_trailing_space_after_curly_bracket() {
-  load(
-      "def main [\n"
-      "  # line below has a space at the end\n"
-      "  { \n"
-      "]\n"
-      "# successfully parsed\n"
-  );
-}
-
-void test_dilated_reagent_with_comment() {
-  load(
-      "def main [\n"
-      "  {1: number, foo: bar} <- copy 34  # test comment\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: \"number\", \"foo\": \"bar\"}\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_dilated_reagent_with_comment_immediately_following() {
-  load(
-      "def main [\n"
-      "  1:number <- copy {34: literal}  # test comment\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: First augment next_word to group balanced brackets together.
-
-:(before "End next_word Special-cases")
-if (in.peek() == '(')
-  return slurp_balanced_bracket(in);
-// treat curlies mostly like parens, but don't mess up labels
-if (start_of_dilated_reagent(in))
-  return slurp_balanced_bracket(in);
-
-:(code)
-// A curly is considered a label if it's the last thing on a line. Dilated
-// reagents should remain all on one line.
-bool start_of_dilated_reagent(istream& in) {
-  if (in.peek() != '{') return false;
-  int pos = in.tellg();
-  in.get();  // slurp '{'
-  skip_whitespace_but_not_newline(in);
-  char next = in.peek();
-  in.seekg(pos);
-  return next != '\n';
-}
-
-// Assume the first letter is an open bracket, and read everything until the
-// matching close bracket.
-// We balance {} () and [].
-string slurp_balanced_bracket(istream& in) {
-  ostringstream result;
-  char c;
-  list<char> open_brackets;
-  while (in >> c) {
-    if (c == '(') open_brackets.push_back(c);
-    if (c == ')') {
-      if (open_brackets.empty() || open_brackets.back() != '(') {
-        raise << "unbalanced ')'\n" << end();
-        continue;
-      }
-      assert(open_brackets.back() == '(');
-      open_brackets.pop_back();
-    }
-    if (c == '[') open_brackets.push_back(c);
-    if (c == ']') {
-      if (open_brackets.empty() || open_brackets.back() != '[') {
-        raise << "unbalanced ']'\n" << end();
-        continue;
-      }
-      open_brackets.pop_back();
-    }
-    if (c == '{') open_brackets.push_back(c);
-    if (c == '}') {
-      if (open_brackets.empty() || open_brackets.back() != '{') {
-        raise << "unbalanced '}'\n" << end();
-        continue;
-      }
-      open_brackets.pop_back();
-    }
-    result << c;
-    if (open_brackets.empty()) break;
-  }
-  skip_whitespace_and_comments_but_not_newline(in);
-  return result.str();
-}
-
-:(after "Parsing reagent(string s)")
-if (starts_with(s, "{")) {
-  assert(properties.empty());
-  istringstream in(s);
-  in >> std::noskipws;
-  in.get();  // skip '{'
-  name = slurp_key(in);
-  if (name.empty()) {
-    raise << "invalid reagent '" << s << "' without a name\n" << end();
-    return;
-  }
-  if (name == "}") {
-    raise << "invalid empty reagent '" << s << "'\n" << end();
-    return;
-  }
-  {
-    string s = next_word(in);
-    if (s.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete dilated reagent at end of file (0)\n" << end();
-      return;
-    }
-    string_tree* type_names = new string_tree(s);
-    // End Parsing Dilated Reagent Type Property(type_names)
-    type = new_type_tree(type_names);
-    delete type_names;
-  }
-  while (has_data(in)) {
-    string key = slurp_key(in);
-    if (key.empty()) continue;
-    if (key == "}") continue;
-    string s = next_word(in);
-    if (s.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete dilated reagent at end of file (1)\n" << end();
-      return;
-    }
-    string_tree* value = new string_tree(s);
-    // End Parsing Dilated Reagent Property(value)
-    properties.push_back(pair<string, string_tree*>(key, value));
-  }
-  return;
-}
-
-:(code)
-string slurp_key(istream& in) {
-  string result = next_word(in);
-  if (result.empty()) {
-    assert(!has_data(in));
-    raise << "incomplete dilated reagent at end of file (2)\n" << end();
-    return result;
-  }
-  while (!result.empty() && *result.rbegin() == ':')
-    strip_last(result);
-  while (isspace(in.peek()) || in.peek() == ':')
-    in.get();
-  return result;
-}
diff --git a/archive/2.vm/017parse_tree.cc b/archive/2.vm/017parse_tree.cc
deleted file mode 100644
index 02170f6d..00000000
--- a/archive/2.vm/017parse_tree.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// So far instructions can only contain linear lists of properties. Now we add
-// support for more complex trees of properties in dilated reagents. This will
-// come in handy later for expressing complex types, like "a dictionary from
-// (address to array of charaters) to (list of numbers)".
-//
-// Type trees aren't as general as s-expressions even if they look like them:
-// the first element of a type tree is always an atom, and it can never be
-// dotted (right->right->right->...->right is always NULL).
-//
-// For now you can't use the simpler 'colon-based' representation inside type
-// trees. Once you start typing parens, keep on typing parens.
-
-void test_dilated_reagent_with_nested_brackets() {
-  load(
-      "def main [\n"
-      "  {1: number, foo: (bar (baz quux))} <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: \"number\", \"foo\": (\"bar\" (\"baz\" \"quux\"))}\n"
-  );
-}
-
-:(before "End Parsing Dilated Reagent Property(value)")
-value = parse_string_tree(value);
-:(before "End Parsing Dilated Reagent Type Property(type_names)")
-type_names = parse_string_tree(type_names);
-
-:(code)
-string_tree* parse_string_tree(string_tree* s) {
-  assert(s->atom);
-  if (!starts_with(s->value, "(")) return s;
-  string_tree* result = parse_string_tree(s->value);
-  delete s;
-  return result;
-}
-
-string_tree* parse_string_tree(const string& s) {
-  istringstream in(s);
-  in >> std::noskipws;
-  return parse_string_tree(in);
-}
-
-string_tree* parse_string_tree(istream& in) {
-  skip_whitespace_but_not_newline(in);
-  if (!has_data(in)) return NULL;
-  if (in.peek() == ')') {
-    in.get();
-    return NULL;
-  }
-  if (in.peek() != '(') {
-    string s = next_word(in);
-    if (s.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete string tree at end of file (0)\n" << end();
-      return NULL;
-    }
-    string_tree* result = new string_tree(s);
-    return result;
-  }
-  in.get();  // skip '('
-  string_tree* result = NULL;
-  string_tree** curr = &result;
-  while (true) {
-    skip_whitespace_but_not_newline(in);
-    assert(has_data(in));
-    if (in.peek() == ')') break;
-    *curr = new string_tree(NULL, NULL);
-    if (in.peek() == '(') {
-      (*curr)->left = parse_string_tree(in);
-    }
-    else {
-      string s = next_word(in);
-      if (s.empty()) {
-        assert(!has_data(in));
-        raise << "incomplete string tree at end of file (1)\n" << end();
-        return NULL;
-      }
-      (*curr)->left = new string_tree(s);
-    }
-    curr = &(*curr)->right;
-  }
-  in.get();  // skip ')'
-  assert(*curr == NULL);
-  return result;
-}
-
-void test_dilated_reagent_with_type_tree() {
-  Hide_errors = true;  // 'map' isn't defined yet
-  load(
-      "def main [\n"
-      "  {1: (foo (address array character) (bar number))} <- copy 34\n"
-      "]\n"
-      "container foo [\n"
-      "]\n"
-      "container bar [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: (\"foo\" (\"address\" \"array\" \"character\") (\"bar\" \"number\"))}\n"
-  );
-}
-
-void test_dilated_empty_tree() {
-  load(
-      "def main [\n"
-      "  {1: number, foo: ()} <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: \"number\", \"foo\": ()}\n"
-  );
-}
-
-void test_dilated_singleton_tree() {
-  load(
-      "def main [\n"
-      "  {1: number, foo: (bar)} <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   product: {1: \"number\", \"foo\": (\"bar\")}\n"
-  );
-}
diff --git a/archive/2.vm/018constant.cc b/archive/2.vm/018constant.cc
deleted file mode 100644
index bbf3a412..00000000
--- a/archive/2.vm/018constant.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-//: A few literal constants.
-
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "literal-boolean", 0);
-
-//: 'true'
-
-:(code)
-void test_true() {
-  load(
-      "def main [\n"
-      "  1:boolean <- copy true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {true: \"literal-boolean\"}\n"
-  );
-}
-
-:(before "End Parsing reagent")
-if (name == "true") {
-  if (type != NULL) {
-    raise << "'true' is a literal and can't take a type\n" << end();
-    return;
-  }
-  type = new type_tree("literal-boolean");
-  set_value(1);
-}
-
-//: 'false'
-
-:(code)
-void test_false() {
-  load(
-      "def main [\n"
-      "  1:boolean <- copy false\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {false: \"literal-boolean\"}\n"
-  );
-}
-
-:(before "End Parsing reagent")
-if (name == "false") {
-  if (type != NULL) {
-    raise << "'false' is a literal and can't take a type\n" << end();
-    return;
-  }
-  type = new type_tree("literal-boolean");
-  set_value(0);
-}
-
-//: 'null'
-
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "literal-address", 0);
-
-:(code)
-void test_null() {
-  load(
-      "def main [\n"
-      "  1:address:number <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse:   ingredient: {null: \"literal-address\"}\n"
-  );
-}
-
-:(before "End Parsing reagent")
-if (name == "null") {
-  if (type != NULL) {
-    raise << "'null' is a literal and can't take a type\n" << end();
-    return;
-  }
-  type = new type_tree("literal-address");
-  set_value(0);
-}
diff --git a/archive/2.vm/019type_abbreviations.cc b/archive/2.vm/019type_abbreviations.cc
deleted file mode 100644
index 35cc5d90..00000000
--- a/archive/2.vm/019type_abbreviations.cc
+++ /dev/null
@@ -1,236 +0,0 @@
-//: For convenience, allow Mu types to be abbreviated.
-
-void test_type_abbreviations() {
-  transform(
-      "type foo = number\n"
-      "def main [\n"
-      "  a:foo <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: product type after expanding abbreviations: \"number\"\n"
-  );
-}
-
-:(before "End Globals")
-map<string, type_tree*> Type_abbreviations, Type_abbreviations_snapshot;
-
-//:: Defining type abbreviations.
-
-:(before "End Command Handlers")
-else if (command == "type") {
-  load_type_abbreviations(in);
-}
-
-:(code)
-void load_type_abbreviations(istream& in) {
-  string new_type_name = next_word(in);
-  assert(has_data(in) || !new_type_name.empty());
-  if (!has_data(in) || new_type_name.empty()) {
-    raise << "incomplete 'type' statement; must be of the form 'type <new type name> = <type expression>'\n" << end();
-    return;
-  }
-  string arrow = next_word(in);
-  assert(has_data(in) || !arrow.empty());
-  if (arrow.empty()) {
-    raise << "incomplete 'type' statement 'type " << new_type_name << "'\n" << end();
-    return;
-  }
-  if (arrow != "=") {
-    raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end();
-    return;
-  }
-  if (!has_data(in)) {
-    raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end();
-    return;
-  }
-  string old = next_word(in);
-  if (old.empty()) {
-    raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end();
-    raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end();
-    return;
-  }
-  if (contains_key(Type_abbreviations, new_type_name)) {
-    raise << "'type' conflict: '" << new_type_name << "' defined as both '" << names_to_string_without_quotes(get(Type_abbreviations, new_type_name)) << "' and '" << old << "'\n" << end();
-    return;
-  }
-  trace(100, "type") << "alias " << new_type_name << " = " << old << end();
-  type_tree* old_type = new_type_tree(old);
-  put(Type_abbreviations, new_type_name, old_type);
-}
-
-type_tree* new_type_tree(const string& x) {
-  string_tree* type_names = starts_with(x, "(") ? parse_string_tree(x) : parse_string_list(x);
-  type_tree* result = new_type_tree(type_names);
-  delete type_names;
-  expand_type_abbreviations(result);
-  return result;
-}
-
-string_tree* parse_string_list(const string& s) {
-  istringstream in(s);
-  in >> std::noskipws;
-  return parse_property_list(in);
-}
-
-void test_type_error1() {
-  Hide_errors = true;
-  transform(
-      "type foo\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: incomplete 'type' statement 'type foo'\n"
-  );
-}
-
-void test_type_error2() {
-  Hide_errors = true;
-  transform(
-      "type foo =\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: incomplete 'type' statement 'type foo ='\n"
-  );
-}
-
-void test_type_error3() {
-  Hide_errors = true;
-  transform(
-      "type foo bar baz\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: 'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type foo bar'\n"
-  );
-}
-
-void test_type_conflict_error() {
-  Hide_errors = true;
-  transform(
-      "type foo = bar\n"
-      "type foo = baz\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: 'type' conflict: 'foo' defined as both 'bar' and 'baz'\n"
-  );
-}
-
-void test_type_abbreviation_for_compound() {
-  transform(
-      "type foo = address:number\n"
-      "def main [\n"
-      "  1:foo <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: product type after expanding abbreviations: (\"address\" \"number\")\n"
-  );
-}
-
-//: cleaning up type abbreviations between tests and before exiting
-
-:(before "End save_snapshots")
-Type_abbreviations_snapshot = Type_abbreviations;
-:(before "End restore_snapshots")
-restore_type_abbreviations();
-:(before "End One-time Setup")
-atexit(clear_type_abbreviations);
-:(code)
-void restore_type_abbreviations() {
-  for (map<string, type_tree*>::iterator p = Type_abbreviations.begin();  p != Type_abbreviations.end();  ++p) {
-    if (!contains_key(Type_abbreviations_snapshot, p->first))
-      delete p->second;
-  }
-  Type_abbreviations.clear();
-  Type_abbreviations = Type_abbreviations_snapshot;
-}
-void clear_type_abbreviations() {
-  for (map<string, type_tree*>::iterator p = Type_abbreviations.begin();  p != Type_abbreviations.end();  ++p)
-    delete p->second;
-  Type_abbreviations.clear();
-}
-
-//:: A few default abbreviations.
-
-:(before "End Mu Types Initialization")
-put(Type_abbreviations, "&", new_type_tree("address"));
-put(Type_abbreviations, "@", new_type_tree("array"));
-put(Type_abbreviations, "num", new_type_tree("number"));
-put(Type_abbreviations, "bool", new_type_tree("boolean"));
-put(Type_abbreviations, "char", new_type_tree("character"));
-
-:(code)
-void test_use_type_abbreviations_when_declaring_type_abbreviations() {
-  transform(
-      "type foo = &:num\n"
-      "def main [\n"
-      "  1:foo <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: product type after expanding abbreviations: (\"address\" \"number\")\n"
-  );
-}
-
-//:: Expand type aliases before running.
-//: We'll do this in a transform so that we don't need to define abbreviations
-//: before we use them.
-
-void test_abbreviations_for_address_and_array() {
-  transform(
-      "def main [\n"
-      "  f 1:&:num\n"  // abbreviation for 'address:number'
-      "  f 2:@:num\n"  // abbreviation for 'array:number'
-      "  f 3:&:@:num\n"  // combining '&' and '@'
-      "  f 4:&:&:@:&:@:num\n"  // ..any number of times
-      "  f {5: (array (& num) 3)}\n"  // support for dilated reagents and more complex parse trees
-      "]\n"
-      "def f [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- expand type abbreviations in recipe 'main'\n"
-      "transform: ingredient type after expanding abbreviations: (\"address\" \"number\")\n"
-      "transform: ingredient type after expanding abbreviations: (\"array\" \"number\")\n"
-      "transform: ingredient type after expanding abbreviations: (\"address\" \"array\" \"number\")\n"
-      "transform: ingredient type after expanding abbreviations: (\"address\" \"address\" \"array\" \"address\" \"array\" \"number\")\n"
-      "transform: ingredient type after expanding abbreviations: (\"array\" (\"address\" \"number\") \"3\")\n"
-  );
-}
-
-:(before "Transform.push_back(update_instruction_operations)")
-Transform.push_back(expand_type_abbreviations);  // idempotent
-// Begin Type Modifying Transforms
-// End Type Modifying Transforms
-
-:(code)
-void expand_type_abbreviations(const recipe_ordinal r) {
-  expand_type_abbreviations(get(Recipe, r));
-}
-
-void expand_type_abbreviations(const recipe& caller) {
-  trace(101, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end();
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    trace(102, "transform") << "instruction '" << to_original_string(inst) << end();
-    for (long int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-      expand_type_abbreviations(inst.ingredients.at(i).type);
-      trace(102, "transform") << "ingredient type after expanding abbreviations: " << names_to_string(inst.ingredients.at(i).type) << end();
-    }
-    for (long int i = 0;  i < SIZE(inst.products);  ++i) {
-      expand_type_abbreviations(inst.products.at(i).type);
-      trace(102, "transform") << "product type after expanding abbreviations: " << names_to_string(inst.products.at(i).type) << end();
-    }
-  }
-  // End Expand Type Abbreviations(caller)
-}
-
-void expand_type_abbreviations(type_tree* type) {
-  if (!type) return;
-  if (!type->atom) {
-    expand_type_abbreviations(type->left);
-    expand_type_abbreviations(type->right);
-    return;
-  }
-  if (contains_key(Type_abbreviations, type->name))
-    *type = type_tree(*get(Type_abbreviations, type->name));
-}
diff --git a/archive/2.vm/020run.cc b/archive/2.vm/020run.cc
deleted file mode 100644
index aa4513e4..00000000
--- a/archive/2.vm/020run.cc
+++ /dev/null
@@ -1,571 +0,0 @@
-//: Phase 3: Start running a loaded and transformed recipe.
-//:
-//:   The process of running Mu code:
-//:     load -> transform -> run
-//:
-//: So far we've seen recipes as lists of instructions, and instructions point
-//: at other recipes. To kick things off Mu needs to know how to run certain
-//: 'primitive' recipes. That will then give the ability to run recipes
-//: containing these primitives.
-//:
-//: This layer defines a skeleton with just two primitive recipes: IDLE which
-//: does nothing, and COPY, which can copy numbers from one memory location to
-//: another. Later layers will add more primitives.
-
-void test_copy_literal() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {1: \"number\"} <- copy {23: \"literal\"}\n"
-      "mem: storing 23 in location 1\n"
-  );
-}
-
-void test_copy() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 23\n"
-      "  2:num <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {2: \"number\"} <- copy {1: \"number\"}\n"
-      "mem: location 1 is 23\n"
-      "mem: storing 23 in location 2\n"
-  );
-}
-
-void test_copy_multiple() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 23, 24\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 23 in location 1\n"
-      "mem: storing 24 in location 2\n"
-  );
-}
-
-:(before "End Types")
-// Book-keeping while running a recipe.
-//: Later layers will replace this to support running multiple routines at once.
-struct routine {
-  recipe_ordinal running_recipe;
-  int running_step_index;
-  routine(recipe_ordinal r) :running_recipe(r), running_step_index(0) {}
-  bool completed() const;
-  const vector<instruction>& steps() const;
-};
-
-:(before "End Globals")
-routine* Current_routine = NULL;
-:(before "End Reset")
-Current_routine = NULL;
-
-:(code)
-void run(const recipe_ordinal r) {
-  routine rr(r);
-  Current_routine = &rr;
-  run_current_routine();
-  Current_routine = NULL;
-}
-
-void run_current_routine() {
-  while (should_continue_running(Current_routine)) {  // beware: may modify Current_routine
-    // Running One Instruction
-    if (current_instruction().is_label) { ++current_step_index();  continue; }
-    trace(Callstack_depth, "run") << to_string(current_instruction()) << end();
-//?     if (Foo) cerr << "run: " << to_string(current_instruction()) << '\n';
-    if (get_or_insert(Memory, 0) != 0) {
-      raise << "something wrote to location 0; this should never happen\n" << end();
-      put(Memory, 0, 0);
-    }
-    // read all ingredients from memory, each potentially spanning multiple locations
-    vector<vector<double> > ingredients;
-    if (should_copy_ingredients()) {
-      for (int i = 0;  i < SIZE(current_instruction().ingredients);  ++i)
-        ingredients.push_back(read_memory(current_instruction().ingredients.at(i)));
-    }
-    // instructions below will write to 'products'
-    vector<vector<double> > products;
-    //: This will be a large switch that later layers will often insert cases
-    //: into. Never call 'continue' within it. Instead, we'll explicitly
-    //: control which of the following stages after the switch we run for each
-    //: instruction.
-    bool write_products = true;
-    bool fall_through_to_next_instruction = true;
-    switch (current_instruction().operation) {
-      // Primitive Recipe Implementations
-      case COPY: {
-        copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin()));
-        break;
-      }
-      // End Primitive Recipe Implementations
-      default: {
-        raise << "not a primitive op: " << current_instruction().operation << '\n' << end();
-      }
-    }
-    //: used by a later layer
-    if (write_products) {
-      if (SIZE(products) < SIZE(current_instruction().products)) {
-        raise << SIZE(products) << " vs " << SIZE(current_instruction().products) << ": failed to write to all products in '" << to_original_string(current_instruction()) << "'\n" << end();
-      }
-      else {
-        for (int i = 0;  i < SIZE(current_instruction().products);  ++i) {
-          // Writing Instruction Product(i)
-          write_memory(current_instruction().products.at(i), products.at(i));
-        }
-      }
-    }
-    // End Running One Instruction
-    if (fall_through_to_next_instruction)
-      ++current_step_index();
-  }
-  stop_running_current_routine:;
-}
-
-//: Helpers for managing trace depths
-//:
-//: We're going to use trace depths primarily to segment code running at
-//: different frames of the call stack. This will make it easy for the trace
-//: browser to collapse over entire calls.
-//:
-//: The entire map of possible depths is as follows:
-//:
-//: Errors will be depth 0.
-//: Mu 'applications' will be able to use depths 1-99 as they like.
-//: Primitive statements will occupy 100 and up to Max_depth, organized by
-//: stack frames.
-:(before "End Globals")
-extern const int Initial_callstack_depth = 100;
-int Callstack_depth = Initial_callstack_depth;
-:(before "End Reset")
-Callstack_depth = Initial_callstack_depth;
-
-//: Other helpers for the VM.
-
-:(code)
-//: hook replaced in a later layer
-bool should_continue_running(const routine* current_routine) {
-  assert(current_routine == Current_routine);  // argument passed in just to make caller readable above
-  return !Current_routine->completed();
-}
-
-bool should_copy_ingredients() {
-  // End should_copy_ingredients Special-cases
-  return true;
-}
-
-bool is_mu_scalar(reagent/*copy*/ r) {
-  return is_mu_scalar(r.type);
-}
-bool is_mu_scalar(const type_tree* type) {
-  if (!type) return false;
-  if (is_mu_address(type)) return false;
-  if (!type->atom) return false;
-  if (is_literal(type))
-    return type->name != "literal-string";
-  return size_of(type) == 1;
-}
-
-bool is_mu_address(reagent/*copy*/ r) {
-  // End Preprocess is_mu_address(reagent r)
-  return is_mu_address(r.type);
-}
-bool is_mu_address(const type_tree* type) {
-  if (!type) return false;
-  if (is_literal(type)) return false;
-  if (type->atom) return false;
-  if (!type->left->atom) {
-    raise << "invalid type " << to_string(type) << '\n' << end();
-    return false;
-  }
-  return type->left->value == Address_type_ordinal;
-}
-
-//: Some helpers.
-//: Important that they return references into the current routine.
-
-//: hook replaced in a later layer
-int& current_step_index() {
-  return Current_routine->running_step_index;
-}
-
-//: hook replaced in a later layer
-recipe_ordinal currently_running_recipe() {
-  return Current_routine->running_recipe;
-}
-
-//: hook replaced in a later layer
-const string& current_recipe_name() {
-  return get(Recipe, Current_routine->running_recipe).name;
-}
-
-//: hook replaced in a later layer
-const recipe& current_recipe() {
-  return get(Recipe, Current_routine->running_recipe);
-}
-
-//: hook replaced in a later layer
-const instruction& current_instruction() {
-  return get(Recipe, Current_routine->running_recipe).steps.at(Current_routine->running_step_index);
-}
-
-//: hook replaced in a later layer
-bool routine::completed() const {
-  return running_step_index >= SIZE(get(Recipe, running_recipe).steps);
-}
-
-//: hook replaced in a later layer
-const vector<instruction>& routine::steps() const {
-  return get(Recipe, running_recipe).steps;
-}
-
-//:: Startup flow
-
-:(before "End Mu Prelude")
-load_file_or_directory("core.mu");
-//? DUMP("");
-//? exit(0);
-
-//: Step 2: load any .mu files provided at the commandline
-:(before "End Commandline Parsing")
-// Check For .mu Files
-if (argc > 1) {
-  // skip argv[0]
-  ++argv;
-  --argc;
-  while (argc > 0) {
-    // ignore argv past '--'; that's commandline args for 'main'
-    if (string(*argv) == "--") break;
-    if (starts_with(*argv, "--"))
-      cerr << "treating " << *argv << " as a file rather than an option\n";
-    load_file_or_directory(*argv);
-    --argc;
-    ++argv;
-  }
-  if (Run_tests) Recipe.erase(get(Recipe_ordinal, "main"));
-}
-transform_all();
-//? cerr << to_original_string(get(Type_ordinal, "editor")) << '\n';
-//? cerr << to_original_string(get(Recipe, get(Recipe_ordinal, "event-loop"))) << '\n';
-//? DUMP("");
-//? exit(0);
-if (trace_contains_errors()) return 1;
-if (Trace_stream && Run_tests) {
-  // We'll want a trace per test. Clear the trace.
-  delete Trace_stream;
-  Trace_stream = NULL;
-}
-save_snapshots();
-
-//: Step 3: if we aren't running tests, locate a recipe called 'main' and
-//: start running it.
-:(before "End Main")
-if (!Run_tests && contains_key(Recipe_ordinal, "main") && contains_key(Recipe, get(Recipe_ordinal, "main"))) {
-  // Running Main
-  reset();
-  trace(2, "run") << "=== Starting to run" << end();
-  assert(Num_calls_to_transform_all == 1);
-  run_main(argc, argv);
-}
-
-:(code)
-void run_main(int argc, char* argv[]) {
-  recipe_ordinal r = get(Recipe_ordinal, "main");
-  if (r) run(r);
-}
-
-void load_file_or_directory(string filename) {
-  if (is_directory(filename)) {
-    load_all(filename);
-    return;
-  }
-  ifstream fin(filename.c_str());
-  if (!fin) {
-    cerr << "no such file '" << filename << "'\n" << end();  // don't raise, just warn. just in case it's just a name for a test to run.
-    return;
-  }
-  trace(2, "load") << "=== " << filename << end();
-  load(fin);
-  fin.close();
-}
-
-bool is_directory(string path) {
-  struct stat info;
-  if (stat(path.c_str(), &info)) return false;  // error
-  return info.st_mode & S_IFDIR;
-}
-
-void load_all(string dir) {
-  dirent** files;
-  int num_files = scandir(dir.c_str(), &files, NULL, alphasort);
-  for (int i = 0;  i < num_files;  ++i) {
-    string curr_file = files[i]->d_name;
-    if (isdigit(curr_file.at(0)) && ends_with(curr_file, ".mu"))
-      load_file_or_directory(dir+'/'+curr_file);
-    free(files[i]);
-    files[i] = NULL;
-  }
-  free(files);
-}
-
-bool ends_with(const string& s, const string& pat) {
-  for (string::const_reverse_iterator p = s.rbegin(), q = pat.rbegin();  q != pat.rend();  ++p, ++q) {
-    if (p == s.rend()) return false;  // pat too long
-    if (*p != *q) return false;
-  }
-  return true;
-}
-
-:(before "End Includes")
-#include <dirent.h>
-#include <sys/stat.h>
-
-//:: Reading from memory, writing to memory.
-
-:(code)
-vector<double> read_memory(reagent/*copy*/ x) {
-  // Begin Preprocess read_memory(x)
-  vector<double> result;
-  if (x.name == "null") result.push_back(/*alloc id*/0);
-  if (is_literal(x)) {
-    result.push_back(x.value);
-    return result;
-  }
-  // End Preprocess read_memory(x)
-  int size = size_of(x);
-  for (int offset = 0;  offset < size;  ++offset) {
-    double val = get_or_insert(Memory, x.value+offset);
-    trace(Callstack_depth+1, "mem") << "location " << x.value+offset << " is " << no_scientific(val) << end();
-    result.push_back(val);
-  }
-  return result;
-}
-
-void write_memory(reagent/*copy*/ x, const vector<double>& data) {
-  assert(Current_routine);  // run-time only
-  // Begin Preprocess write_memory(x, data)
-  if (!x.type) {
-    raise << "can't write to '" << to_string(x) << "'; no type\n" << end();
-    return;
-  }
-  if (is_dummy(x)) return;
-  if (is_literal(x)) return;
-  // End Preprocess write_memory(x, data)
-  if (x.value == 0) {
-    raise << "can't write to location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    return;
-  }
-  if (size_mismatch(x, data)) {
-    raise << maybe(current_recipe_name()) << "size mismatch in storing to '" << x.original_string << "' (" << size_of(x) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end();
-    return;
-  }
-  // End write_memory(x) Special-cases
-  for (int offset = 0;  offset < SIZE(data);  ++offset) {
-    assert(x.value+offset > 0);
-    trace(Callstack_depth+1, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end();
-//?     if (Foo) cerr << "mem: storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << '\n';
-    put(Memory, x.value+offset, data.at(offset));
-  }
-}
-
-:(code)
-int size_of(const reagent& r) {
-  if (!r.type) return 0;
-  // End size_of(reagent r) Special-cases
-  return size_of(r.type);
-}
-int size_of(const type_tree* type) {
-  if (!type) return 0;
-  if (type->atom) {
-    if (type->value == -1) return 1;  // error value, but we'll raise it elsewhere
-    if (type->value == 0) return 1;
-    // End size_of(type) Atom Special-cases
-  }
-  else {
-    if (!type->left->atom) {
-      raise << "invalid type " << to_string(type) << '\n' << end();
-      return 0;
-    }
-    if (type->left->value == Address_type_ordinal) return 2;  // address and alloc id
-    // End size_of(type) Non-atom Special-cases
-  }
-  // End size_of(type) Special-cases
-  return 1;
-}
-
-bool size_mismatch(const reagent& x, const vector<double>& data) {
-  if (!x.type) return true;
-  // End size_mismatch(x) Special-cases
-//?   if (size_of(x) != SIZE(data)) cerr << size_of(x) << " vs " << SIZE(data) << '\n';
-  return size_of(x) != SIZE(data);
-}
-
-bool is_literal(const reagent& r) {
-  return is_literal(r.type);
-}
-bool is_literal(const type_tree* type) {
-  if (!type) return false;
-  if (!type->atom) return false;
-  return type->value == 0;
-}
-
-bool scalar(const vector<int>& x) {
-  return SIZE(x) == 1;
-}
-bool scalar(const vector<double>& x) {
-  return SIZE(x) == 1;
-}
-
-// helper for tests
-void run(const string& form) {
-  vector<recipe_ordinal> tmp = load(form);
-  transform_all();
-  if (tmp.empty()) return;
-  if (trace_contains_errors()) return;
-  // if a test defines main, it probably wants to start there regardless of
-  // definition order
-  if (contains_key(Recipe, get(Recipe_ordinal, "main")))
-    run(get(Recipe_ordinal, "main"));
-  else
-    run(tmp.front());
-}
-
-void test_run_label() {
-  run(
-      "def main [\n"
-      "  +foo\n"
-      "  1:num <- copy 23\n"
-      "  2:num <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {1: \"number\"} <- copy {23: \"literal\"}\n"
-      "run: {2: \"number\"} <- copy {1: \"number\"}\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: +foo");
-}
-
-void test_run_dummy() {
-  run(
-      "def main [\n"
-      "  _ <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: _ <- copy {0: \"literal\"}\n"
-  );
-}
-
-void test_run_null() {
-  run(
-      "def main [\n"
-      "  1:&:num <- copy null\n"
-      "]\n"
-  );
-}
-
-void test_write_to_0_disallowed() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  0:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 34 in location 0");
-}
-
-//: Mu is robust to various combinations of commas and spaces. You just have
-//: to put spaces around the '<-'.
-
-void test_comma_without_space() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 2,2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-void test_space_without_comma() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 2 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-void test_comma_before_space() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 2, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-void test_comma_after_space() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 2 ,2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-//:: Counters for trying to understand where Mu programs are spending their
-//:: time.
-
-:(before "End Globals")
-bool Run_profiler = false;
-// We'll key profile information by recipe_ordinal rather than name because
-// it's more efficient, and because later layers will show more than just the
-// name of a recipe.
-//
-// One drawback: if you're clearing recipes your profile will be inaccurate.
-// So far that happens in tests, and in 'run-sandboxed' in a later layer.
-map<recipe_ordinal, int> Instructions_running;
-:(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--profile")) {
-  Run_profiler = true;
-}
-:(after "Running One Instruction")
-if (Run_profiler) Instructions_running[currently_running_recipe()]++;
-:(before "End One-time Setup")
-atexit(dump_profile);
-:(code)
-void dump_profile() {
-  if (!Run_profiler) return;
-  if (Run_tests) {
-    cerr << "It's not a good idea to profile a run with tests, since tests can create conflicting recipes and mislead you. To try it anyway, comment out this check in the code.\n";
-    return;
-  }
-  ofstream fout;
-  fout.open("profile.instructions");
-  if (fout) {
-    for (map<recipe_ordinal, int>::iterator p = Instructions_running.begin();  p != Instructions_running.end();  ++p) {
-      fout << std::setw(9) << p->second << ' ' << header_label(p->first) << '\n';
-    }
-  }
-  fout.close();
-  // End dump_profile
-}
-
-// overridden in a later layer
-string header_label(const recipe_ordinal r) {
-  return get(Recipe, r).name;
-}
diff --git a/archive/2.vm/021check_instruction.cc b/archive/2.vm/021check_instruction.cc
deleted file mode 100644
index 5a8e1324..00000000
--- a/archive/2.vm/021check_instruction.cc
+++ /dev/null
@@ -1,260 +0,0 @@
-//: Introduce a new transform to perform various checks in instructions before
-//: we start running them. It'll be extensible, so that we can add checks for
-//: new recipes as we extend 'run' to support them.
-//:
-//: Doing checking in a separate part complicates things, because the values
-//: of variables in memory and the processor (current_recipe_name,
-//: current_instruction) aren't available at checking time. If I had a more
-//: sophisticated layer system I'd introduce the simpler version first and
-//: transform it in a separate layer or set of layers.
-
-:(before "End Checks")
-Transform.push_back(check_instruction);  // idempotent
-
-:(code)
-void check_instruction(const recipe_ordinal r) {
-  trace(101, "transform") << "--- perform checks for recipe " << get(Recipe, r).name << end();
-  map<string, vector<type_ordinal> > metadata;
-  for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
-    instruction& inst = get(Recipe, r).steps.at(i);
-    if (inst.is_label) continue;
-    switch (inst.operation) {
-      // Primitive Recipe Checks
-      case COPY: {
-        if (SIZE(inst.products) > SIZE(inst.ingredients)) {
-          raise << maybe(get(Recipe, r).name) << "too many products in '" << to_original_string(inst) << "'\n" << end();
-          break;
-        }
-        for (int i = 0;  i < SIZE(inst.products);  ++i) {
-          if (!types_coercible(inst.products.at(i), inst.ingredients.at(i))) {
-            raise << maybe(get(Recipe, r).name) << "can't copy '" << inst.ingredients.at(i).original_string << "' to '" << inst.products.at(i).original_string << "'; types don't match\n" << end();
-            goto finish_checking_instruction;
-          }
-        }
-        break;
-      }
-      // End Primitive Recipe Checks
-      default: {
-        // Defined Recipe Checks
-        // End Defined Recipe Checks
-      }
-    }
-    finish_checking_instruction:;
-  }
-}
-
-void test_copy_checks_reagent_count() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too many products in '1:num, 2:num <- copy 34'\n"
-  );
-}
-
-void test_write_scalar_to_array_disallowed() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '34' to '1:array:num'; types don't match\n"
-  );
-}
-
-void test_write_scalar_to_array_disallowed_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num, 2:array:num <- copy 34, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '35' to '2:array:num'; types don't match\n"
-  );
-}
-
-void test_write_scalar_to_address_disallowed() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '34' to '1:&:num'; types don't match\n"
-  );
-}
-
-void test_write_address_to_character_disallowed() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- copy 12/unsafe\n"
-      "  2:char <- copy 1:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '1:&:num' to '2:char'; types don't match\n"
-  );
-}
-
-void test_write_number_to_character_allowed() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 97\n"
-      "  2:char <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(code)
-// types_match with some leniency
-bool types_coercible(reagent/*copy*/ to, reagent/*copy*/ from) {
-  // Begin types_coercible(reagent to, reagent from)
-  if (types_match_sub(to, from)) return true;
-  if (is_real_mu_number(from) && is_mu_character(to)) return true;
-  // End types_coercible Special-cases
-  return false;
-}
-
-bool types_match_sub(const reagent& to, const reagent& from) {
-  // to sidestep type-checking, use /unsafe in the source.
-  // this will be highlighted in red inside vim. just for setting up some tests.
-  if (is_unsafe(from)) return true;
-  if (is_literal(from)) {
-    if (is_mu_array(to)) return false;
-    // End Matching Types For Literal(to)
-    if (!to.type) return false;
-    // allow writing null to any address
-    if (is_mu_address(to)) return from.name == "null";
-    return size_of(to) == 1;  // literals are always scalars
-  }
-  return types_strictly_match_sub(to, from);
-}
-// variant for others to call
-bool types_match(reagent/*copy*/ to, reagent/*copy*/ from) {
-  // Begin types_match(reagent to, reagent from)
-  return types_match_sub(to, from);
-}
-
-//: copy arguments for later layers
-bool types_strictly_match_sub(const reagent& to, const reagent& from) {
-  if (to.type == NULL) return false;  // error
-  if (is_literal(from) && to.type->value == Number_type_ordinal) return true;
-  // to sidestep type-checking, use /unsafe in the source.
-  // this will be highlighted in red inside vim. just for setting up some tests.
-  if (is_unsafe(from)) return true;
-  // '_' never raises type error
-  if (is_dummy(to)) return true;
-  if (!to.type) return !from.type;
-  return types_strictly_match(to.type, from.type);
-}
-// variant for others to call
-bool types_strictly_match(reagent/*copy*/ to, reagent/*copy*/ from) {
-  // Begin types_strictly_match(reagent to, reagent from)
-  return types_strictly_match_sub(to, from);
-}
-
-bool types_strictly_match(const type_tree* to, const type_tree* from) {
-  if (from == to) return true;
-  if (!to) return false;
-  if (!from) return to->atom && to->value == 0;
-  if (from->atom != to->atom) return false;
-  if (from->atom) {
-    if (from->value == -1) return from->name == to->name;
-    return from->value == to->value;
-  }
-  if (types_strictly_match(to->left, from->left) && types_strictly_match(to->right, from->right))
-    return true;
-  // fallback: (x) == x
-  if (to->right == NULL && types_strictly_match(to->left, from)) return true;
-  if (from->right == NULL && types_strictly_match(to, from->left)) return true;
-  return false;
-}
-
-void test_unknown_type_does_not_match_unknown_type() {
-  reagent a("a:foo");
-  reagent b("b:bar");
-  CHECK(!types_strictly_match(a, b));
-}
-
-void test_unknown_type_matches_itself() {
-  reagent a("a:foo");
-  reagent b("b:foo");
-  CHECK(types_strictly_match(a, b));
-}
-
-void test_type_abbreviations_match_raw_types() {
-  put(Type_abbreviations, "text", new_type_tree("address:array:character"));
-  // a has type (address buffer (address array character))
-  reagent a("a:address:buffer:text");
-  expand_type_abbreviations(a.type);
-  // b has type (address buffer address array character)
-  reagent b("b:address:buffer:address:array:character");
-  CHECK(types_strictly_match(a, b));
-  delete Type_abbreviations["text"];
-  put(Type_abbreviations, "text", NULL);
-}
-
-//: helpers
-
-bool is_unsafe(const reagent& r) {
-  return has_property(r, "unsafe");
-}
-
-bool is_mu_array(reagent/*copy*/ r) {
-  // End Preprocess is_mu_array(reagent r)
-  return is_mu_array(r.type);
-}
-bool is_mu_array(const type_tree* type) {
-  if (!type) return false;
-  if (is_literal(type)) return false;
-  if (type->atom) return false;
-  if (!type->left->atom) {
-    raise << "invalid type " << to_string(type) << '\n' << end();
-    return false;
-  }
-  return type->left->value == Array_type_ordinal;
-}
-
-bool is_mu_boolean(reagent/*copy*/ r) {
-  // End Preprocess is_mu_boolean(reagent r)
-  if (!r.type) return false;
-  if (is_literal(r)) return false;
-  if (!r.type->atom) return false;
-  return r.type->value == Boolean_type_ordinal;
-}
-
-bool is_mu_number(reagent/*copy*/ r) {
-  if (is_mu_character(r.type)) return true;  // permit arithmetic on unicode code points
-  return is_real_mu_number(r);
-}
-
-bool is_real_mu_number(reagent/*copy*/ r) {
-  // End Preprocess is_mu_number(reagent r)
-  if (!r.type) return false;
-  if (!r.type->atom) return false;
-  if (is_literal(r)) {
-    return r.type->name == "literal-fractional-number"
-        || r.type->name == "literal";
-  }
-  return r.type->value == Number_type_ordinal;
-}
-
-bool is_mu_character(reagent/*copy*/ r) {
-  // End Preprocess is_mu_character(reagent r)
-  return is_mu_character(r.type);
-}
-bool is_mu_character(const type_tree* type) {
-  if (!type) return false;
-  if (!type->atom) return false;
-  if (is_literal(type)) return false;
-  return type->value == Character_type_ordinal;
-}
diff --git a/archive/2.vm/022arithmetic.cc b/archive/2.vm/022arithmetic.cc
deleted file mode 100644
index 05e79e3b..00000000
--- a/archive/2.vm/022arithmetic.cc
+++ /dev/null
@@ -1,1071 +0,0 @@
-//: Arithmetic primitives
-
-:(before "End Primitive Recipe Declarations")
-ADD,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "add", ADD);
-:(before "End Primitive Recipe Checks")
-case ADD: {
-  // primary goal of these checks is to forbid address arithmetic
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'add' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'add' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'add' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ADD: {
-  double result = 0;
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    result += ingredients.at(i).at(0);
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_add_literal() {
-  run(
-      "def main [\n"
-      "  1:num <- add 23, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 57 in location 1\n"
-  );
-}
-
-void test_add() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 23\n"
-      "  2:num <- copy 34\n"
-      "  3:num <- add 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 57 in location 3\n"
-  );
-}
-
-void test_add_multiple() {
-  run(
-      "def main [\n"
-      "  1:num <- add 3, 4, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-  );
-}
-
-void test_add_checks_type() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- add 2:bool, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'add' requires number ingredients, but got '2:bool'\n"
-  );
-}
-
-void test_add_checks_return_type() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- add 2, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'add' should yield a number, but got '1:&:num'\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-SUBTRACT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "subtract", SUBTRACT);
-:(before "End Primitive Recipe Checks")
-case SUBTRACT: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'subtract' has no ingredients\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'subtract' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'subtract' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'subtract' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SUBTRACT: {
-  double result = ingredients.at(0).at(0);
-  for (int i = 1;  i < SIZE(ingredients);  ++i)
-    result -= ingredients.at(i).at(0);
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_subtract_literal() {
-  run(
-      "def main [\n"
-      "  1:num <- subtract 5, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 1\n"
-  );
-}
-
-void test_subtract() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 23\n"
-      "  2:num <- copy 34\n"
-      "  3:num <- subtract 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -11 in location 3\n"
-  );
-}
-
-void test_subtract_multiple() {
-  run(
-      "def main [\n"
-      "  1:num <- subtract 6, 3, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-MULTIPLY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "multiply", MULTIPLY);
-:(before "End Primitive Recipe Checks")
-case MULTIPLY: {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'multiply' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'multiply' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'multiply' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MULTIPLY: {
-  double result = 1;
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    result *= ingredients.at(i).at(0);
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_multiply_literal() {
-  run(
-      "def main [\n"
-      "  1:num <- multiply 2, 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 6 in location 1\n"
-  );
-}
-
-void test_multiply() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 4\n"
-      "  2:num <- copy 6\n"
-      "  3:num <- multiply 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 24 in location 3\n"
-  );
-}
-
-void test_multiply_multiple() {
-  run(
-      "def main [\n"
-      "  1:num <- multiply 2, 3, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 24 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-DIVIDE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "divide", DIVIDE);
-:(before "End Primitive Recipe Checks")
-case DIVIDE: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'divide' has no ingredients\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'divide' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'divide' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'divide' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case DIVIDE: {
-  double result = ingredients.at(0).at(0);
-  for (int i = 1;  i < SIZE(ingredients);  ++i)
-    result /= ingredients.at(i).at(0);
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_divide_literal() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 8, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-void test_divide() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 27\n"
-      "  2:num <- copy 3\n"
-      "  3:num <- divide 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 9 in location 3\n"
-  );
-}
-
-void test_divide_multiple() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 12, 3, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-//: Integer division
-
-:(before "End Primitive Recipe Declarations")
-DIVIDE_WITH_REMAINDER,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "divide-with-remainder", DIVIDE_WITH_REMAINDER);
-:(before "End Primitive Recipe Checks")
-case DIVIDE_WITH_REMAINDER: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 2) {
-    raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' yields two products in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (!is_dummy(inst.products.at(i)) && !is_mu_number(inst.products.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' should yield a number, but got '" << inst.products.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case DIVIDE_WITH_REMAINDER: {
-  products.resize(2);
-  // fractions will be dropped; very large numbers will overflow
-  long long int a = static_cast<long long int>(ingredients.at(0).at(0));
-  long long int b = static_cast<long long int>(ingredients.at(1).at(0));
-  if (b == 0) {
-    raise << maybe(current_recipe_name()) << "divide by zero in '" << to_original_string(current_instruction()) << "'\n" << end();
-    products.resize(2);
-    products.at(0).push_back(0);
-    products.at(1).push_back(0);
-    break;
-  }
-  long long int quotient = a / b;
-  long long int remainder = a % b;
-  products.at(0).push_back(static_cast<double>(quotient));
-  products.at(1).push_back(static_cast<double>(remainder));
-  break;
-}
-
-:(code)
-void test_divide_with_remainder_literal() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- divide-with-remainder 9, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-      "mem: storing 1 in location 2\n"
-  );
-}
-
-void test_divide_with_remainder() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 27\n"
-      "  2:num <- copy 11\n"
-      "  3:num, 4:num <- divide-with-remainder 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 3\n"
-      "mem: storing 5 in location 4\n"
-  );
-}
-
-void test_divide_with_decimal_point() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 5, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2.5 in location 1\n"
-  );
-}
-
-void test_divide_by_zero() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 4, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing inf in location 1\n"
-  );
-}
-
-void test_divide_by_zero_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- divide-with-remainder 4, 0\n"
-      "]\n"
-  );
-  // integer division can't return floating-point infinity
-  CHECK_TRACE_CONTENTS(
-      "error: main: divide by zero in '1:num <- divide-with-remainder 4, 0'\n"
-  );
-}
-
-//: Bitwise shifts
-
-:(before "End Primitive Recipe Declarations")
-SHIFT_LEFT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "shift-left", SHIFT_LEFT);
-:(before "End Primitive Recipe Checks")
-case SHIFT_LEFT: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'shift-left' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'shift-left' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'shift-left' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'shift-left' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SHIFT_LEFT: {
-  // ingredients must be integers
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  int b = static_cast<int>(ingredients.at(1).at(0));
-  products.resize(1);
-  if (b < 0) {
-    raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end();
-    products.at(0).push_back(0);
-    break;
-  }
-  products.at(0).push_back(a<<b);
-  break;
-}
-
-:(code)
-void test_shift_left_by_zero() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-left 1, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_shift_left_1() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-left 1, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 16 in location 1\n"
-  );
-}
-
-void test_shift_left_2() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-left 3, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-  );
-}
-
-void test_shift_left_by_negative() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- shift-left 3, -1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: second ingredient can't be negative in '1:num <- shift-left 3, -1'\n"
-  );
-}
-
-void test_shift_left_ignores_fractional_part() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 3, 2\n"
-      "  2:num <- shift-left 1:num, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-SHIFT_RIGHT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "shift-right", SHIFT_RIGHT);
-:(before "End Primitive Recipe Checks")
-case SHIFT_RIGHT: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'shift-right' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'shift-right' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'shift-right' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'shift-right' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SHIFT_RIGHT: {
-  // ingredients must be integers
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  int b = static_cast<int>(ingredients.at(1).at(0));
-  products.resize(1);
-  if (b < 0) {
-    raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end();
-    products.at(0).push_back(0);
-    break;
-  }
-  products.at(0).push_back(a>>b);
-  break;
-}
-
-:(code)
-void test_shift_right_by_zero() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-right 1, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_shift_right_1() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-right 1024, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 512 in location 1\n"
-  );
-}
-
-void test_shift_right_2() {
-  run(
-      "def main [\n"
-      "  1:num <- shift-right 3, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_shift_right_by_negative() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- shift-right 4, -1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: second ingredient can't be negative in '1:num <- shift-right 4, -1'\n"
-  );
-}
-
-void test_shift_right_ignores_fractional_part() {
-  run(
-      "def main [\n"
-      "  1:num <- divide 3, 2\n"
-      "  2:num <- shift-right 1:num, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-AND_BITS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "and-bits", AND_BITS);
-:(before "End Primitive Recipe Checks")
-case AND_BITS: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'and-bits' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'and-bits' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'and-bits' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'and-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case AND_BITS: {
-  // ingredients must be integers
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  int b = static_cast<int>(ingredients.at(1).at(0));
-  products.resize(1);
-  products.at(0).push_back(a&b);
-  break;
-}
-
-:(code)
-void test_and_bits_1() {
-  run(
-      "def main [\n"
-      "  1:num <- and-bits 8, 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-void test_and_bits_2() {
-  run(
-      "def main [\n"
-      "  1:num <- and-bits 3, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-void test_and_bits_3() {
-  run(
-      "def main [\n"
-      "  1:num <- and-bits 14, 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-void test_and_bits_negative() {
-  run(
-      "def main [\n"
-      "  1:num <- and-bits -3, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-OR_BITS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "or-bits", OR_BITS);
-:(before "End Primitive Recipe Checks")
-case OR_BITS: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'or-bits' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'or-bits' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'or-bits' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'or-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case OR_BITS: {
-  // ingredients must be integers
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  int b = static_cast<int>(ingredients.at(1).at(0));
-  products.resize(1);
-  products.at(0).push_back(a|b);
-  break;
-}
-
-:(code)
-void test_or_bits_1() {
-  run(
-      "def main [\n"
-      "  1:num <- or-bits 3, 8\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 11 in location 1\n"
-  );
-}
-
-void test_or_bits_2() {
-  run(
-      "def main [\n"
-      "  1:num <- or-bits 3, 10\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 11 in location 1\n"
-  );
-}
-
-void test_or_bits_3() {
-  run(
-      "def main [\n"
-      "  1:num <- or-bits 4, 6\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 6 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-XOR_BITS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "xor-bits", XOR_BITS);
-:(before "End Primitive Recipe Checks")
-case XOR_BITS: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'xor-bits' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'xor-bits' requires number ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'xor-bits' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'xor-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case XOR_BITS: {
-  // ingredients must be integers
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  int b = static_cast<int>(ingredients.at(1).at(0));
-  products.resize(1);
-  products.at(0).push_back(a^b);
-  break;
-}
-
-:(code)
-void test_xor_bits_1() {
-  run(
-      "def main [\n"
-      "  1:num <- xor-bits 3, 8\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 11 in location 1\n"
-  );
-}
-
-void test_xor_bits_2() {
-  run(
-      "def main [\n"
-      "  1:num <- xor-bits 3, 10\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 9 in location 1\n"
-  );
-}
-
-void test_xor_bits_3() {
-  run(
-      "def main [\n"
-      "  1:num <- xor-bits 4, 6\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-FLIP_BITS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "flip-bits", FLIP_BITS);
-:(before "End Primitive Recipe Checks")
-case FLIP_BITS: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'flip-bits' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'flip-bits' requires a number ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'flip-bits' yields one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'flip-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case FLIP_BITS: {
-  // ingredient must be integer
-  int a = static_cast<int>(ingredients.at(0).at(0));
-  products.resize(1);
-  products.at(0).push_back(~a);
-  break;
-}
-
-:(code)
-void test_flip_bits_zero() {
-  run(
-      "def main [\n"
-      "  1:num <- flip-bits 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -1 in location 1\n"
-  );
-}
-
-void test_flip_bits_negative() {
-  run(
-      "def main [\n"
-      "  1:num <- flip-bits -1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-void test_flip_bits_1() {
-  run(
-      "def main [\n"
-      "  1:num <- flip-bits 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -4 in location 1\n"
-  );
-}
-
-void test_flip_bits_2() {
-  run(
-      "def main [\n"
-      "  1:num <- flip-bits 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -13 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-ROUND,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "round", ROUND);
-:(before "End Primitive Recipe Checks")
-case ROUND: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'round' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'round' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ROUND: {
-  products.resize(1);
-  products.at(0).push_back(rint(ingredients.at(0).at(0)));
-  break;
-}
-
-:(code)
-void test_round_to_nearest_integer() {
-  run(
-      "def main [\n"
-      "  1:num <- round 12.2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-  );
-}
-
-void test_round_halves_toward_zero() {
-  run(
-      "def main [\n"
-      "  1:num <- round 12.5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-  );
-}
-
-void test_round_halves_toward_zero_2() {
-  run(
-      "def main [\n"
-      "  1:num <- round -12.5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -12 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-TRUNCATE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "truncate", TRUNCATE);
-:(before "End Primitive Recipe Checks")
-case TRUNCATE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'truncate' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'truncate' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TRUNCATE: {
-  products.resize(1);
-  products.at(0).push_back(trunc(ingredients.at(0).at(0)));
-  break;
-}
-
-:(code)
-void test_truncate_to_nearest_integer() {
-  run(
-      "def main [\n"
-      "  1:num <- truncate 12.2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-  );
-}
-
-void test_truncate_negative() {
-  run(
-      "def main [\n"
-      "  1:num <- truncate -12.2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing -12 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-SQUARE_ROOT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "square-root", SQUARE_ROOT);
-:(before "End Primitive Recipe Checks")
-case SQUARE_ROOT: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'square-root' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'square-root' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SQUARE_ROOT: {
-  products.resize(1);
-  products.at(0).push_back(sqrt(ingredients.at(0).at(0)));
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CHARACTER_TO_CODE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "character-to-code", CHARACTER_TO_CODE);
-:(before "End Primitive Recipe Checks")
-case CHARACTER_TO_CODE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_character(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'character-to-code' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of 'character-to-code' should be a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CHARACTER_TO_CODE: {
-  double result = 0;
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    result += ingredients.at(i).at(0);
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(before "End Includes")
-#include <math.h>
diff --git a/archive/2.vm/023boolean.cc b/archive/2.vm/023boolean.cc
deleted file mode 100644
index c6c5cac7..00000000
--- a/archive/2.vm/023boolean.cc
+++ /dev/null
@@ -1,224 +0,0 @@
-//: Boolean primitives
-
-:(before "End Primitive Recipe Declarations")
-AND,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "and", AND);
-:(before "End Primitive Recipe Checks")
-case AND: {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_scalar(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'and' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'and' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case AND: {
-  bool result = true;
-  for (int i = 0;  i < SIZE(ingredients);  ++i)
-    result = result && scalar_ingredient(ingredients, i);
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-:(code)
-double scalar_ingredient(const vector<vector<double> >& ingredients, int i) {
-  if (is_mu_address(current_instruction().ingredients.at(i)))
-    return ingredients.at(i).at(/*skip alloc id*/1);
-  return ingredients.at(i).at(0);
-}
-
-void test_and() {
-  run(
-      "def main [\n"
-      "  1:bool <- copy true\n"
-      "  2:bool <- copy false\n"
-      "  3:bool <- and 1:bool, 2:bool\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_and_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- and true, true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_and_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- and true, true, false\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-void test_and_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- and true, true, true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-OR,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "or", OR);
-:(before "End Primitive Recipe Checks")
-case OR: {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_scalar(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'or' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'or' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case OR: {
-  bool result = false;
-  for (int i = 0;  i < SIZE(ingredients);  ++i)
-    result = result || scalar_ingredient(ingredients, i);
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_or() {
-  run(
-      "def main [\n"
-      "  1:bool <- copy true\n"
-      "  2:bool <- copy false\n"
-      "  3:bool <- or 1:bool, 2:bool\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_or_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- or false, false\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-void test_or_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- or false, false, false\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-void test_or_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- or false, false, true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-NOT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "not", NOT);
-:(before "End Primitive Recipe Checks")
-case NOT: {
-  if (SIZE(inst.products) != SIZE(inst.ingredients)) {
-    raise << "ingredients and products should match in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_scalar(inst.ingredients.at(i)) && !is_mu_address(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'not' requires ingredients that can be interpreted as boolean, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (is_dummy(inst.products.at(i))) continue;
-    if (!is_mu_boolean(inst.products.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'not' should yield a boolean, but got '" << inst.products.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NOT: {
-  products.resize(SIZE(ingredients));
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    products.at(i).push_back(!scalar_ingredient(ingredients, i));
-  }
-  break;
-}
-
-:(code)
-void test_not() {
-  run(
-      "def main [\n"
-      "  1:bool <- copy true\n"
-      "  2:bool <- not 1:bool\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 2\n"
-  );
-}
-
-void test_not_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool, 2:bool, 3:bool <- not true, false, true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 1 in location 2\n"
-      "mem: storing 0 in location 3\n"
-  );
-}
diff --git a/archive/2.vm/024jump.cc b/archive/2.vm/024jump.cc
deleted file mode 100644
index 66e238e6..00000000
--- a/archive/2.vm/024jump.cc
+++ /dev/null
@@ -1,237 +0,0 @@
-//: Jump primitives
-
-void test_jump_can_skip_instructions() {
-  run(
-      "def main [\n"
-      "  jump 1:offset\n"
-      "  1:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump {1: \"offset\"}\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: {1: \"number\"} <- copy {1: \"literal\"}");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 1 in location 1");
-}
-
-:(before "End Primitive Recipe Declarations")
-JUMP,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "jump", JUMP);
-:(before "End Primitive Recipe Checks")
-case JUMP: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' should get exactly one ingredient\n" << end();
-    break;
-  }
-  if (!is_literal(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '" << to_original_string(inst) << "' should be a label or offset, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case JUMP: {
-  assert(current_instruction().ingredients.at(0).initialized);
-  current_step_index() += ingredients.at(0).at(0)+1;
-  trace(Callstack_depth+1, "run") << "jumping to instruction " << current_step_index() << end();
-  // skip rest of this instruction
-  write_products = false;
-  fall_through_to_next_instruction = false;
-  break;
-}
-
-//: special type to designate jump targets
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "offset", 0);
-
-:(code)
-void test_jump_backward() {
-  run(
-      "def main [\n"
-      "  jump 1:offset\n"  // 0 -+
-      "  jump 3:offset\n"  //    |   +-+ 1
-                           //   \/  /\ |
-      "  jump -2:offset\n" //  2 +-->+ |
-      "]\n"                //         \/ 3
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump {1: \"offset\"}\n"
-      "run: jump {-2: \"offset\"}\n"
-      "run: jump {3: \"offset\"}\n"
-  );
-}
-
-void test_jump_takes_no_products() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- jump 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'jump' instructions write no products\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-JUMP_IF,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "jump-if", JUMP_IF);
-:(before "End Primitive Recipe Checks")
-case JUMP_IF: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' should get exactly two ingredients\n" << end();
-    break;
-  }
-  if (!is_mu_address(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
-    break;
-  }
-  if (!is_literal(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'jump-if' instructions write no products\n" << end();
-    break;
-  }
-  // End JUMP_IF Checks
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case JUMP_IF: {
-  assert(current_instruction().ingredients.at(1).initialized);
-  if (!scalar_ingredient(ingredients, 0)) {
-    trace(Callstack_depth+1, "run") << "jump-if fell through" << end();
-    break;
-  }
-  current_step_index() += ingredients.at(1).at(0)+1;
-  trace(Callstack_depth+1, "run") << "jumping to instruction " << current_step_index() << end();
-  // skip rest of this instruction
-  write_products = false;
-  fall_through_to_next_instruction = false;
-  break;
-}
-
-:(code)
-void test_jump_if() {
-  run(
-      "def main [\n"
-      "  jump-if 999, 1:offset\n"
-      "  123:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump-if {999: \"literal\"}, {1: \"offset\"}\n"
-      "run: jumping to instruction 2\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: {123: \"number\"} <- copy {1: \"literal\"}");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 1 in location 123");
-}
-
-void test_jump_if_fallthrough() {
-  run(
-      "def main [\n"
-      "  jump-if 0, 1:offset\n"
-      "  123:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump-if {0: \"literal\"}, {1: \"offset\"}\n"
-      "run: jump-if fell through\n"
-      "run: {123: \"number\"} <- copy {1: \"literal\"}\n"
-      "mem: storing 1 in location 123\n"
-  );
-}
-
-void test_jump_if_on_address() {
-  run(
-      "def main [\n"
-      "  10:num/alloc-id, 11:num <- copy 0, 999\n"
-      "  jump-if 10:&:number, 1:offset\n"
-      "  123:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump-if {10: (\"address\" \"number\")}, {1: \"offset\"}\n"
-      "run: jumping to instruction 3\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: {123: \"number\"} <- copy {1: \"literal\"}");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 1 in location 123");
-}
-
-:(before "End Primitive Recipe Declarations")
-JUMP_UNLESS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "jump-unless", JUMP_UNLESS);
-:(before "End Primitive Recipe Checks")
-case JUMP_UNLESS: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' should get exactly two ingredients\n" << end();
-    break;
-  }
-  if (!is_mu_address(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end();
-    break;
-  }
-  if (!is_literal(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'jump' instructions write no products\n" << end();
-    break;
-  }
-  // End JUMP_UNLESS Checks
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case JUMP_UNLESS: {
-  assert(current_instruction().ingredients.at(1).initialized);
-  if (scalar_ingredient(ingredients, 0)) {
-    trace(Callstack_depth+1, "run") << "jump-unless fell through" << end();
-    break;
-  }
-  current_step_index() += ingredients.at(1).at(0)+1;
-  trace(Callstack_depth+1, "run") << "jumping to instruction " << current_step_index() << end();
-  // skip rest of this instruction
-  write_products = false;
-  fall_through_to_next_instruction = false;
-  break;
-}
-
-:(code)
-void test_jump_unless() {
-  run(
-      "def main [\n"
-      "  jump-unless 0, 1:offset\n"
-      "  123:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump-unless {0: \"literal\"}, {1: \"offset\"}\n"
-      "run: jumping to instruction 2\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: {123: \"number\"} <- copy {1: \"literal\"}");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 1 in location 123");
-}
-
-void test_jump_unless_fallthrough() {
-  run(
-      "def main [\n"
-      "  jump-unless 999, 1:offset\n"
-      "  123:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: jump-unless {999: \"literal\"}, {1: \"offset\"}\n"
-      "run: jump-unless fell through\n"
-      "run: {123: \"number\"} <- copy {1: \"literal\"}\n"
-      "mem: storing 1 in location 123\n"
-  );
-}
diff --git a/archive/2.vm/025compare.cc b/archive/2.vm/025compare.cc
deleted file mode 100644
index bade3c9c..00000000
--- a/archive/2.vm/025compare.cc
+++ /dev/null
@@ -1,624 +0,0 @@
-//: Comparison primitives
-
-:(before "End Primitive Recipe Declarations")
-EQUAL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "equal", EQUAL);
-:(before "End Primitive Recipe Checks")
-case EQUAL: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'equal' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  const reagent& exemplar = inst.ingredients.at(0);
-  for (int i = /*skip exemplar*/1;  i < SIZE(inst.ingredients);  ++i) {
-    if (!types_match(inst.ingredients.at(i), exemplar) && !types_match(exemplar, inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << to_original_string(inst) << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case EQUAL: {
-  vector<double>& exemplar = ingredients.at(0);
-  bool result = true;
-  for (int i = /*skip exemplar*/1;  i < SIZE(ingredients);  ++i) {
-    if (SIZE(ingredients.at(i)) != SIZE(exemplar)) {
-      result = false;
-      break;
-    }
-    if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) {
-      result = false;
-      break;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_equal() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: location 1 is 34\n"
-      "mem: location 2 is 33\n"
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_equal_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:bool <- equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: location 1 is 34\n"
-      "mem: location 2 is 34\n"
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_equal_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- equal 34, 34, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_equal_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- equal 34, 34, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-NOT_EQUAL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "not-equal", NOT_EQUAL);
-:(before "End Primitive Recipe Checks")
-case NOT_EQUAL: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'equal' needs two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  const reagent& exemplar = inst.ingredients.at(0);
-  if (!types_match(inst.ingredients.at(1), exemplar) && !types_match(exemplar, inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << to_original_string(inst) << "'\n" << end();
-    goto finish_checking_instruction;
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NOT_EQUAL: {
-  vector<double>& exemplar = ingredients.at(0);
-  products.resize(1);
-  if (SIZE(ingredients.at(1)) != SIZE(exemplar)) {
-    products.at(0).push_back(true);
-    break;
-  }
-  bool equal_ingredients = equal(ingredients.at(1).begin(), ingredients.at(1).end(), exemplar.begin());
-  products.at(0).push_back(!equal_ingredients);
-  break;
-}
-
-:(code)
-void test_not_equal() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- not-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: location 1 is 34\n"
-      "mem: location 2 is 33\n"
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_not_equal_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:bool <- not-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: location 1 is 34\n"
-      "mem: location 2 is 34\n"
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-GREATER_THAN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "greater-than", GREATER_THAN);
-:(before "End Primitive Recipe Checks")
-case GREATER_THAN: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'greater-than' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'greater-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'greater-than' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'greater-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case GREATER_THAN: {
-  bool result = true;
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i-1).at(0) <= ingredients.at(i).at(0)) {
-      result = false;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_greater_than() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- greater-than 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_greater_than_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:bool <- greater-than 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_greater_than_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- greater-than 36, 35, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_greater_than_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- greater-than 36, 35, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-LESSER_THAN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "lesser-than", LESSER_THAN);
-:(before "End Primitive Recipe Checks")
-case LESSER_THAN: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'lesser-than' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'lesser-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'lesser-than' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'lesser-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case LESSER_THAN: {
-  bool result = true;
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i-1).at(0) >= ingredients.at(i).at(0)) {
-      result = false;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_lesser_than() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 32\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- lesser-than 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_lesser_than_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- lesser-than 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_lesser_than_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- lesser-than 34, 35, 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_lesser_than_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- lesser-than 34, 35, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-:(before "End Primitive Recipe Declarations")
-GREATER_OR_EQUAL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "greater-or-equal", GREATER_OR_EQUAL);
-:(before "End Primitive Recipe Checks")
-case GREATER_OR_EQUAL: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'greater-or-equal' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'greater-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case GREATER_OR_EQUAL: {
-  bool result = true;
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i-1).at(0) < ingredients.at(i).at(0)) {
-      result = false;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_greater_or_equal() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- greater-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_greater_or_equal_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:bool <- greater-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_greater_or_equal_3() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 35\n"
-      "  3:bool <- greater-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_greater_or_equal_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- greater-or-equal 36, 35, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_greater_or_equal_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- greater-or-equal 36, 35, 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-LESSER_OR_EQUAL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "lesser-or-equal", LESSER_OR_EQUAL);
-:(before "End Primitive Recipe Checks")
-case LESSER_OR_EQUAL: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case LESSER_OR_EQUAL: {
-  bool result = true;
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i-1).at(0) > ingredients.at(i).at(0)) {
-      result = false;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_lesser_or_equal() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 32\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- lesser-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_lesser_or_equal_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 33\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- lesser-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_lesser_or_equal_3() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 33\n"
-      "  3:bool <- lesser-or-equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_lesser_or_equal_multiple() {
-  run(
-      "def main [\n"
-      "  1:bool <- lesser-or-equal 34, 35, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-  );
-}
-
-void test_lesser_or_equal_multiple_2() {
-  run(
-      "def main [\n"
-      "  1:bool <- lesser-or-equal 34, 35, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-MAX,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "max", MAX);
-:(before "End Primitive Recipe Checks")
-case MAX: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'max' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'max' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'max' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'max' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MAX: {
-  int result = ingredients.at(0).at(0);
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i).at(0) > result) {
-      result = ingredients.at(i).at(0);
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MIN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "min", MIN);
-:(before "End Primitive Recipe Checks")
-case MIN: {
-  if (SIZE(inst.ingredients) <= 1) {
-    raise << maybe(get(Recipe, r).name) << "'min' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_number(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'min' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > 1) {
-    raise << maybe(get(Recipe, r).name) << "'min' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'min' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MIN: {
-  int result = ingredients.at(0).at(0);
-  for (int i = /**/1;  i < SIZE(ingredients);  ++i) {
-    if (ingredients.at(i).at(0) < result) {
-      result = ingredients.at(i).at(0);
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
diff --git a/archive/2.vm/026call.cc b/archive/2.vm/026call.cc
deleted file mode 100644
index faa9455d..00000000
--- a/archive/2.vm/026call.cc
+++ /dev/null
@@ -1,246 +0,0 @@
-//: So far the recipes we define can't run each other. Let's fix that.
-
-void test_calling_recipe() {
-  run(
-      "def main [\n"
-      "  f\n"
-      "]\n"
-      "def f [\n"
-      "  3:num <- add 2, 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 3\n"
-  );
-}
-
-void test_return_on_fallthrough() {
-  run(
-      "def main [\n"
-      "  f\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-      "def f [\n"
-      "  4:num <- copy 0\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: f\n"
-      "run: {4: \"number\"} <- copy {0: \"literal\"}\n"
-      "run: {5: \"number\"} <- copy {0: \"literal\"}\n"
-      "run: {1: \"number\"} <- copy {0: \"literal\"}\n"
-      "run: {2: \"number\"} <- copy {0: \"literal\"}\n"
-      "run: {3: \"number\"} <- copy {0: \"literal\"}\n"
-  );
-}
-
-:(before "struct routine {")
-// Everytime a recipe runs another, we interrupt it and start running the new
-// recipe. When that finishes, we continue this one where we left off.
-// This requires maintaining a 'stack' of interrupted recipes or 'calls'.
-struct call {
-  recipe_ordinal running_recipe;
-  int running_step_index;
-  // End call Fields
-  call(recipe_ordinal r) { clear(r, 0); }
-  call(recipe_ordinal r, int index) { clear(r, index); }
-  void clear(recipe_ordinal r, int index) {
-    running_recipe = r;
-    running_step_index = index;
-    // End call Constructor
-  }
-  ~call() {
-    // End call Destructor
-  }
-};
-typedef list<call> call_stack;
-
-:(replace{} "struct routine")
-struct routine {
-  call_stack calls;
-  // End routine Fields
-  routine(recipe_ordinal r);
-  bool completed() const;
-  const vector<instruction>& steps() const;
-};
-:(code)
-routine::routine(recipe_ordinal r) {
-  ++Callstack_depth;
-  trace(Callstack_depth+1, "trace") << "new routine; incrementing callstack depth to " << Callstack_depth << end();
-  assert(Callstack_depth < Max_depth);
-  calls.push_front(call(r));
-  // End routine Constructor
-}
-
-//:: now update routine's helpers
-
-//: macro versions for a slight speedup
-
-:(delete{} "int& current_step_index()")
-:(delete{} "recipe_ordinal currently_running_recipe()")
-:(delete{} "const string& current_recipe_name()")
-:(delete{} "const recipe& current_recipe()")
-:(delete{} "const instruction& current_instruction()")
-
-:(before "End Includes")
-#define current_call() Current_routine->calls.front()
-#define current_step_index() current_call().running_step_index
-#define currently_running_recipe() current_call().running_recipe
-#define current_recipe() get(Recipe, currently_running_recipe())
-#define current_recipe_name() current_recipe().name
-#define to_instruction(call) get(Recipe, (call).running_recipe).steps.at((call).running_step_index)
-#define current_instruction() to_instruction(current_call())
-
-//: function versions for debugging
-
-:(code)
-//? :(before "End Globals")
-//? bool Foo2 = false;
-//? :(code)
-//? call& current_call() {
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return Current_routine->calls.front();
-//? }
-//? :(replace{} "int& current_step_index()")
-//? int& current_step_index() {
-//?   assert(!Current_routine->calls.empty());
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return current_call().running_step_index;
-//? }
-//? :(replace{} "recipe_ordinal currently_running_recipe()")
-//? recipe_ordinal currently_running_recipe() {
-//?   assert(!Current_routine->calls.empty());
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return current_call().running_recipe;
-//? }
-//? :(replace{} "const string& current_recipe_name()")
-//? const string& current_recipe_name() {
-//?   assert(!Current_routine->calls.empty());
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return get(Recipe, current_call().running_recipe).name;
-//? }
-//? :(replace{} "const recipe& current_recipe()")
-//? const recipe& current_recipe() {
-//?   assert(!Current_routine->calls.empty());
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return get(Recipe, current_call().running_recipe);
-//? }
-//? :(replace{} "const instruction& current_instruction()")
-//? const instruction& current_instruction() {
-//?   assert(!Current_routine->calls.empty());
-//?   if (Foo2) cerr << __FUNCTION__ << '\n';
-//?   return to_instruction(current_call());
-//? }
-//? :(code)
-//? const instruction& to_instruction(const call& call) {
-//?   return get(Recipe, call.running_recipe).steps.at(call.running_step_index);
-//? }
-
-:(code)
-void dump_callstack() {
-  if (!Current_routine) return;
-  if (Current_routine->calls.size() <= 1) return;
-  for (call_stack::const_iterator p = ++Current_routine->calls.begin();  p != Current_routine->calls.end();  ++p)
-    raise << "  called from " << get(Recipe, p->running_recipe).name << ": " << to_original_string(to_instruction(*p)) << '\n' << end();
-}
-
-:(after "Defined Recipe Checks")
-// not a primitive; check that it's present in the book of recipes
-if (!contains_key(Recipe, inst.operation)) {
-  raise << maybe(get(Recipe, r).name) << "undefined operation in '" << to_original_string(inst) << "'\n" << end();
-  break;
-}
-:(replace{} "default:" following "End Primitive Recipe Implementations")
-default: {
-  if (contains_key(Recipe, current_instruction().operation)) {  // error already raised in Checks above
-    // not a primitive; look up the book of recipes
-    ++Callstack_depth;
-    trace(Callstack_depth+1, "trace") << "incrementing callstack depth to " << Callstack_depth << end();
-    assert(Callstack_depth < Max_depth);
-    const call& caller_frame = current_call();
-    Current_routine->calls.push_front(call(to_instruction(caller_frame).operation));
-    finish_call_housekeeping(to_instruction(caller_frame), ingredients);
-    // not done with caller
-    write_products = false;
-    fall_through_to_next_instruction = false;
-    // End Non-primitive Call(caller_frame)
-  }
-}
-:(code)
-void finish_call_housekeeping(const instruction& call_instruction, const vector<vector<double> >& ingredients) {
-  // End Call Housekeeping
-}
-
-void test_calling_undefined_recipe_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  foo\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: undefined operation in 'foo'\n"
-  );
-}
-
-void test_calling_undefined_recipe_handles_missing_result() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  x:num <- foo\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: undefined operation in 'x:num <- foo'\n"
-  );
-}
-
-//:: finally, we need to fix the termination conditions for the run loop
-
-:(replace{} "bool routine::completed() const")
-bool routine::completed() const {
-  return calls.empty();
-}
-
-:(replace{} "const vector<instruction>& routine::steps() const")
-const vector<instruction>& routine::steps() const {
-  assert(!calls.empty());
-  return get(Recipe, calls.front().running_recipe).steps;
-}
-
-:(after "Running One Instruction")
-// when we reach the end of one call, we may reach the end of the one below
-// it, and the one below that, and so on
-while (current_step_index() >= SIZE(Current_routine->steps())) {
-  // Falling Through End Of Recipe
-  trace(Callstack_depth+1, "trace") << "fall-through: exiting " << current_recipe_name() << "; decrementing callstack depth from " << Callstack_depth << end();
-  --Callstack_depth;
-  assert(Callstack_depth >= 0);
-  Current_routine->calls.pop_front();
-  if (Current_routine->calls.empty()) goto stop_running_current_routine;
-  // Complete Call Fallthrough
-  // todo: fail if no products returned
-  ++current_step_index();
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_CALL_STACK,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump-call-stack", _DUMP_CALL_STACK);
-:(before "End Primitive Recipe Checks")
-case _DUMP_CALL_STACK: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _DUMP_CALL_STACK: {
-  dump(Current_routine->calls);
-  break;
-}
-:(code)
-void dump(const call_stack& calls) {
-  for (call_stack::const_reverse_iterator p = calls.rbegin(); p != calls.rend(); ++p)
-    cerr << get(Recipe, p->running_recipe).name << ":" << p->running_step_index << " -- " << to_string(to_instruction(*p)) << '\n';
-}
diff --git a/archive/2.vm/027call_ingredient.cc b/archive/2.vm/027call_ingredient.cc
deleted file mode 100644
index 659f644d..00000000
--- a/archive/2.vm/027call_ingredient.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-//: Calls can take ingredients just like primitives. To access a recipe's
-//: ingredients, use 'next-ingredient'.
-
-void test_next_ingredient() {
-  run(
-      "def main [\n"
-      "  f 2\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"
-      "  13:num <- add 1, 12:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 13\n"
-  );
-}
-
-void test_next_ingredient_missing() {
-  run(
-      "def main [\n"
-      "  f\n"
-      "]\n"
-      "def f [\n"
-      "  _, 12:num <- next-ingredient\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 12\n"
-  );
-}
-
-:(before "End call Fields")
-vector<vector<double> > ingredient_atoms;
-vector<reagent> ingredients;
-int next_ingredient_to_process;
-:(before "End call Constructor")
-next_ingredient_to_process = 0;
-
-:(before "End Call Housekeeping")
-for (int i = 0;  i < SIZE(ingredients);  ++i) {
-  current_call().ingredient_atoms.push_back(ingredients.at(i));
-  reagent/*copy*/ ingredient = call_instruction.ingredients.at(i);
-  // End Compute Call Ingredient
-  current_call().ingredients.push_back(ingredient);
-  // End Populate Call Ingredient
-}
-
-:(before "End Primitive Recipe Declarations")
-NEXT_INGREDIENT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "next-ingredient", NEXT_INGREDIENT);
-put(Recipe_ordinal, "next-input", NEXT_INGREDIENT);
-:(before "End Primitive Recipe Checks")
-case NEXT_INGREDIENT: {
-  if (!inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'next-ingredient' didn't expect any ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NEXT_INGREDIENT: {
-  assert(!Current_routine->calls.empty());
-  if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) {
-    reagent/*copy*/ product = current_instruction().products.at(0);
-    // End Preprocess NEXT_INGREDIENT product
-    if (current_recipe_name() == "main") {
-      // no ingredient types since the call might be implicit; assume ingredients are always strings
-      // todo: how to test this?
-      if (!is_mu_text(product))
-        raise << "main: wrong type for ingredient '" << product.original_string << "'\n" << end();
-    }
-    else if (!types_coercible(product,
-                              current_call().ingredients.at(current_call().next_ingredient_to_process))) {
-      raise << maybe(current_recipe_name()) << "wrong type for ingredient '" << product.original_string << "': " << current_call().ingredients.at(current_call().next_ingredient_to_process).original_string << '\n' << end();
-      // End next-ingredient Type Mismatch Error
-    }
-    products.push_back(
-        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
-    assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
-    products.at(1).push_back(1);
-    ++current_call().next_ingredient_to_process;
-  }
-  else {
-    if (SIZE(current_instruction().products) < 2)
-      raise << maybe(current_recipe_name()) << "no ingredient to save in '" << current_instruction().products.at(0).original_string << "'\n" << end();
-    if (current_instruction().products.empty()) break;
-    products.resize(2);
-    // pad the first product with sufficient zeros to match its type
-    products.at(0).resize(size_of(current_instruction().products.at(0)));
-    products.at(1).push_back(0);
-  }
-  break;
-}
-
-:(code)
-void test_next_ingredient_fail_on_missing() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  f\n"
-      "]\n"
-      "def f [\n"
-      "  11:num <- next-ingredient\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: f: no ingredient to save in '11:num'\n"
-  );
-}
-
-void test_rewind_ingredients() {
-  run(
-      "def main [\n"
-      "  f 2\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"  // consume ingredient
-      "  _, 1:bool <- next-ingredient\n"  // will not find any ingredients
-      "  rewind-ingredients\n"
-      "  13:num, 2:bool <- next-ingredient\n"  // will find ingredient again
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 12\n"
-      "mem: storing 0 in location 1\n"
-      "mem: storing 2 in location 13\n"
-      "mem: storing 1 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-REWIND_INGREDIENTS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "rewind-ingredients", REWIND_INGREDIENTS);
-put(Recipe_ordinal, "rewind-inputs", REWIND_INGREDIENTS);
-:(before "End Primitive Recipe Checks")
-case REWIND_INGREDIENTS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case REWIND_INGREDIENTS: {
-  current_call().next_ingredient_to_process = 0;
-  break;
-}
-
-//: another primitive: 'ingredient' for random access
-
-:(code)
-void test_ingredient() {
-  run(
-      "def main [\n"
-      "  f 1, 2\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- ingredient 1\n"  // consume second ingredient first
-      "  13:num, 1:bool <- next-ingredient\n"  // next-ingredient tries to scan past that
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 12\n"
-      "mem: storing 0 in location 1\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-INGREDIENT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "ingredient", INGREDIENT);
-put(Recipe_ordinal, "input", INGREDIENT);
-:(before "End Primitive Recipe Checks")
-case INGREDIENT: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'ingredient' expects exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_literal(inst.ingredients.at(0)) && !is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'ingredient' expects a literal ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case INGREDIENT: {
-  if (static_cast<int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) {
-    current_call().next_ingredient_to_process = ingredients.at(0).at(0);
-    products.push_back(
-        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
-    assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
-    products.at(1).push_back(1);
-    ++current_call().next_ingredient_to_process;
-  }
-  else {
-    if (SIZE(current_instruction().products) > 1) {
-      products.resize(2);
-      products.at(0).push_back(0);  // todo: will fail noisily if we try to read a compound value
-      products.at(1).push_back(0);
-    }
-  }
-  break;
-}
-
-//: a particularly common array type is the text, or address:array:character
-:(code)
-bool is_mu_text(reagent/*copy*/ x) {
-  // End Preprocess is_mu_text(reagent x)
-  return x.type
-      && !x.type->atom
-      && x.type->left->atom
-      && x.type->left->value == Address_type_ordinal
-      && x.type->right
-      && !x.type->right->atom
-      && x.type->right->left->atom
-      && x.type->right->left->value == Array_type_ordinal
-      && x.type->right->right
-      && !x.type->right->right->atom
-      && x.type->right->right->left->value == Character_type_ordinal
-      && x.type->right->right->right == NULL;
-}
diff --git a/archive/2.vm/028call_return.cc b/archive/2.vm/028call_return.cc
deleted file mode 100644
index 056db7b9..00000000
--- a/archive/2.vm/028call_return.cc
+++ /dev/null
@@ -1,197 +0,0 @@
-//: Calls can also generate products, using 'reply' or 'return'.
-
-void test_return() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- f 34\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"
-      "  13:num <- add 1, 12:num\n"
-      "  return 12:num, 13:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      "mem: storing 35 in location 2\n"
-  );
-}
-
-void test_reply() {
-  run(
-      "def main [\n"
-      "  1:num, 2:num <- f 34\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"
-      "  13:num <- add 1, 12:num\n"
-      "  reply 12:num, 13:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      "mem: storing 35 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-RETURN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "return", RETURN);
-put(Recipe_ordinal, "reply", RETURN);  // synonym while teaching
-put(Recipe_ordinal, "output", RETURN);  // experiment
-:(before "End Primitive Recipe Checks")
-case RETURN: {
-  break;  // checks will be performed by a transform below
-}
-:(before "End Primitive Recipe Implementations")
-case RETURN: {
-  // Begin Return
-  trace(Callstack_depth+1, "trace") << current_instruction().name << ": decrementing callstack depth from " << Callstack_depth << end();
-  --Callstack_depth;
-  if (Callstack_depth < 0) {
-    Current_routine->calls.clear();
-    goto stop_running_current_routine;
-  }
-  Current_routine->calls.pop_front();
-  // just in case 'main' returns a value, drop it for now
-  if (Current_routine->calls.empty()) goto stop_running_current_routine;
-  for (int i = 0;  i < SIZE(ingredients);  ++i)
-    trace(Callstack_depth+1, "run") << "result " << i << " is " << to_string(ingredients.at(i)) << end();
-  // make return products available to caller
-  copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin()));
-  // End Return
-  break;  // continue to process rest of *caller* instruction
-}
-
-//: Types in return instructions are checked ahead of time.
-
-:(before "End Checks")
-Transform.push_back(check_types_of_return_instructions);  // idempotent
-:(code)
-void check_types_of_return_instructions(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  trace(9991, "transform") << "--- check types of return instructions in recipe " << caller.name << end();
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& caller_instruction = caller.steps.at(i);
-    if (caller_instruction.is_label) continue;
-    if (caller_instruction.products.empty()) continue;
-    if (is_primitive(caller_instruction.operation)) continue;
-    const recipe& callee = get(Recipe, caller_instruction.operation);
-    for (int i = 0;  i < SIZE(callee.steps);  ++i) {
-      const instruction& return_inst = callee.steps.at(i);
-      if (return_inst.operation != RETURN) continue;
-      // check types with the caller
-      if (SIZE(caller_instruction.products) > SIZE(return_inst.ingredients)) {
-        raise << maybe(caller.name) << "too few values returned from " << callee.name << '\n' << end();
-        break;
-      }
-      for (int i = 0;  i < SIZE(caller_instruction.products);  ++i) {
-        reagent/*copy*/ lhs = return_inst.ingredients.at(i);
-        reagent/*copy*/ rhs = caller_instruction.products.at(i);
-        // End Check RETURN Copy(lhs, rhs)
-        if (!types_coercible(rhs, lhs)) {
-          raise << maybe(callee.name) << return_inst.name << " ingredient '" << lhs.original_string << "' can't be saved in '" << rhs.original_string << "'\n" << end();
-          raise << "  ['" << to_string(lhs.type) << "' vs '" << to_string(rhs.type) << "']\n" << end();
-          goto finish_return_check;
-        }
-      }
-      // check that any return ingredients with /same-as-ingredient connect up
-      // the corresponding ingredient and product in the caller.
-      for (int i = 0;  i < SIZE(caller_instruction.products);  ++i) {
-        if (has_property(return_inst.ingredients.at(i), "same-as-ingredient")) {
-          string_tree* tmp = property(return_inst.ingredients.at(i), "same-as-ingredient");
-          if (!tmp || !tmp->atom) {
-            raise << maybe(caller.name) << "'same-as-ingredient' metadata should take exactly one value in '" << to_original_string(return_inst) << "'\n" << end();
-            goto finish_return_check;
-          }
-          int ingredient_index = to_integer(tmp->value);
-          if (ingredient_index >= SIZE(caller_instruction.ingredients)) {
-            raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(caller_instruction) << "'\n" << end();
-            goto finish_return_check;
-          }
-          if (!is_dummy(caller_instruction.products.at(i)) && !is_literal(caller_instruction.ingredients.at(ingredient_index)) && caller_instruction.products.at(i).name != caller_instruction.ingredients.at(ingredient_index).name) {
-            raise << maybe(caller.name) << "'" << to_original_string(caller_instruction) << "' should write to '" << caller_instruction.ingredients.at(ingredient_index).original_string << "' rather than '" << caller_instruction.products.at(i).original_string << "'\n" << end();
-          }
-        }
-      }
-      finish_return_check:;
-    }
-  }
-}
-
-bool is_primitive(recipe_ordinal r) {
-  return r < MAX_PRIMITIVE_RECIPES;
-}
-
-void test_return_type_mismatch() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  3:num <- f 2\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"
-      "  13:num <- copy 35\n"
-      "  14:point <- copy 12:point/raw\n"
-      "  return 14:point\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: f: return ingredient '14:point' can't be saved in '3:num'\n"
-  );
-}
-
-//: In Mu we'd like to assume that any instruction doesn't modify its
-//: ingredients unless they're also products. The /same-as-ingredient inside
-//: the recipe's 'return' indicates that an ingredient is intended to be
-//: modified in place, and will help catch accidental misuse of such
-//: 'ingredient-products' (sometimes called in-out parameters in other
-//: languages).
-
-void test_return_same_as_ingredient() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- test1 1:num  # call with different ingredient and product\n"
-      "]\n"
-      "def test1 [\n"
-      "  10:num <- next-ingredient\n"
-      "  return 10:num/same-as-ingredient:0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: '2:num <- test1 1:num' should write to '1:num' rather than '2:num'\n"
-  );
-}
-
-void test_return_same_as_ingredient_dummy() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  _ <- test1 1:num  # call with different ingredient and product\n"
-      "]\n"
-      "def test1 [\n"
-      "  10:num <- next-ingredient\n"
-      "  return 10:num/same-as-ingredient:0\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-string to_string(const vector<double>& in) {
-  if (in.empty()) return "[]";
-  ostringstream out;
-  if (SIZE(in) == 1) {
-    out << no_scientific(in.at(0));
-    return out.str();
-  }
-  out << "[";
-  for (int i = 0;  i < SIZE(in);  ++i) {
-    if (i > 0) out << ", ";
-    out << no_scientific(in.at(i));
-  }
-  out << "]";
-  return out.str();
-}
diff --git a/archive/2.vm/029tools.cc b/archive/2.vm/029tools.cc
deleted file mode 100644
index 4cca09f6..00000000
--- a/archive/2.vm/029tools.cc
+++ /dev/null
@@ -1,326 +0,0 @@
-//: Allow Mu programs to log facts just like we've been doing in C++ so far.
-
-void test_trace() {
-  run(
-      "def main [\n"
-      "  trace 1, [foo], [this is a trace in Mu]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "foo: this is a trace in Mu\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-TRACE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "trace", TRACE);
-:(before "End Primitive Recipe Checks")
-case TRACE: {
-  if (SIZE(inst.ingredients) < 3) {
-    raise << maybe(get(Recipe, r).name) << "'trace' takes three or more ingredients rather than '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'trace' should be a number (depth), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'trace' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TRACE: {
-  int depth = ingredients.at(0).at(0);
-  string label = current_instruction().ingredients.at(1).name;
-  ostringstream out;
-  for (int i = 2;  i < SIZE(current_instruction().ingredients);  ++i) {
-    if (i > 2) out << ' ';
-    out << inspect(current_instruction().ingredients.at(i), ingredients.at(i));
-  }
-  trace(depth, label) << out.str() << end();
-  break;
-}
-
-//: simpler limited version of 'trace'
-
-:(before "End Types")  //: include in all cleaved compilation units
-const int App_depth = 1;  // where all Mu code will trace to by default
-
-:(before "End Primitive Recipe Declarations")
-STASH,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "stash", STASH);
-:(before "End Primitive Recipe Checks")
-case STASH: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case STASH: {
-  ostringstream out;
-  for (int i = 0;  i < SIZE(current_instruction().ingredients);  ++i) {
-    if (i) out << ' ';
-    out << inspect(current_instruction().ingredients.at(i), ingredients.at(i));
-  }
-  trace(App_depth, "app") << out.str() << end();
-  break;
-}
-
-:(code)
-void test_stash_literal_string() {
-  run(
-      "def main [\n"
-      "  stash [foo]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo\n"
-  );
-}
-
-void test_stash_literal_number() {
-  run(
-      "def main [\n"
-      "  stash [foo:], 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: 4\n"
-  );
-}
-
-void test_stash_number() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  stash [foo:], 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: 34\n"
-  );
-}
-
-:(code)
-string inspect(const reagent& r, const vector<double>& data) {
-  if (is_literal(r))
-    return r.name;
-  // End inspect Special-cases(r, data)
-  ostringstream out;
-  for (long long i = 0;  i < SIZE(data);  ++i) {
-    if (i) out << ' ';
-    out << no_scientific(data.at(i));
-  }
-  return out.str();
-}
-
-:(before "End Primitive Recipe Declarations")
-HIDE_ERRORS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "hide-errors", HIDE_ERRORS);
-:(before "End Primitive Recipe Checks")
-case HIDE_ERRORS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case HIDE_ERRORS: {
-  Hide_errors = true;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-SHOW_ERRORS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "show-errors", SHOW_ERRORS);
-:(before "End Primitive Recipe Checks")
-case SHOW_ERRORS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SHOW_ERRORS: {
-  Hide_errors = false;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-TRACE_UNTIL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "trace-until", TRACE_UNTIL);
-:(before "End Primitive Recipe Checks")
-case TRACE_UNTIL: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TRACE_UNTIL: {
-  if (Trace_stream) {
-    Trace_stream->collect_depth = ingredients.at(0).at(0);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_TRACE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump-trace", _DUMP_TRACE);
-:(before "End Primitive Recipe Checks")
-case _DUMP_TRACE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _DUMP_TRACE: {
-  if (ingredients.empty()) {
-    DUMP("");
-  }
-  else {
-    DUMP(current_instruction().ingredients.at(0).name);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLEAR_TRACE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$clear-trace", _CLEAR_TRACE);
-:(before "End Primitive Recipe Checks")
-case _CLEAR_TRACE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _CLEAR_TRACE: {
-  if (Trace_stream) Trace_stream->past_lines.clear();
-  break;
-}
-
-//:: 'cheating' by using the host system
-
-:(before "End Primitive Recipe Declarations")
-_PRINT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$print", _PRINT);
-:(before "End Primitive Recipe Checks")
-case _PRINT: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _PRINT: {
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    if (is_literal(current_instruction().ingredients.at(i))) {
-      trace(Callstack_depth+1, "run") << "$print: " << current_instruction().ingredients.at(i).name << end();
-      if (!has_property(current_instruction().ingredients.at(i), "newline")) {
-        cout << current_instruction().ingredients.at(i).name;
-      }
-      // hack: '$print 10' prints '10', but '$print 10/newline' prints '\n'
-      // End $print 10/newline Special-cases
-      else {
-        cout << '\n';
-      }
-    }
-    // End $print Special-cases
-    else {
-      for (int j = 0;  j < SIZE(ingredients.at(i));  ++j) {
-        trace(Callstack_depth+1, "run") << "$print: " << ingredients.at(i).at(j) << end();
-        if (j > 0) cout << " ";
-        cout << no_scientific(ingredients.at(i).at(j));
-      }
-    }
-  }
-  cout.flush();
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_EXIT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$exit", _EXIT);
-:(before "End Primitive Recipe Checks")
-case _EXIT: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _EXIT: {
-  exit(0);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_SYSTEM,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$system", _SYSTEM);
-:(before "End Primitive Recipe Checks")
-case _SYSTEM: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$system' requires exactly one ingredient, but got '" << to_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "ingredient to '$system' must be a literal text, but got '" << to_string(inst) << "'\n" << end();
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _SYSTEM: {
-  int status = system(current_instruction().ingredients.at(0).name.c_str());
-  products.resize(1);
-  products.at(0).push_back(status);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_MEMORY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump-memory", _DUMP_MEMORY);
-:(before "End Primitive Recipe Checks")
-case _DUMP_MEMORY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _DUMP_MEMORY: {
-  dump_memory();
-  break;
-}
-
-//: In times of real extremis we need to create a whole new modality for debug
-//: logs, independent of other changes to the screen or Trace_stream.
-
-:(before "End Globals")
-ofstream LOG;
-:(before "End One-time Setup")
-//? LOG.open("log");
-
-:(before "End Primitive Recipe Declarations")
-_LOG,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$log", _LOG);
-:(before "End Primitive Recipe Checks")
-case _LOG: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _LOG: {
-  ostringstream out;
-  for (int i = 0;  i < SIZE(current_instruction().ingredients);  ++i) {
-    out << inspect(current_instruction().ingredients.at(i), ingredients.at(i));
-  }
-  LOG << out.str() << '\n';
-  break;
-}
-
-//: set a variable from within Mu code
-//: useful for selectively tracing or printing after some point
-:(before "End Globals")
-bool Foo = false;
-:(before "End Primitive Recipe Declarations")
-_FOO,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$foo", _FOO);
-:(before "End Primitive Recipe Checks")
-case _FOO: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _FOO: {
-  Foo = true;
-  break;
-}
diff --git a/archive/2.vm/030container.cc b/archive/2.vm/030container.cc
deleted file mode 100644
index e20af025..00000000
--- a/archive/2.vm/030container.cc
+++ /dev/null
@@ -1,819 +0,0 @@
-//: Containers contain a fixed number of elements of different types.
-
-:(before "End Mu Types Initialization")
-//: We'll use this container as a running example in scenarios below.
-type_ordinal point = put(Type_ordinal, "point", Next_type_ordinal++);
-get_or_insert(Type, point);  // initialize
-get(Type, point).kind = CONTAINER;
-get(Type, point).name = "point";
-get(Type, point).elements.push_back(reagent("x:number"));
-get(Type, point).elements.push_back(reagent("y:number"));
-
-//: Containers can be copied around with a single instruction just like
-//: numbers, no matter how large they are.
-
-//: Tests in this layer often explicitly set up memory before reading it as a
-//: container. Don't do this in general. I'm tagging such cases with /unsafe;
-//: they'll be exceptions to later checks.
-
-:(code)
-void test_copy_multiple_locations() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 35\n"
-      "  3:point <- copy 1:point/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 3\n"
-      "mem: storing 35 in location 4\n"
-  );
-}
-
-//: trying to copy to a differently-typed destination will fail
-void test_copy_checks_size() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  2:point <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '1:num' to '2:point'; types don't match\n"
-  );
-}
-
-:(before "End Mu Types Initialization")
-// A more complex example container, containing another container as one of
-// its elements.
-type_ordinal point_number = put(Type_ordinal, "point-number", Next_type_ordinal++);
-get_or_insert(Type, point_number);  // initialize
-get(Type, point_number).kind = CONTAINER;
-get(Type, point_number).name = "point-number";
-get(Type, point_number).elements.push_back(reagent("xy:point"));
-get(Type, point_number).elements.push_back(reagent("z:number"));
-
-:(code)
-void test_copy_handles_nested_container_elements() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  15:point-number <- copy 12:point-number/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 36 in location 17\n"
-  );
-}
-
-//: products of recipes can include containers
-void test_return_container() {
-  run(
-      "def main [\n"
-      "  3:point <- f 2\n"
-      "]\n"
-      "def f [\n"
-      "  12:num <- next-ingredient\n"
-      "  13:num <- copy 35\n"
-      "  return 12:point/raw\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: result 0 is [2, 35]\n"
-      "mem: storing 2 in location 3\n"
-      "mem: storing 35 in location 4\n"
-  );
-}
-
-//: Containers can be checked for equality with a single instruction just like
-//: numbers, no matter how large they are.
-
-void test_compare_multiple_locations() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"  // first
-      "  2:num <- copy 35\n"
-      "  3:num <- copy 36\n"
-      "  4:num <- copy 34\n"  // second
-      "  5:num <- copy 35\n"
-      "  6:num <- copy 36\n"
-      "  7:bool <- equal 1:point-number/raw, 4:point-number/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 7\n"
-  );
-}
-
-void test_compare_multiple_locations_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"  // first
-      "  2:num <- copy 35\n"
-      "  3:num <- copy 36\n"
-      "  4:num <- copy 34\n"  // second
-      "  5:num <- copy 35\n"
-      "  6:num <- copy 37\n"  // different
-      "  7:bool <- equal 1:point-number/raw, 4:point-number/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 7\n"
-  );
-}
-
-:(before "End size_of(type) Special-cases")
-if (type->value == -1) return 1;  // error value, but we'll raise it elsewhere
-if (type->value == 0) return 1;
-if (!contains_key(Type, type->value)) {
-  raise << "no such type " << type->value << '\n' << end();
-  return 0;
-}
-type_info t = get(Type, type->value);
-if (t.kind == CONTAINER) {
-  // size of a container is the sum of the sizes of its elements
-  int result = 0;
-  for (int i = 0; i < SIZE(t.elements); ++i) {
-    // todo: strengthen assertion to disallow mutual type recursion
-    if (t.elements.at(i).type->value == type->value) {
-      raise << "container " << t.name << " can't include itself as a member\n" << end();
-      return 0;
-    }
-    result += size_of(element_type(type, i));
-  }
-  return result;
-}
-
-:(code)
-void test_stash_container() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"  // first
-      "  2:num <- copy 35\n"
-      "  3:num <- copy 36\n"
-      "  stash [foo:], 1:point-number/raw\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: 34 35 36\n"
-  );
-}
-
-//:: To access elements of a container, use 'get'
-//: 'get' takes a 'base' container and an 'offset' into it and returns the
-//: appropriate element of the container value.
-
-void test_get() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  15:num <- get 12:point/raw, 1:offset\n"  // unsafe
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 15\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-GET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "get", GET);
-:(before "End Primitive Recipe Checks")
-case GET: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'get' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);  // new copy for every invocation
-  // Update GET base in Check
-  if (!base.type) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = base.type;
-  // Update GET base_type in Check
-  if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != CONTAINER) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  const reagent& offset = inst.ingredients.at(1);
-  if (!is_literal(offset) || !is_mu_scalar(offset)) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'get' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  int offset_value = 0;
-  if (is_integer(offset.name)) {
-    offset_value = to_integer(offset.name);
-  }
-  // End update GET offset_value in Check
-  if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) {
-    raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end();
-    break;
-  }
-  if (inst.products.empty()) break;
-  reagent/*copy*/ product = inst.products.at(0);
-  // Update GET product in Check
-  //: use base.type rather than base_type because later layers will introduce compound types
-  const reagent/*copy*/ element = element_type(base.type, offset_value);
-  if (!types_coercible(product, element)) {
-    raise << maybe(get(Recipe, r).name) << "'get " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << product.name << "' has type " << names_to_string_without_quotes(product.type) << '\n' << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case GET: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  // Update GET base in Run
-  int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = base.type;
-  // Update GET base_type in Run
-  int offset = ingredients.at(1).at(0);
-  if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break;  // copied from Check above
-  int src = base_address;
-  for (int i = 0; i < offset; ++i)
-    src += size_of(element_type(base.type, i));
-  trace(Callstack_depth+1, "run") << "address to copy is " << src << end();
-  //: use base.type rather than base_type because later layers will introduce compound types
-  reagent/*copy*/ element = element_type(base.type, offset);
-  element.set_value(src);
-  trace(Callstack_depth+1, "run") << "its type is " << names_to_string(element.type) << end();
-  // Read element
-  products.push_back(read_memory(element));
-  break;
-}
-
-:(code)
-const reagent element_type(const type_tree* type, int offset_value) {
-  assert(offset_value >= 0);
-  const type_tree* base_type = type;
-  // Update base_type in element_type
-  assert(contains_key(Type, base_type->value));
-  assert(!get(Type, base_type->value).name.empty());
-  const type_info& info = get(Type, base_type->value);
-  assert(info.kind == CONTAINER);
-  if (offset_value >= SIZE(info.elements)) return reagent();  // error handled elsewhere
-  reagent/*copy*/ element = info.elements.at(offset_value);
-  // End element_type Special-cases
-  return element;
-}
-
-void test_get_handles_nested_container_elements() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  15:num <- get 12:point-number/raw, 1:offset\n"  // unsafe
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 36 in location 15\n"
-  );
-}
-
-void test_get_out_of_bounds() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  get 12:point-number/raw, 2:offset\n"  // point-number occupies 3 locations but has only 2 fields; out of bounds
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid offset '2' for 'point-number'\n"
-  );
-}
-
-void test_get_out_of_bounds_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  get 12:point-number/raw, -1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid offset '-1' for 'point-number'\n"
-  );
-}
-
-void test_get_product_type_mismatch() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  15:&:num <- get 12:point-number/raw, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'get 12:point-number/raw, 1:offset' should write to number but '15' has type (address number)\n"
-  );
-}
-
-//: we might want to call 'get' without saving the results, say in a sandbox
-
-void test_get_without_product() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  get 12:point/raw, 1:offset\n"  // unsafe
-      "]\n"
-  );
-  // just don't die
-}
-
-//:: To write to elements of containers, use 'put'.
-
-void test_put() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  $clear-trace\n"
-      "  12:point <- put 12:point, 1:offset, 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 36 in location 13"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 34 in location 12");
-}
-
-:(before "End Primitive Recipe Declarations")
-PUT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "put", PUT);
-:(before "End Primitive Recipe Checks")
-case PUT: {
-  if (SIZE(inst.ingredients) != 3) {
-    raise << maybe(get(Recipe, r).name) << "'put' expects exactly 3 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);
-  // Update PUT base in Check
-  if (!base.type) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = base.type;
-  // Update PUT base_type in Check
-  if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != CONTAINER) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ offset = inst.ingredients.at(1);
-  // Update PUT offset in Check
-  if (!is_literal(offset) || !is_mu_scalar(offset)) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'put' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  int offset_value = 0;
-  //: later layers will permit non-integer offsets
-  if (is_integer(offset.name)) {
-    offset_value = to_integer(offset.name);
-    if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) {
-      raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end();
-      break;
-    }
-  }
-  else {
-    offset_value = offset.value;
-  }
-  const reagent& value = inst.ingredients.at(2);
-  //: use base.type rather than base_type because later layers will introduce compound types
-  const reagent& element = element_type(base.type, offset_value);
-  if (!types_coercible(element, value)) {
-    raise << maybe(get(Recipe, r).name) << "'put " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end();
-    break;
-  }
-  if (inst.products.empty()) break;  // no more checks necessary
-  if (inst.products.at(0).name != inst.ingredients.at(0).name) {
-    raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  // End PUT Product Checks
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case PUT: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  // Update PUT base in Run
-  int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = base.type;
-  // Update PUT base_type in Run
-  int offset = ingredients.at(1).at(0);
-  if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break;  // copied from Check above
-  int address = base_address;
-  for (int i = 0; i < offset; ++i)
-    address += size_of(element_type(base.type, i));
-  trace(Callstack_depth+1, "run") << "address to copy to is " << address << end();
-  // optimization: directly write the element rather than updating 'product'
-  // and writing the entire container
-  // Write Memory in PUT in Run
-  write_products = false;
-  for (int i = 0;  i < SIZE(ingredients.at(2));  ++i) {
-    trace(Callstack_depth+1, "mem") << "storing " << no_scientific(ingredients.at(2).at(i)) << " in location " << address+i << end();
-    put(Memory, address+i, ingredients.at(2).at(i));
-  }
-  break;
-}
-
-:(code)
-void test_put_product_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  1:point <- merge 34, 35\n"
-      "  3:point <- put 1:point, x:offset, 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'put' must be first ingredient '1:point', but got '3:point'\n"
-  );
-}
-
-//:: Allow containers to be defined in Mu code.
-
-void test_container() {
-  load(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: --- defining container foo\n"
-      "parse: element: {x: \"number\"}\n"
-      "parse: element: {y: \"number\"}\n"
-  );
-}
-
-void test_container_use_before_definition() {
-  load(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: --- defining container foo\n"
-      "parse: type number: 1000\n"
-      "parse:   element: {x: \"number\"}\n"
-      // todo: brittle
-      // type bar is unknown at this point, but we assign it a number
-      "parse:   element: {y: \"bar\"}\n"
-      // later type bar gets a definition
-      "parse: --- defining container bar\n"
-      "parse: type number: 1001\n"
-      "parse:   element: {x: \"number\"}\n"
-      "parse:   element: {y: \"number\"}\n"
-  );
-}
-
-//: if a container is defined again, the new fields add to the original definition
-void test_container_extend() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "]\n"
-      "container foo [\n"  // add to previous definition
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 35\n"
-      "  3:num <- get 1:foo, 0:offset\n"
-      "  4:num <- get 1:foo, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 3\n"
-      "mem: storing 35 in location 4\n"
-  );
-}
-
-:(before "End Command Handlers")
-else if (command == "container") {
-  insert_container(command, CONTAINER, in);
-}
-
-//: Even though we allow containers to be extended, we don't allow this after
-//: a call to transform_all. But we do want to detect this situation and raise
-//: an error. This field will help us raise such errors.
-:(before "End type_info Fields")
-int Num_calls_to_transform_all_at_first_definition;
-:(before "End type_info Constructor")
-Num_calls_to_transform_all_at_first_definition = -1;
-
-:(code)
-void insert_container(const string& command, kind_of_type kind, istream& in) {
-  skip_whitespace_but_not_newline(in);
-  string name = next_word(in);
-  if (name.empty()) {
-    assert(!has_data(in));
-    raise << "incomplete container definition at end of file (0)\n" << end();
-    return;
-  }
-  // End container Name Refinements
-  trace(101, "parse") << "--- defining " << command << ' ' << name << end();
-  if (!contains_key(Type_ordinal, name)
-      || get(Type_ordinal, name) == 0) {
-    put(Type_ordinal, name, Next_type_ordinal++);
-  }
-  trace(102, "parse") << "type number: " << get(Type_ordinal, name) << end();
-  skip_bracket(in, "'"+command+"' must begin with '['");
-  type_info& info = get_or_insert(Type, get(Type_ordinal, name));
-  if (info.Num_calls_to_transform_all_at_first_definition == -1) {
-    // initial definition of this container
-    info.Num_calls_to_transform_all_at_first_definition = Num_calls_to_transform_all;
-  }
-  else if (info.Num_calls_to_transform_all_at_first_definition != Num_calls_to_transform_all) {
-    // extension after transform_all
-    raise << "there was a call to transform_all() between the definition of container '" << name << "' and a subsequent extension. This is not supported, since any recipes that used '" << name << "' values have already been transformed and \"frozen\".\n" << end();
-    return;
-  }
-  info.name = name;
-  info.kind = kind;
-  while (has_data(in)) {
-    skip_whitespace_and_comments(in);
-    string element = next_word(in);
-    if (element.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete container definition at end of file (1)\n" << end();
-      return;
-    }
-    if (element == "]") break;
-    if (in.peek() != '\n') {
-      raise << command << " '" << name << "' contains multiple elements on a single line. Containers and exclusive containers must only contain elements, one to a line, no code.\n" << end();
-      // skip rest of container declaration
-      while (has_data(in)) {
-        skip_whitespace_and_comments(in);
-        if (next_word(in) == "]") break;
-      }
-      break;
-    }
-    info.elements.push_back(reagent(element));
-    expand_type_abbreviations(info.elements.back().type);  // todo: use abbreviation before declaration
-    replace_unknown_types_with_unique_ordinals(info.elements.back().type, info);
-    trace(103, "parse") << "  element: " << to_string(info.elements.back()) << end();
-    // End Load Container Element Definition
-  }
-}
-
-void replace_unknown_types_with_unique_ordinals(type_tree* type, const type_info& info) {
-  if (!type) return;
-  if (!type->atom) {
-    replace_unknown_types_with_unique_ordinals(type->left, info);
-    replace_unknown_types_with_unique_ordinals(type->right, info);
-    return;
-  }
-  assert(!type->name.empty());
-  if (contains_key(Type_ordinal, type->name)) {
-    type->value = get(Type_ordinal, type->name);
-  }
-  // End insert_container Special-cases
-  else if (type->name != "->") {  // used in recipe types
-    put(Type_ordinal, type->name, Next_type_ordinal++);
-    type->value = get(Type_ordinal, type->name);
-  }
-}
-
-void skip_bracket(istream& in, string message) {
-  skip_whitespace_and_comments(in);
-  if (in.get() != '[')
-    raise << message << '\n' << end();
-}
-
-void test_multi_word_line_in_container_declaration() {
-  Hide_errors = true;
-  run(
-      "container foo [\n"
-      "  x:num y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: container 'foo' contains multiple elements on a single line. Containers and exclusive containers must only contain elements, one to a line, no code.\n"
-  );
-}
-
-//: support type abbreviations in container definitions
-
-void test_type_abbreviations_in_containers() {
-  run(
-      "type foo = number\n"
-      "container bar [\n"
-      "  x:foo\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:foo <- get 1:bar/unsafe, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 2\n"
-  );
-}
-
-:(after "Transform.push_back(expand_type_abbreviations)")
-Transform.push_back(expand_type_abbreviations_in_containers);  // idempotent
-:(code)
-// extremely inefficient; we process all types over and over again, once for every single recipe
-// but it doesn't seem to cause any noticeable slowdown
-void expand_type_abbreviations_in_containers(const recipe_ordinal /*unused*/) {
-  for (map<type_ordinal, type_info>::iterator p = Type.begin();  p != Type.end();  ++p) {
-    for (int i = 0;  i < SIZE(p->second.elements);  ++i)
-      expand_type_abbreviations(p->second.elements.at(i).type);
-  }
-}
-
-//: ensure scenarios are consistent by always starting new container
-//: declarations at the same type number
-:(before "End Reset")  //: for tests
-Next_type_ordinal = 1000;
-:(before "End Test Run Initialization")
-assert(Next_type_ordinal < 1000);
-
-:(code)
-void test_error_on_transform_all_between_container_definition_and_extension() {
-  // define a container
-  run("container foo [\n"
-      "  a:num\n"
-      "]\n");
-  // try to extend the container after transform
-  transform_all();
-  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
-  Hide_errors = true;
-  run("container foo [\n"
-      "  b:num\n"
-      "]\n");
-  CHECK_TRACE_CONTAINS_ERRORS();
-}
-
-//:: Allow container definitions anywhere in the codebase, but complain if you
-//:: can't find a definition at the end.
-
-void test_run_complains_on_unknown_types() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:integer <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: unknown type integer in '1:integer <- copy 0'\n"
-  );
-}
-
-void test_run_allows_type_definition_after_use() {
-  run(
-      "def main [\n"
-      "  1:bar <- copy 0/unsafe\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End Type Modifying Transforms")
-Transform.push_back(check_or_set_invalid_types);  // idempotent
-
-:(code)
-void check_or_set_invalid_types(const recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- check for invalid types in recipe " << caller.name << end();
-  for (int index = 0;  index < SIZE(caller.steps);  ++index) {
-    instruction& inst = caller.steps.at(index);
-    for (int i = 0;  i < SIZE(inst.ingredients);  ++i)
-      check_or_set_invalid_types(inst.ingredients.at(i), caller, inst);
-    for (int i = 0;  i < SIZE(inst.products);  ++i)
-      check_or_set_invalid_types(inst.products.at(i), caller, inst);
-  }
-  // End check_or_set_invalid_types
-}
-
-void check_or_set_invalid_types(reagent& r, const recipe& caller, const instruction& inst) {
-  // Begin check_or_set_invalid_types(r)
-  check_or_set_invalid_types(r.type, maybe(caller.name), "'"+to_original_string(inst)+"'");
-}
-
-void check_or_set_invalid_types(type_tree* type, const string& location_for_error_messages, const string& name_for_error_messages) {
-  if (!type) return;
-  // End Container Type Checks
-  if (!type->atom) {
-    check_or_set_invalid_types(type->left, location_for_error_messages, name_for_error_messages);
-    check_or_set_invalid_types(type->right, location_for_error_messages, name_for_error_messages);
-    return;
-  }
-  if (type->value == 0) return;
-  if (!contains_key(Type, type->value)) {
-    assert(!type->name.empty());
-    if (contains_key(Type_ordinal, type->name))
-      type->value = get(Type_ordinal, type->name);
-    else
-      raise << location_for_error_messages << "unknown type " << type->name << " in " << name_for_error_messages << '\n' << end();
-  }
-}
-
-void test_container_unknown_field() {
-  Hide_errors = true;
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: unknown type in y\n"
-  );
-}
-
-void test_read_container_with_bracket_in_comment() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  # ']' in comment\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: --- defining container foo\n"
-      "parse: element: {x: \"number\"}\n"
-      "parse: element: {y: \"number\"}\n"
-  );
-}
-void test_container_with_compound_field_type() {
-  run(
-      "container foo [\n"
-      "  {x: (address array (address array character))}\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End transform_all")
-check_container_field_types();
-
-:(code)
-void check_container_field_types() {
-  for (map<type_ordinal, type_info>::iterator p = Type.begin();  p != Type.end();  ++p) {
-    const type_info& info = p->second;
-    // Check Container Field Types(info)
-    for (int i = 0;  i < SIZE(info.elements);  ++i)
-      check_invalid_types(info.elements.at(i).type, maybe(info.name), info.elements.at(i).name);
-  }
-}
-
-void check_invalid_types(const type_tree* type, const string& location_for_error_messages, const string& name_for_error_messages) {
-  if (!type) return;  // will throw a more precise error elsewhere
-  if (!type->atom) {
-    check_invalid_types(type->left, location_for_error_messages, name_for_error_messages);
-    check_invalid_types(type->right, location_for_error_messages, name_for_error_messages);
-    return;
-  }
-  if (type->value != 0) {  // value 0 = compound types (layer parse_tree) or type ingredients (layer shape_shifting_container)
-    if (!contains_key(Type, type->value))
-      raise << location_for_error_messages << "unknown type in " << name_for_error_messages << '\n' << end();
-  }
-}
-
-string to_original_string(const type_ordinal t) {
-  ostringstream out;
-  if (!contains_key(Type, t)) return out.str();
-  const type_info& info = get(Type, t);
-  if (info.kind == PRIMITIVE) return out.str();
-  out << (info.kind == CONTAINER ? "container" : "exclusive-container") << " " << info.name << " [\n";
-  for (int i = 0;  i < SIZE(info.elements);  ++i) {
-    out << "  " << info.elements.at(i).original_string << "\n";
-  }
-  out << "]\n";
-  return out.str();
-}
diff --git a/archive/2.vm/031merge.cc b/archive/2.vm/031merge.cc
deleted file mode 100644
index ace4387b..00000000
--- a/archive/2.vm/031merge.cc
+++ /dev/null
@@ -1,270 +0,0 @@
-//: Construct types out of their constituent fields.
-
-void test_merge() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 3, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 1\n"
-      "mem: storing 4 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-MERGE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "merge", MERGE);
-:(before "End Primitive Recipe Checks")
-case MERGE: {
-  // type-checking in a separate transform below
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MERGE: {
-  products.resize(1);
-  for (int i = 0;  i < SIZE(ingredients);  ++i)
-    for (int j = 0;  j < SIZE(ingredients.at(i));  ++j)
-      products.at(0).push_back(ingredients.at(i).at(j));
-  break;
-}
-
-//: type-check 'merge' to avoid interpreting numbers as addresses
-
-:(code)
-void test_merge_check() {
-  run(
-      "def main [\n"
-      "  1:point <- merge 3, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_missing_element() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point <- merge 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too few ingredients in '1:point <- merge 3'\n"
-  );
-}
-
-void test_merge_check_extra_element() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point <- merge 3, 4, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too many ingredients in '1:point <- merge 3, 4, 5'\n"
-  );
-}
-
-//: We want to avoid causing memory corruption, but other than that we want to
-//: be flexible in how we construct containers of containers. It should be
-//: equally easy to define a container out of primitives or intermediate
-//: container fields.
-
-void test_merge_check_recursive_containers() {
-  run(
-      "def main [\n"
-      "  1:point <- merge 3, 4\n"
-      "  1:point-number <- merge 1:point, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_recursive_containers_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point <- merge 3, 4\n"
-      "  2:point-number <- merge 1:point\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too few ingredients in '2:point-number <- merge 1:point'\n"
-  );
-}
-
-void test_merge_check_recursive_containers_3() {
-  run(
-      "def main [\n"
-      "  1:point-number <- merge 3, 4, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_recursive_containers_4() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point-number <- merge 3, 4\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too few ingredients in '1:point-number <- merge 3, 4'\n"
-  );
-}
-
-void test_merge_check_reflexive() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point <- merge 3, 4\n"
-      "  2:point <- merge 1:point\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: Since a container can be merged in several ways, we need to be able to
-//: backtrack through different possibilities. Later we'll allow creating
-//: exclusive containers which contain just one of rather than all of their
-//: elements. That will also require backtracking capabilities. Here's the
-//: state we need to maintain for backtracking:
-
-:(before "End Types")
-struct merge_check_point {
-  reagent container;
-  int container_element_index;
-  merge_check_point(const reagent& c, int i) :container(c), container_element_index(i) {}
-};
-
-struct merge_check_state {
-  stack<merge_check_point> data;
-};
-
-:(before "End Checks")
-Transform.push_back(check_merge_calls);  // idempotent
-:(code)
-void check_merge_calls(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- type-check merge instructions in recipe " << caller.name << end();
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    if (inst.name != "merge") continue;
-    if (SIZE(inst.products) != 1) {
-      raise << maybe(caller.name) << "'merge' should yield a single product in '" << to_original_string(inst) << "'\n" << end();
-      continue;
-    }
-    reagent/*copy*/ product = inst.products.at(0);
-    // Update product While Type-checking Merge
-    const type_tree* product_base_type = product.type->atom ? product.type : product.type->left;
-    assert(product_base_type->atom);
-    if (product_base_type->value == 0 || !contains_key(Type, product_base_type->value)) {
-      raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
-      continue;
-    }
-    const type_info& info = get(Type, product_base_type->value);
-    if (info.kind != CONTAINER && info.kind != EXCLUSIVE_CONTAINER) {
-      raise << maybe(caller.name) << "'merge' should yield a container in '" << to_original_string(inst) << "'\n" << end();
-      continue;
-    }
-    check_merge_call(inst.ingredients, product, caller, inst);
-  }
-}
-
-void check_merge_call(const vector<reagent>& ingredients, const reagent& product, const recipe& caller, const instruction& inst) {
-  int ingredient_index = 0;
-  merge_check_state state;
-  state.data.push(merge_check_point(product, 0));
-  while (true) {
-    assert(!state.data.empty());
-    trace(102, "transform") << ingredient_index << " vs " << SIZE(ingredients) << end();
-    if (ingredient_index >= SIZE(ingredients)) {
-      raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(inst) << "'\n" << end();
-      return;
-    }
-    reagent& container = state.data.top().container;
-    if (!container.type) return;  // error handled elsewhere
-    const type_tree* top_root_type = container.type->atom ? container.type : container.type->left;
-    assert(top_root_type->atom);
-    type_info& container_info = get(Type, top_root_type->value);
-    switch (container_info.kind) {
-      case CONTAINER: {
-        // degenerate case: merge with the same type always succeeds
-        if (state.data.top().container_element_index == 0 && types_coercible(container, inst.ingredients.at(ingredient_index)))
-          return;
-        const reagent& expected_ingredient = element_type(container.type, state.data.top().container_element_index);
-        trace(102, "transform") << "checking container " << to_string(container) << " || " << to_string(expected_ingredient) << " vs ingredient " << ingredient_index << end();
-        // if the current element is the ingredient we expect, move on to the next element/ingredient
-        if (types_coercible(expected_ingredient, ingredients.at(ingredient_index))) {
-          ++ingredient_index;
-          ++state.data.top().container_element_index;
-          while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements)) {
-            state.data.pop();
-            if (state.data.empty()) {
-              if (ingredient_index < SIZE(ingredients))
-                raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
-              return;
-            }
-            ++state.data.top().container_element_index;
-          }
-        }
-        // if not, maybe it's a field of the current element
-        else {
-          // no change to ingredient_index
-          state.data.push(merge_check_point(expected_ingredient, 0));
-        }
-        break;
-      }
-      // End check_merge_call Special-cases
-      default: {
-        if (!types_coercible(container, ingredients.at(ingredient_index))) {
-          raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << to_original_string(inst) << "'\n" << end();
-          raise << "  (expected '" << debug_string(container) << "')\n" << end();
-          raise << "  (got '" << debug_string(ingredients.at(ingredient_index)) << "')\n" << end();
-          return;
-        }
-        ++ingredient_index;
-        // ++state.data.top().container_element_index;  // unnecessary, but wouldn't do any harm
-        do {
-          state.data.pop();
-          if (state.data.empty()) {
-            if (ingredient_index < SIZE(ingredients))
-              raise << maybe(caller.name) << "too many ingredients in '" << to_original_string(inst) << "'\n" << end();
-            return;
-          }
-          ++state.data.top().container_element_index;
-        } while (state.data.top().container_element_index >= SIZE(get(Type, get_base_type(state.data.top().container.type)->value).elements));
-      }
-    }
-  }
-  // never gets here
-  assert(false);
-}
-
-//: replaced in a later layer
-//: todo: find some clean way to take this call completely out of this layer
-const type_tree* get_base_type(const type_tree* t) {
-  return t;
-}
-
-void test_merge_check_product() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- merge 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'merge' should yield a container in '1:num <- merge 3'\n"
-  );
-}
-
-:(before "End Includes")
-#include <stack>
-using std::stack;
diff --git a/archive/2.vm/032array.cc b/archive/2.vm/032array.cc
deleted file mode 100644
index 30adde20..00000000
--- a/archive/2.vm/032array.cc
+++ /dev/null
@@ -1,635 +0,0 @@
-//: Arrays contain a variable number of elements of the same type. Their value
-//: starts with the length of the array.
-//:
-//: You can create arrays of containers, but containers can only contain
-//: elements of a fixed size, so you can't create containers containing arrays.
-//: Create containers containing addresses to arrays instead.
-
-//: You can create arrays using 'create-array'.
-void test_create_array() {
-  run(
-      "def main [\n"
-      // create an array occupying locations 1 (for the size) and 2-4 (for the elements)
-      "  1:array:num:3 <- create-array\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: creating array from 4 locations\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-CREATE_ARRAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "create-array", CREATE_ARRAY);
-:(before "End Primitive Recipe Checks")
-case CREATE_ARRAY: {
-  if (inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'create-array' needs one product and no ingredients but got '" << to_original_string(inst) << '\n' << end();
-    break;
-  }
-  reagent/*copy*/ product = inst.products.at(0);
-  // Update CREATE_ARRAY product in Check
-  if (!is_mu_array(product)) {
-    raise << maybe(get(Recipe, r).name) << "'create-array' cannot create non-array '" << product.original_string << "'\n" << end();
-    break;
-  }
-  if (!product.type->right) {
-    raise << maybe(get(Recipe, r).name) << "create array of what? '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  // 'create-array' will need to check properties rather than types
-  type_tree* array_length_from_type = product.type->right->right;
-  if (!array_length_from_type) {
-    raise << maybe(get(Recipe, r).name) << "create array of what size? '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!product.type->right->right->atom)
-    array_length_from_type = array_length_from_type->left;
-  if (!is_integer(array_length_from_type->name)) {
-    raise << maybe(get(Recipe, r).name) << "'create-array' product should specify size of array after its element type, but got '" << product.type->right->right->name << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CREATE_ARRAY: {
-  reagent/*copy*/ product = current_instruction().products.at(0);
-  // Update CREATE_ARRAY product in Run
-  int base_address = product.value;
-  type_tree* array_length_from_type = product.type->right->right;
-  if (!product.type->right->right->atom)
-    array_length_from_type = array_length_from_type->left;
-  int array_length = to_integer(array_length_from_type->name);
-  // initialize array length, so that size_of will work
-  trace(Callstack_depth+1, "mem") << "storing " << array_length << " in location " << base_address << end();
-  put(Memory, base_address, array_length);  // in array elements
-  int size = size_of(product);  // in locations
-  trace(Callstack_depth+1, "run") << "creating array from " << size << " locations" << end();
-  // initialize array
-  for (int i = 1;  i <= size_of(product);  ++i)
-    put(Memory, base_address+i, 0);
-  // no need to update product
-  write_products = false;
-  break;
-}
-
-:(code)
-// Arrays can be copied around with a single instruction just like numbers,
-// no matter how large they are.
-// You don't need to pass the size around, since each array variable stores its
-// size in memory at run-time. We'll call a variable with an explicit size a
-// 'static' array, and one without a 'dynamic' array since it can contain
-// arrays of many different sizes.
-void test_copy_array() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  2:num <- copy 14\n"
-      "  3:num <- copy 15\n"
-      "  4:num <- copy 16\n"
-      "  5:array:num <- copy 1:array:num:3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 5\n"
-      "mem: storing 14 in location 6\n"
-      "mem: storing 15 in location 7\n"
-      "mem: storing 16 in location 8\n"
-  );
-}
-
-void test_stash_array() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  2:num <- copy 14\n"
-      "  3:num <- copy 15\n"
-      "  4:num <- copy 16\n"
-      "  stash [foo:], 1:array:num:3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: 3 14 15 16\n"
-  );
-}
-
-:(before "End types_coercible Special-cases")
-if (is_mu_array(from) && is_mu_array(to))
-  return types_strictly_match(array_element(from.type), array_element(to.type));
-
-:(before "End size_of(reagent r) Special-cases")
-if (!r.type->atom && r.type->left->atom && r.type->left->value == Array_type_ordinal) {
-  if (!r.type->right) {
-    raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end();
-    return 1;
-  }
-  return /*space for length*/1 + array_length(r)*size_of(array_element(r.type));
-}
-
-:(before "End size_of(type) Non-atom Special-cases")
-if (type->left->value == Array_type_ordinal) return static_array_length(type);
-:(code)
-int static_array_length(const type_tree* type) {
-  if (!type->atom && type->right && !type->right->atom && type->right->right && !type->right->right->atom && !type->right->right->right  // exactly 3 types
-      && type->right->right->left && type->right->right->left->atom && is_integer(type->right->right->left->name)) {  // third 'type' is a number
-    // get size from type
-    return to_integer(type->right->right->left->name);
-  }
-  cerr << to_string(type) << '\n';
-  assert(false);
-}
-
-//: disable the size mismatch check for arrays since the destination array
-//: need not be initialized
-:(before "End size_mismatch(x) Special-cases")
-if (x.type && !x.type->atom && x.type->left->value == Array_type_ordinal) return false;
-
-//:: arrays inside containers
-//: arrays are disallowed inside containers unless their length is fixed in
-//: advance
-
-:(code)
-void test_container_permits_static_array_element() {
-  run(
-      "container foo [\n"
-      "  x:array:num:3\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End insert_container Special-cases")
-else if (is_integer(type->name)) {  // sometimes types will contain non-type tags, like numbers for the size of an array
-  type->value = 0;
-}
-
-:(code)
-void test_container_disallows_dynamic_array_element() {
-  Hide_errors = true;
-  run(
-      "container foo [\n"
-      "  x:array:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: container 'foo' cannot determine size of element 'x'\n"
-  );
-}
-
-:(before "End Load Container Element Definition")
-{
-  const type_tree* type = info.elements.back().type;
-  if (type && type->atom && type->name == "array") {
-    raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end();
-    continue;
-  }
-  if (type && !type->atom && type->left->atom && type->left->name == "array") {
-    if (!type->right) {
-      raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end();
-      continue;
-    }
-    if (!type->right->right || !is_integer(type->right->right->left->name)) {  // array has no length
-      raise << "container '" << name << "' cannot determine size of element '" << info.elements.back().name << "'\n" << end();
-      continue;
-    }
-  }
-}
-
-//: disable the size mismatch check for 'merge' instructions since containers
-//: can contain arrays, and since we already do plenty of checking for them
-:(before "End size_mismatch(x) Special-cases")
-if (current_call().running_step_index < SIZE(get(Recipe, current_call().running_recipe).steps)
-    && current_instruction().operation == MERGE) {
-  return false;
-}
-
-:(code)
-void test_merge_static_array_into_container() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:array:num:3\n"
-      "]\n"
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  10:foo <- merge 34, 1:array:num:3\n"
-      "]\n"
-  );
-  // no errors
-}
-
-void test_code_inside_container() {
-  Hide_errors = true;
-  run(
-      "container card [\n"
-      "  rank:num <- next-ingredient\n"
-      "]\n"
-      "def foo [\n"
-      "  1:card <- merge 3\n"
-      "  2:num <- get 1:card rank:offset\n"
-      "]\n"
-  );
-  // shouldn't die
-}
-
-//:: To access elements of an array, use 'index'
-
-void test_index() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  2:num <- copy 14\n"
-      "  3:num <- copy 15\n"
-      "  4:num <- copy 16\n"
-      "  10:num <- index 1:array:num:3, 0/index\n"  // the index must be a non-negative whole number
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 10\n"
-  );
-}
-
-void test_index_compound_element() {
-  run(
-      "def main [\n"
-      "  {1: (array (address number) 3)} <- create-array\n"
-      // skip alloc id
-      "  3:num <- copy 14\n"
-      // skip alloc id
-      "  5:num <- copy 15\n"
-      // skip alloc id
-      "  7:num <- copy 16\n"
-      "  10:address:num <- index {1: (array (address number) 3)}, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // skip alloc id
-      "mem: storing 14 in location 11\n"
-  );
-}
-
-void test_index_direct_offset() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  2:num <- copy 14\n"
-      "  3:num <- copy 15\n"
-      "  4:num <- copy 16\n"
-      "  10:num <- copy 0\n"
-      "  20:num <- index 1:array:num, 10:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 20\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-INDEX,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "index", INDEX);
-:(before "End Primitive Recipe Checks")
-case INDEX: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'index' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);
-  // Update INDEX base in Check
-  if (!is_mu_array(base)) {
-    raise << maybe(get(Recipe, r).name) << "'index' on a non-array '" << base.original_string << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ index = inst.ingredients.at(1);
-  // Update INDEX index in Check
-  if (!is_mu_number(index)) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'index' should be a number, but got '" << index.original_string << "'\n" << end();
-    break;
-  }
-  if (inst.products.empty()) break;
-  reagent/*copy*/ product = inst.products.at(0);
-  // Update INDEX product in Check
-  reagent/*local*/ element(copy_array_element(base.type));
-  if (!types_coercible(product, element)) {
-    raise << maybe(get(Recipe, r).name) << "'index' on '" << base.original_string << "' can't be saved in '" << product.original_string << "'; type should be '" << names_to_string_without_quotes(element.type) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case INDEX: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  // Update INDEX base in Run
-  int base_address = base.value;
-  trace(Callstack_depth+1, "run") << "base address is " << base_address << end();
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ index = current_instruction().ingredients.at(1);
-  // Update INDEX index in Run
-  vector<double> index_val(read_memory(index));
-  if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) {
-    raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  reagent/*local*/ element(copy_array_element(base.type));
-  element.set_value(base_address + /*skip length*/1 + index_val.at(0)*size_of(element.type));
-  trace(Callstack_depth+1, "run") << "address to copy is " << element.value << end();
-  trace(Callstack_depth+1, "run") << "its type is " << to_string(element.type) << end();
-  // Read element
-  products.push_back(read_memory(element));
-  break;
-}
-
-:(code)
-type_tree* copy_array_element(const type_tree* type) {
-  return new type_tree(*array_element(type));
-}
-
-type_tree* array_element(const type_tree* type) {
-  assert(type->right);
-  if (type->right->atom) {
-    return type->right;
-  }
-  else if (!type->right->right) {
-    return type->right->left;
-  }
-  // hack: support array:num:3 without requiring extra parens
-  else if (type->right->right->left && type->right->right->left->atom && is_integer(type->right->right->left->name)) {
-    assert(!type->right->right->right);
-    return type->right->left;
-  }
-  return type->right;
-}
-
-int array_length(const reagent& x) {
-  // x should already be canonized.
-  // hack: look for length in type
-  if (!x.type->atom && x.type->right && !x.type->right->atom && x.type->right->right && !x.type->right->right->atom && !x.type->right->right->right  // exactly 3 types
-      && x.type->right->right->left && x.type->right->right->left->atom && is_integer(x.type->right->right->left->name)) {  // third 'type' is a number
-    // get size from type
-    return to_integer(x.type->right->right->left->name);
-  }
-  // this should never happen at transform time
-  return get_or_insert(Memory, x.value);
-}
-
-:(before "End Unit Tests")
-void test_array_length_compound() {
-  put(Memory, 1, 3);
-  put(Memory, 2, 14);
-  put(Memory, 3, 15);
-  put(Memory, 4, 16);
-  reagent x("1:array:address:num");  // 3 types, but not a static array
-  populate_value(x);
-  CHECK_EQ(array_length(x), 3);
-}
-
-void test_array_length_static() {
-  reagent x("1:array:num:3");
-  CHECK_EQ(array_length(x), 3);
-}
-
-void test_index_truncates() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  2:num <- copy 14\n"
-      "  3:num <- copy 15\n"
-      "  4:num <- copy 16\n"
-      "  10:num <- index 1:array:num:3, 1.5\n"  // non-whole number
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // fraction is truncated away
-      "mem: storing 15 in location 10\n"
-  );
-}
-
-void test_index_out_of_bounds() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:point:3 <- create-array\n"
-      "  index 1:array:point:3, 4\n"  // less than size of array in locations, but larger than its length in elements
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid index 4 in 'index 1:array:point:3, 4'\n"
-  );
-}
-
-void test_index_out_of_bounds_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  index 1:array:num, -1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid index -1 in 'index 1:array:num, -1'\n"
-  );
-}
-
-void test_index_product_type_mismatch() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:point:3 <- create-array\n"
-      "  10:num <- index 1:array:point, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'index' on '1:array:point' can't be saved in '10:num'; type should be 'point'\n"
-  );
-}
-
-//: we might want to call 'index' without saving the results, say in a sandbox
-
-void test_index_without_product() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  index 1:array:num:3, 0\n"
-      "]\n"
-  );
-  // just don't die
-}
-
-//:: To write to elements of arrays, use 'put'.
-
-void test_put_index() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  1:array:num <- put-index 1:array:num, 1, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 3\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-PUT_INDEX,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "put-index", PUT_INDEX);
-:(before "End Primitive Recipe Checks")
-case PUT_INDEX: {
-  if (SIZE(inst.ingredients) != 3) {
-    raise << maybe(get(Recipe, r).name) << "'put-index' expects exactly 3 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);
-  // Update PUT_INDEX base in Check
-  if (!is_mu_array(base)) {
-    raise << maybe(get(Recipe, r).name) << "'put-index' on a non-array '" << base.original_string << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ index = inst.ingredients.at(1);
-  // Update PUT_INDEX index in Check
-  if (!is_mu_number(index)) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'put-index' should have type 'number', but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ value = inst.ingredients.at(2);
-  // Update PUT_INDEX value in Check
-  reagent/*local*/ element(copy_array_element(base.type));
-  if (!types_coercible(element, value)) {
-    raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end();
-    break;
-  }
-  if (inst.products.empty()) break;  // no more checks necessary
-  if (inst.products.at(0).name != inst.ingredients.at(0).name) {
-    raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  // End PUT_INDEX Product Checks
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case PUT_INDEX: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  // Update PUT_INDEX base in Run
-  int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ index = current_instruction().ingredients.at(1);
-  // Update PUT_INDEX index in Run
-  vector<double> index_val(read_memory(index));
-  if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) {
-    raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  int address = base_address + /*skip length*/1 + index_val.at(0)*size_of(array_element(base.type));
-  trace(Callstack_depth+1, "run") << "address to copy to is " << address << end();
-  // optimization: directly write the element rather than updating 'product'
-  // and writing the entire array
-  write_products = false;
-  vector<double> value = read_memory(current_instruction().ingredients.at(2));
-  // Write Memory in PUT_INDEX in Run
-  for (int i = 0;  i < SIZE(value);  ++i) {
-    trace(Callstack_depth+1, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end();
-    put(Memory, address+i, value.at(i));
-  }
-  break;
-}
-
-:(code)
-void test_put_index_out_of_bounds() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:point:3 <- create-array\n"
-      "  8:point <- merge 34, 35\n"
-      "  1:array:point <- put-index 1:array:point, 4, 8:point\n"  // '4' is less than size of array in locations, but larger than its length in elements
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid index 4 in '1:array:point <- put-index 1:array:point, 4, 8:point'\n"
-  );
-}
-
-void test_put_index_out_of_bounds_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:point:3 <- create-array\n"
-      "  10:point <- merge 34, 35\n"
-      "  1:array:point <- put-index 1:array:point, -1, 10:point\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid index -1 in '1:array:point <- put-index 1:array:point, -1, 10:point'\n"
-  );
-}
-
-void test_put_index_product_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  4:array:num:3 <- put-index 1:array:num:3, 0, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'put-index' must be first ingredient '1:array:num:3', but got '4:array:num:3'\n"
-  );
-}
-
-//:: compute the length of an array
-
-void test_array_length() {
-  run(
-      "def main [\n"
-      "  1:array:num:3 <- create-array\n"
-      "  10:num <- length 1:array:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 10\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-LENGTH,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "length", LENGTH);
-:(before "End Primitive Recipe Checks")
-case LENGTH: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'length' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ array = inst.ingredients.at(0);
-  // Update LENGTH array in Check
-  if (!is_mu_array(array)) {
-    raise << "tried to calculate length of non-array '" << array.original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case LENGTH: {
-  reagent/*copy*/ array = current_instruction().ingredients.at(0);
-  // Update LENGTH array in Run
-  if (array.value == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  products.resize(1);
-  products.at(0).push_back(get_or_insert(Memory, array.value));
-  break;
-}
-
-//: optimization: none of the instructions in this layer use 'ingredients' so
-//: stop copying potentially huge arrays into it.
-:(before "End should_copy_ingredients Special-cases")
-recipe_ordinal r = current_instruction().operation;
-if (r == CREATE_ARRAY || r == INDEX || r == PUT_INDEX || r == LENGTH)
-  return false;
diff --git a/archive/2.vm/033exclusive_container.cc b/archive/2.vm/033exclusive_container.cc
deleted file mode 100644
index fc944f8d..00000000
--- a/archive/2.vm/033exclusive_container.cc
+++ /dev/null
@@ -1,554 +0,0 @@
-//: Exclusive containers contain exactly one of a fixed number of 'variants'
-//: of different types.
-//:
-//: They also implicitly contain a tag describing precisely which variant is
-//: currently stored in them.
-
-:(before "End Mu Types Initialization")
-//: We'll use this container as a running example, with two number elements.
-{
-type_ordinal tmp = put(Type_ordinal, "number-or-point", Next_type_ordinal++);
-get_or_insert(Type, tmp);  // initialize
-get(Type, tmp).kind = EXCLUSIVE_CONTAINER;
-get(Type, tmp).name = "number-or-point";
-get(Type, tmp).elements.push_back(reagent("i:number"));
-get(Type, tmp).elements.push_back(reagent("p:point"));
-}
-
-//: Tests in this layer often explicitly set up memory before reading it as a
-//: container. Don't do this in general. I'm tagging such cases with /unsafe;
-//: they'll be exceptions to later checks.
-
-:(code)
-void test_copy_exclusive_container() {
-  run(
-      // Copying exclusive containers copies all their contents, and an extra
-      // location for the tag.
-      "def main [\n"
-      "  1:num <- copy 1\n"  // 'point' variant
-      "  2:num <- copy 34\n"
-      "  3:num <- copy 35\n"
-      "  4:number-or-point <- copy 1:number-or-point/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 4\n"
-      "mem: storing 34 in location 5\n"
-      "mem: storing 35 in location 6\n"
-  );
-}
-
-:(before "End size_of(type) Special-cases")
-if (t.kind == EXCLUSIVE_CONTAINER) {
-  // size of an exclusive container is the size of its largest variant
-  // (So like containers, it can't contain arrays.)
-  int result = 0;
-  for (int i = 0; i < SIZE(t.elements); ++i) {
-    reagent tmp;
-    tmp.type = new type_tree(*type);
-    int size = size_of(variant_type(tmp, i));
-    if (size > result) result = size;
-  }
-  // ...+1 for its tag.
-  return result+1;
-}
-
-//:: To access variants of an exclusive container, use 'maybe-convert'.
-//: It always returns an address (so that you can modify it) or null (to
-//: signal that the conversion failed (because the container contains a
-//: different variant).
-
-//: 'maybe-convert' requires a literal in ingredient 1. We'll use a synonym
-//: called 'variant'.
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "variant", 0);
-
-:(code)
-void test_maybe_convert() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 1\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  20:point, 22:bool <- maybe-convert 12:number-or-point/unsafe, 1:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // boolean
-      "mem: storing 1 in location 22\n"
-      // point
-      "mem: storing 35 in location 20\n"
-      "mem: storing 36 in location 21\n"
-  );
-}
-
-void test_maybe_convert_fail() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 1\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  20:num, 21:bool <- maybe-convert 12:number-or-point/unsafe, 0:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // boolean
-      "mem: storing 0 in location 21\n"
-      // number: no write
-  );
-}
-
-
-:(before "End Primitive Recipe Declarations")
-MAYBE_CONVERT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "maybe-convert", MAYBE_CONVERT);
-:(before "End Primitive Recipe Checks")
-case MAYBE_CONVERT: {
-  const recipe& caller = get(Recipe, r);
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);
-  // Update MAYBE_CONVERT base in Check
-  if (!base.type) {
-    raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = base.type;
-  // Update MAYBE_CONVERT base_type in Check
-  if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != EXCLUSIVE_CONTAINER) {
-    raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal(inst.ingredients.at(1))) {
-    raise << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  if (inst.products.empty()) break;
-  if (SIZE(inst.products) != 2) {
-    raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 products in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ product = inst.products.at(0);
-  // Update MAYBE_CONVERT product in Check
-  reagent& offset = inst.ingredients.at(1);
-  populate_value(offset);
-  if (offset.value >= SIZE(get(Type, base_type->value).elements)) {
-    raise << maybe(caller.name) << "invalid tag " << offset.value << " in '" << to_original_string(inst) << '\n' << end();
-    break;
-  }
-  const reagent& variant = variant_type(base, offset.value);
-  if (!types_coercible(product, variant)) {
-    raise << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but '" << product.name << "' has type " << to_string(product.type) << '\n' << end();
-    break;
-  }
-  reagent/*copy*/ status = inst.products.at(1);
-  // Update MAYBE_CONVERT status in Check
-  if (!is_mu_boolean(status)) {
-    raise << maybe(get(Recipe, r).name) << "second product yielded by 'maybe-convert' should be a boolean, but tried to write to '" << inst.products.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MAYBE_CONVERT: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  // Update MAYBE_CONVERT base in Run
-  int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  int tag = current_instruction().ingredients.at(1).value;
-  reagent/*copy*/ product = current_instruction().products.at(0);
-  // Update MAYBE_CONVERT product in Run
-  reagent/*copy*/ status = current_instruction().products.at(1);
-  // Update MAYBE_CONVERT status in Run
-  // optimization: directly write results to only update first product when necessary
-  write_products = false;
-  if (tag == static_cast<int>(get_or_insert(Memory, base_address))) {
-    const reagent& variant = variant_type(base, tag);
-    trace(Callstack_depth+1, "mem") << "storing 1 in location " << status.value << end();
-    put(Memory, status.value, 1);
-    if (!is_dummy(product)) {
-      // Write Memory in Successful MAYBE_CONVERT in Run
-      for (int i = 0;  i < size_of(variant);  ++i) {
-        double val = get_or_insert(Memory, base_address+/*skip tag*/1+i);
-        trace(Callstack_depth+1, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end();
-        put(Memory, product.value+i, val);
-      }
-    }
-  }
-  else {
-    trace(Callstack_depth+1, "mem") << "storing 0 in location " << status.value << end();
-    put(Memory, status.value, 0);
-  }
-  break;
-}
-
-:(code)
-const reagent variant_type(const reagent& base, int tag) {
-  return variant_type(base.type, tag);
-}
-
-const reagent variant_type(const type_tree* type, int tag) {
-  assert(tag >= 0);
-  const type_tree* root_type = type->atom ? type : type->left;
-  assert(contains_key(Type, root_type->value));
-  assert(!get(Type, root_type->value).name.empty());
-  const type_info& info = get(Type, root_type->value);
-  assert(info.kind == EXCLUSIVE_CONTAINER);
-  reagent/*copy*/ element = info.elements.at(tag);
-  // End variant_type Special-cases
-  return element;
-}
-
-void test_maybe_convert_product_type_mismatch() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 1\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  20:num, 21:bool <- maybe-convert 12:number-or-point/unsafe, 1:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'maybe-convert 12:number-or-point/unsafe, 1:variant' should write to point but '20' has type number\n"
-  );
-}
-
-void test_maybe_convert_dummy_product() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 1\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  _, 21:bool <- maybe-convert 12:number-or-point/unsafe, 1:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//:: Allow exclusive containers to be defined in Mu code.
-
-void test_exclusive_container() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: --- defining exclusive-container foo\n"
-      "parse: element: {x: \"number\"}\n"
-      "parse: element: {y: \"number\"}\n"
-  );
-}
-
-:(before "End Command Handlers")
-else if (command == "exclusive-container") {
-  insert_container(command, EXCLUSIVE_CONTAINER, in);
-}
-
-//: arrays are disallowed inside exclusive containers unless their length is
-//: fixed in advance
-
-:(code)
-void test_exclusive_container_contains_array() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:@:num:3\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_exclusive_container_disallows_dynamic_array_element() {
-  Hide_errors = true;
-  run(
-      "exclusive-container foo [\n"
-      "  x:@:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: container 'foo' cannot determine size of element 'x'\n"
-  );
-}
-
-//:: To construct exclusive containers out of variant types, use 'merge'.
-void test_lift_to_exclusive_container() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:foo <- merge 0/x, 1:num\n"  // tag must be a literal when merging exclusive containers
-      "  4:foo <- merge 1/y, 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 2\n"
-      "mem: storing 34 in location 3\n"
-      "mem: storing 1 in location 4\n"
-      "mem: storing 34 in location 5\n"
-  );
-}
-
-//: type-checking for 'merge' on exclusive containers
-
-void test_merge_handles_exclusive_container() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  z:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 0/x, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 34 in location 2\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_requires_literal_tag_for_exclusive_container() {
-  Hide_errors = true;
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  z:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:foo <- merge 1:num, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: ingredient 0 of 'merge' should be a literal, for the tag of exclusive-container 'foo' in '2:foo <- merge 1:num, 34'\n"
-  );
-}
-
-void test_merge_handles_exclusive_container_inside_exclusive_container() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  a:num\n"
-      "  b:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:bar <- merge 0/a, 34\n"
-      "  4:foo <- merge 1/y, 2:bar\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 5\n"
-      "mem: storing 34 in location 6\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End check_merge_call Special-cases")
-case EXCLUSIVE_CONTAINER: {
-  assert(state.data.top().container_element_index == 0);
-  trace(102, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end();
-  // easy case: exact match
-  if (types_strictly_match(container, inst.ingredients.at(ingredient_index)))
-    return;
-  if (!is_literal(ingredients.at(ingredient_index))) {
-    raise << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container '" << container_info.name << "' in '" << to_original_string(inst) << "'\n" << end();
-    return;
-  }
-  reagent/*copy*/ ingredient = ingredients.at(ingredient_index);  // unnecessary copy just to keep this function from modifying caller
-  populate_value(ingredient);
-  if (ingredient.value >= SIZE(container_info.elements)) {
-    raise << maybe(caller.name) << "invalid tag at " << ingredient_index << " for '" << container_info.name << "' in '" << to_original_string(inst) << "'\n" << end();
-    return;
-  }
-  const reagent& variant = variant_type(container, ingredient.value);
-  trace(102, "transform") << "tag: " << ingredient.value << end();
-  // replace union with its variant
-  state.data.pop();
-  state.data.push(merge_check_point(variant, 0));
-  ++ingredient_index;
-  break;
-}
-
-:(code)
-void test_merge_check_container_containing_exclusive_container() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 23, 1/y, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 23 in location 1\n"
-      "mem: storing 1 in location 2\n"
-      "mem: storing 34 in location 3\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_container_containing_exclusive_container_2() {
-  Hide_errors = true;
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 23, 1/y, 34, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too many ingredients in '1:foo <- merge 23, 1/y, 34, 35'\n"
-  );
-}
-
-void test_merge_check_exclusive_container_containing_container() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 1/y, 23, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-      "mem: storing 23 in location 2\n"
-      "mem: storing 34 in location 3\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_exclusive_container_containing_container_2() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 0/x, 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_exclusive_container_containing_container_3() {
-  Hide_errors = true;
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 1/y, 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too few ingredients in '1:foo <- merge 1/y, 23'\n"
-  );
-}
-
-void test_merge_check_exclusive_container_containing_container_4() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:num\n"
-      "  y:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  a:num\n"
-      "  b:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:bar <- merge 23, 24\n"
-      "  3:foo <- merge 1/y, 1:bar\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: Since the different variants of an exclusive-container might have
-//: different sizes, relax the size mismatch check for 'merge' instructions.
-:(before "End size_mismatch(x) Special-cases")
-if (current_step_index() < SIZE(Current_routine->steps())
-    && current_instruction().operation == MERGE
-    && !current_instruction().products.empty()
-    && current_instruction().products.at(0).type) {
-  reagent/*copy*/ x = current_instruction().products.at(0);
-  // Update size_mismatch Check for MERGE(x)
-  const type_tree* root_type = x.type->atom ? x.type : x.type->left;
-  assert(root_type->atom);
-  if (get(Type, root_type->value).kind == EXCLUSIVE_CONTAINER)
-    return size_of(x) < SIZE(data);
-}
-
-:(code)
-void test_merge_exclusive_container_with_mismatched_sizes() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  x:num\n"
-      "  y:foo\n"
-      "]\n"
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 35\n"
-      "  3:bar <- merge 0/x, 1:num\n"
-      "  6:bar <- merge 1/foo, 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-      "mem: storing 34 in location 4\n"
-      // bar is always 3 large so location 5 is skipped
-      "mem: storing 1 in location 6\n"
-      "mem: storing 34 in location 7\n"
-      "mem: storing 35 in location 8\n"
-  );
-}
diff --git a/archive/2.vm/034address.cc b/archive/2.vm/034address.cc
deleted file mode 100644
index bafde7b4..00000000
--- a/archive/2.vm/034address.cc
+++ /dev/null
@@ -1,514 +0,0 @@
-//: Addresses help us spend less time copying data around.
-
-//: So far we've been operating on primitives like numbers and characters, and
-//: we've started combining these primitives together into larger logical
-//: units (containers or arrays) that may contain many different primitives at
-//: once. Containers and arrays can grow quite large in complex programs, and
-//: we'd like some way to efficiently share them between recipes without
-//: constantly having to make copies. Right now 'next-ingredient' and 'return'
-//: copy data across recipe boundaries. To avoid copying large quantities of
-//: data around, we'll use *addresses*. An address is a bookmark to some
-//: arbitrary quantity of data (the *payload*). It's a primitive, so it's as
-//: efficient to copy as a number. To read or modify the payload 'pointed to'
-//: by an address, we'll perform a *lookup*.
-//:
-//: The notion of 'lookup' isn't an instruction like 'add' or 'subtract'.
-//: Instead it's an operation that can be performed when reading any of the
-//: ingredients of an instruction, and when writing to any of the products. To
-//: write to the payload of an ingredient rather than its value, simply add
-//: the /lookup property to it. Modern computers provide efficient support for
-//: addresses and lookups, making this a realistic feature.
-//:
-//: To create addresses and allocate memory exclusively for their use, use
-//: 'new'. Memory is a finite resource so if the computer can't satisfy your
-//: request, 'new' may return a 0 (null) address.
-//:
-//: Computers these days have lots of memory so in practice we can often
-//: assume we'll never run out. If you start running out however, say in a
-//: long-running program, you'll need to switch mental gears and start
-//: husbanding our memory more carefully. The most important tool to avoid
-//: wasting memory is to 'abandon' an address when you don't need it anymore.
-//: That frees up the memory allocated to it to be reused in future calls to
-//: 'new'.
-
-//: Since memory can be reused multiple times, it can happen that you have a
-//: stale copy to an address that has since been abandoned and reused. Using
-//: the stale address is almost never safe, but it can be very hard to track
-//: down such copies because any errors caused by them may occur even millions
-//: of instructions after the copy or abandon instruction. To help track down
-//: such issues, Mu tracks an 'alloc id' for each allocation it makes. The
-//: first call to 'new' has an alloc id of 1, the second gets 2, and so on.
-//: The alloc id is never reused.
-:(before "End Globals")
-long long Next_alloc_id = 0;
-:(before "End Reset")
-Next_alloc_id = 0;
-
-//: The 'new' instruction records alloc ids both in the memory being allocated
-//: and *also* in the address. The 'abandon' instruction clears alloc ids in
-//: both places as well. Tracking alloc ids in this manner allows us to raise
-//: errors about stale addresses much earlier: 'lookup' operations always
-//: compare alloc ids between the address and its payload.
-
-//: todo: give 'new' a custodian ingredient. Following malloc/free is a temporary hack.
-
-:(code)
-void test_new() {
-  run(
-      // call 'new' two times with identical types without modifying the
-      // results; you should get back different results
-      "def main [\n"
-      "  10:&:num <- new num:type\n"
-      "  12:&:num <- new num:type\n"
-      "  20:bool <- equal 10:&:num, 12:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1000 in location 11\n"
-      "mem: storing 0 in location 20\n"
-  );
-}
-
-void test_new_array() {
-  run(
-      // call 'new' with a second ingredient to allocate an array of some type
-      // rather than a single copy
-      "def main [\n"
-      "  10:&:@:num <- new num:type, 5\n"
-      "  12:&:num <- new num:type\n"
-      "  20:num/alloc2, 21:num/alloc1 <- deaddress 10:&:@:num, 12:&:num\n"
-      "  30:num <- subtract 21:num/alloc2, 20:num/alloc1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {10: (\"address\" \"array\" \"number\")} <- new {num: \"type\"}, {5: \"literal\"}\n"
-      "mem: array length is 5\n"
-      // skip alloc id in allocation
-      "mem: storing 1000 in location 11\n"
-      // don't forget the extra locations for alloc id and array length
-      "mem: storing 7 in location 30\n"
-  );
-}
-
-void test_dilated_reagent_with_new() {
-  run(
-      "def main [\n"
-      "  10:&:&:num <- new {(& num): type}\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "new: size of '(& num)' is 2\n"
-  );
-}
-
-//: 'new' takes a weird 'type' as its first ingredient; don't error on it
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "type", 0);
-:(code)
-bool is_mu_type_literal(const reagent& r) {
-  return is_literal(r) && r.type && r.type->name == "type";
-}
-
-:(before "End Primitive Recipe Declarations")
-NEW,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "new", NEW);
-:(before "End Primitive Recipe Checks")
-case NEW: {
-  const recipe& caller = get(Recipe, r);
-  if (inst.ingredients.empty() || SIZE(inst.ingredients) > 2) {
-    raise << maybe(caller.name) << "'new' requires one or two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  // End NEW Check Special-cases
-  const reagent& type = inst.ingredients.at(0);
-  if (!is_mu_type_literal(type)) {
-    raise << maybe(caller.name) << "first ingredient of 'new' should be a type, but got '" << type.original_string << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.ingredients) > 1 && !is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(caller.name) << "second ingredient of 'new' should be a number (array length), but got '" << type.original_string << "'\n" << end();
-    break;
-  }
-  if (inst.products.empty()) {
-    raise << maybe(caller.name) << "result of 'new' should never be ignored\n" << end();
-    break;
-  }
-  if (!product_of_new_is_valid(inst)) {
-    raise << maybe(caller.name) << "product of 'new' has incorrect type: '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-
-:(code)
-bool product_of_new_is_valid(const instruction& inst) {
-  reagent/*copy*/ product = inst.products.at(0);
-  // Update NEW product in Check
-  if (!product.type || product.type->atom || product.type->left->value != Address_type_ordinal)
-    return false;
-  drop_from_type(product, "address");
-  if (SIZE(inst.ingredients) > 1) {
-    // array allocation
-    if (!product.type || product.type->atom || product.type->left->value != Array_type_ordinal)
-      return false;
-    drop_from_type(product, "array");
-  }
-  reagent/*local*/ expected_product(new_type_tree(inst.ingredients.at(0).name));
-  return types_strictly_match(product, expected_product);
-}
-
-void drop_from_type(reagent& r, string expected_type) {
-  assert(!r.type->atom);
-  if (r.type->left->name != expected_type) {
-    raise << "can't drop2 " << expected_type << " from '" << to_string(r) << "'\n" << end();
-    return;
-  }
-  // r.type = r.type->right
-  type_tree* tmp = r.type;
-  r.type = tmp->right;
-  tmp->right = NULL;
-  delete tmp;
-  // if (!r.type->right) r.type = r.type->left
-  assert(!r.type->atom);
-  if (r.type->right) return;
-  tmp = r.type;
-  r.type = tmp->left;
-  tmp->left = NULL;
-  delete tmp;
-}
-
-void test_new_returns_incorrect_type() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:bool <- new num:type\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'new' has incorrect type: '1:bool <- new num:type'\n"
-  );
-}
-
-void test_new_discerns_singleton_list_from_atom_container() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- new {(num): type}\n"  // should be '{num: type}'
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'new' has incorrect type: '1:&:num <- new {(num): type}'\n"
-  );
-}
-
-void test_new_with_type_abbreviation() {
-  run(
-      "def main [\n"
-      "  1:&:num <- new num:type\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_new_with_type_abbreviation_inside_compound() {
-  run(
-      "def main [\n"
-      "  {1: (address address number), raw: ()} <- new {(& num): type}\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_equal_result_of_new_with_null() {
-  run(
-      "def main [\n"
-      "  1:&:num <- new num:type\n"
-      "  10:bool <- equal 1:&:num, null\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 10\n"
-  );
-}
-
-//: To implement 'new', a Mu transform turns all 'new' instructions into
-//: 'allocate' instructions that precompute the amount of memory they want to
-//: allocate.
-
-//: Ensure that we never call 'allocate' directly, and that there's no 'new'
-//: instructions left after the transforms have run.
-:(before "End Primitive Recipe Checks")
-case ALLOCATE: {
-  raise << "never call 'allocate' directly'; always use 'new'\n" << end();
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NEW: {
-  raise << "no implementation for 'new'; why wasn't it translated to 'allocate'? Please save a copy of your program and send it to Kartik.\n" << end();
-  break;
-}
-
-:(after "Transform.push_back(check_instruction)")  // check_instruction will guard against direct 'allocate' instructions below
-Transform.push_back(transform_new_to_allocate);  // idempotent
-
-:(code)
-void transform_new_to_allocate(const recipe_ordinal r) {
-  trace(101, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end();
-  for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
-    instruction& inst = get(Recipe, r).steps.at(i);
-    // Convert 'new' To 'allocate'
-    if (inst.name == "new") {
-      if (inst.ingredients.empty()) return;  // error raised elsewhere
-      inst.operation = ALLOCATE;
-      type_tree* type = new_type_tree(inst.ingredients.at(0).name);
-      inst.ingredients.at(0).set_value(size_of(type));
-      trace(102, "new") << "size of '" << inst.ingredients.at(0).name << "' is " << inst.ingredients.at(0).value << end();
-      delete type;
-    }
-  }
-}
-
-//: implement 'allocate' based on size
-
-:(before "End Globals")
-extern const int Reserved_for_tests = 1000;
-int Memory_allocated_until = Reserved_for_tests;
-int Initial_memory_per_routine = 100000;
-:(before "End Reset")
-Memory_allocated_until = Reserved_for_tests;
-Initial_memory_per_routine = 100000;
-:(before "End routine Fields")
-int alloc, alloc_max;
-:(before "End routine Constructor")
-alloc = Memory_allocated_until;
-Memory_allocated_until += Initial_memory_per_routine;
-alloc_max = Memory_allocated_until;
-trace(Callstack_depth+1, "new") << "routine allocated memory from " << alloc << " to " << alloc_max << end();
-
-:(before "End Primitive Recipe Declarations")
-ALLOCATE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "allocate", ALLOCATE);
-:(before "End Primitive Recipe Implementations")
-case ALLOCATE: {
-  // compute the space we need
-  int size = ingredients.at(0).at(0);
-  int alloc_id = Next_alloc_id;
-  Next_alloc_id++;
-  if (SIZE(ingredients) > 1) {
-    // array allocation
-    trace(Callstack_depth+1, "mem") << "array length is " << ingredients.at(1).at(0) << end();
-    size = /*space for length*/1 + size*ingredients.at(1).at(0);
-  }
-  int result = allocate(size);
-  // initialize alloc-id in payload
-  trace(Callstack_depth+1, "mem") << "storing alloc-id " << alloc_id << " in location " << result << end();
-  put(Memory, result, alloc_id);
-  if (SIZE(current_instruction().ingredients) > 1) {
-    // initialize array length
-    trace(Callstack_depth+1, "mem") << "storing array length " << ingredients.at(1).at(0) << " in location " << result+/*skip alloc id*/1 << end();
-    put(Memory, result+/*skip alloc id*/1, ingredients.at(1).at(0));
-  }
-  products.resize(1);
-  products.at(0).push_back(alloc_id);
-  products.at(0).push_back(result);
-  break;
-}
-:(code)
-int allocate(int size) {
-  // include space for alloc id
-  ++size;
-  trace(Callstack_depth+1, "mem") << "allocating size " << size << end();
-//?   Total_alloc += size;
-//?   ++Num_alloc;
-  // Allocate Special-cases
-  // compute the region of memory to return
-  // really crappy at the moment
-  ensure_space(size);
-  const int result = Current_routine->alloc;
-  trace(Callstack_depth+1, "mem") << "new alloc: " << result << end();
-  // initialize allocated space
-  for (int address = result;  address < result+size;  ++address) {
-    trace(Callstack_depth+1, "mem") << "storing 0 in location " << address << end();
-    put(Memory, address, 0);
-  }
-  Current_routine->alloc += size;
-  // no support yet for reclaiming memory between routines
-  assert(Current_routine->alloc <= Current_routine->alloc_max);
-  return result;
-}
-
-//: statistics for debugging
-//? :(before "End Globals")
-//? int Total_alloc = 0;
-//? int Num_alloc = 0;
-//? int Total_free = 0;
-//? int Num_free = 0;
-//? :(before "End Reset")
-//? if (!Memory.empty()) {
-//?   cerr << Total_alloc << "/" << Num_alloc
-//?        << " vs " << Total_free << "/" << Num_free << '\n';
-//?   cerr << SIZE(Memory) << '\n';
-//? }
-//? Total_alloc = Num_alloc = Total_free = Num_free = 0;
-
-:(code)
-void ensure_space(int size) {
-  if (size > Initial_memory_per_routine) {
-    cerr << "can't allocate " << size << " locations, that's too much compared to " << Initial_memory_per_routine << ".\n";
-    exit(1);
-  }
-  if (Current_routine->alloc + size > Current_routine->alloc_max) {
-    // waste the remaining space and create a new chunk
-    Current_routine->alloc = Memory_allocated_until;
-    Memory_allocated_until += Initial_memory_per_routine;
-    Current_routine->alloc_max = Memory_allocated_until;
-    trace(Callstack_depth+1, "new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max << end();
-  }
-}
-
-void test_new_initializes() {
-  Memory_allocated_until = 10;
-  put(Memory, Memory_allocated_until, 1);
-  run(
-      "def main [\n"
-      "  1:&:num <- new num:type\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 10\n"
-      "mem: storing 0 in location 11\n"
-      "mem: storing 10 in location 2\n"
-  );
-}
-
-void test_new_initializes_alloc_id() {
-  Memory_allocated_until = 10;
-  put(Memory, Memory_allocated_until, 1);
-  Next_alloc_id = 23;
-  run(
-      "def main [\n"
-      "  1:&:num <- new num:type\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // initialize memory
-      "mem: storing 0 in location 10\n"
-      "mem: storing 0 in location 11\n"
-      // alloc-id in payload
-      "mem: storing alloc-id 23 in location 10\n"
-      // alloc-id in address
-      "mem: storing 23 in location 1\n"
-  );
-}
-
-void test_new_size() {
-  run(
-      "def main [\n"
-      "  10:&:num <- new num:type\n"
-      "  12:&:num <- new num:type\n"
-      "  20:num/alloc1, 21:num/alloc2 <- deaddress 10:&:num, 12:&:num\n"
-      "  30:num <- subtract 21:num/alloc2, 20:num/alloc1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // size of number + alloc id
-      "mem: storing 2 in location 30\n"
-  );
-}
-
-void test_new_array_size() {
-  run(
-      "def main [\n"
-      "  10:&:@:num <- new num:type, 5\n"
-      "  12:&:num <- new num:type\n"
-      "  20:num/alloc1, 21:num/alloc2 <- deaddress 10:&:num, 12:&:num\n"
-      "  30:num <- subtract 21:num/alloc2, 20:num/alloc1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // 5 locations for array contents + array length + alloc id
-      "mem: storing 7 in location 30\n"
-  );
-}
-
-void test_new_empty_array() {
-  run(
-      "def main [\n"
-      "  10:&:@:num <- new num:type, 0\n"
-      "  12:&:num <- new num:type\n"
-      "  20:num/alloc1, 21:num/alloc2 <- deaddress 10:&:@:num, 12:&:num\n"
-      "  30:num <- subtract 21:num/alloc2, 20:num/alloc1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {10: (\"address\" \"array\" \"number\")} <- new {num: \"type\"}, {0: \"literal\"}\n"
-      "mem: array length is 0\n"
-      // one location for array length and one for alloc id
-      "mem: storing 2 in location 30\n"
-  );
-}
-
-//: If a routine runs out of its initial allocation, it should allocate more.
-void test_new_overflow() {
-  Initial_memory_per_routine = 3;  // barely enough room for point allocation below
-  run(
-      "def main [\n"
-      "  10:&:num <- new num:type\n"
-      "  12:&:point <- new point:type\n"  // not enough room in initial page
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "new: routine allocated memory from 1000 to 1003\n"
-      "new: routine allocated memory from 1003 to 1006\n"
-  );
-}
-
-void test_new_without_ingredient() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- new\n"  // missing ingredient
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'new' requires one or two ingredients, but got '1:&:num <- new'\n"
-  );
-}
-
-//: a little helper: convert address to number
-
-:(before "End Primitive Recipe Declarations")
-DEADDRESS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "deaddress", DEADDRESS);
-:(before "End Primitive Recipe Checks")
-case DEADDRESS: {
-  // primary goal of these checks is to forbid address arithmetic
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_address(inst.ingredients.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'deaddress' requires address ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  if (SIZE(inst.products) > SIZE(inst.ingredients)) {
-    raise << maybe(get(Recipe, r).name) << "too many products in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (!is_real_mu_number(inst.products.at(i))) {
-      raise << maybe(get(Recipe, r).name) << "'deaddress' requires number products, but got '" << inst.products.at(i).original_string << "'\n" << end();
-      goto finish_checking_instruction;
-    }
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case DEADDRESS: {
-  products.resize(SIZE(ingredients));
-  for (int i = 0;  i < SIZE(ingredients);  ++i) {
-    products.at(i).push_back(ingredients.at(i).at(/*skip alloc id*/1));
-  }
-  break;
-}
diff --git a/archive/2.vm/035lookup.cc b/archive/2.vm/035lookup.cc
deleted file mode 100644
index 4229651a..00000000
--- a/archive/2.vm/035lookup.cc
+++ /dev/null
@@ -1,664 +0,0 @@
-//: Go from an address to the payload it points at using /lookup.
-//:
-//: The tests in this layer use unsafe operations so as to stay decoupled from
-//: 'new'.
-
-void test_copy_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      // Treat locations 10 and 11 as an address to look up, pointing at the
-      // payload in locations 20 and 21.
-      "  30:num <- copy 10:&:num/lookup\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 94 in location 30\n"
-  );
-}
-
-:(before "End Preprocess read_memory(x)")
-canonize(x);
-
-//: similarly, write to addresses pointing at other locations using the
-//: 'lookup' property
-:(code)
-void test_store_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:num
-      "  11:num <- copy 10\n"
-      "  10:&:num/lookup <- copy 94\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 94 in location 11\n"
-  );
-}
-
-:(before "End Preprocess write_memory(x, data)")
-canonize(x);
-
-//: writes to address 0 always loudly fail
-:(code)
-void test_store_to_0_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  10:&:num <- copy null\n"
-      "  10:&:num/lookup <- copy 94\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 94 in location 0");
-  CHECK_TRACE_CONTENTS(
-      "error: main: tried to lookup 0 in '10:&:num/lookup <- copy 94'\n"
-  );
-}
-
-//: attempts to /lookup address 0 always loudly fail
-void test_lookup_0_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  10:&:num <- copy null\n"
-      "  20:num <- copy 10:&:num/lookup\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: tried to lookup 0 in '20:num <- copy 10:&:num/lookup'\n"
-  );
-}
-
-void test_lookup_0_dumps_callstack() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  foo null\n"
-      "]\n"
-      "def foo [\n"
-      "  10:&:num <- next-input\n"
-      "  20:num <- copy 10:&:num/lookup\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: tried to lookup 0 in '20:num <- copy 10:&:num/lookup'\n"
-      "error:   called from main: foo null\n"
-  );
-}
-
-void canonize(reagent& x) {
-  if (is_literal(x)) return;
-  // Begin canonize(x) Lookups
-  while (has_property(x, "lookup"))
-    lookup_memory(x);
-}
-
-void lookup_memory(reagent& x) {
-  if (!x.type || x.type->atom || x.type->left->value != Address_type_ordinal) {
-    raise << maybe(current_recipe_name()) << "tried to lookup '" << x.original_string << "' but it isn't an address\n" << end();
-    dump_callstack();
-    return;
-  }
-  // compute value
-  if (x.value == 0) {
-    raise << maybe(current_recipe_name()) << "tried to lookup 0\n" << end();
-    dump_callstack();
-    return;
-  }
-  lookup_memory_core(x, /*check_for_null*/true);
-}
-
-void lookup_memory_core(reagent& x, bool check_for_null) {
-  double address = x.value + /*skip alloc id in address*/1;
-  double new_value = get_or_insert(Memory, address);
-  trace(Callstack_depth+1, "mem") << "location " << address << " contains " << no_scientific(new_value) << end();
-  // check for null
-  if (check_for_null && new_value == 0) {
-    if (Current_routine) {
-      raise << maybe(current_recipe_name()) << "tried to lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-      dump_callstack();
-    }
-    else {
-      raise << "tried to lookup 0\n" << end();
-    }
-  }
-  // validate alloc-id
-  double alloc_id_in_address = get_or_insert(Memory, x.value);
-  double alloc_id_in_payload = get_or_insert(Memory, new_value);
-//?   cerr << x.value << ": " << alloc_id_in_address << " vs " << new_value << ": " << alloc_id_in_payload << '\n';
-  if (alloc_id_in_address != alloc_id_in_payload) {
-      raise << maybe(current_recipe_name()) << "address is already abandoned in '" << to_original_string(current_instruction()) << "'\n" << end();
-      dump_callstack();
-  }
-  // all well; complete the lookup
-  x.set_value(new_value+/*skip alloc id in payload*/1);
-  drop_from_type(x, "address");
-  drop_one_lookup(x);
-}
-
-:(after "Begin types_coercible(reagent to, reagent from)")
-if (!canonize_type(to)) return false;
-if (!canonize_type(from)) return false;
-:(after "Begin types_match(reagent to, reagent from)")
-if (!canonize_type(to)) return false;
-if (!canonize_type(from)) return false;
-:(after "Begin types_strictly_match(reagent to, reagent from)")
-if (!canonize_type(to)) return false;
-if (!canonize_type(from)) return false;
-
-:(before "End Preprocess is_mu_array(reagent r)")
-if (!canonize_type(r)) return false;
-
-:(before "End Preprocess is_mu_address(reagent r)")
-if (!canonize_type(r)) return false;
-
-:(before "End Preprocess is_mu_number(reagent r)")
-if (!canonize_type(r)) return false;
-:(before "End Preprocess is_mu_boolean(reagent r)")
-if (!canonize_type(r)) return false;
-:(before "End Preprocess is_mu_character(reagent r)")
-if (!canonize_type(r)) return false;
-
-:(after "Update product While Type-checking Merge")
-if (!canonize_type(product)) continue;
-
-:(before "End Compute Call Ingredient")
-canonize_type(ingredient);
-:(before "End Preprocess NEXT_INGREDIENT product")
-canonize_type(product);
-:(before "End Check RETURN Copy(lhs, rhs)
-canonize_type(lhs);
-canonize_type(rhs);
-
-:(code)
-bool canonize_type(reagent& r) {
-  while (has_property(r, "lookup")) {
-    if (!r.type || r.type->atom || !r.type->left || !r.type->left->atom || r.type->left->value != Address_type_ordinal) {
-      raise << "cannot perform lookup on '" << r.name << "' because it has non-address type " << to_string(r.type) << '\n' << end();
-      return false;
-    }
-    drop_from_type(r, "address");
-    drop_one_lookup(r);
-  }
-  return true;
-}
-
-void drop_one_lookup(reagent& r) {
-  for (vector<pair<string, string_tree*> >::iterator p = r.properties.begin();  p != r.properties.end();  ++p) {
-    if (p->first == "lookup") {
-      r.properties.erase(p);
-      return;
-    }
-  }
-  assert(false);
-}
-
-//: Tedious fixup to support addresses in container/array instructions of previous layers.
-//: Most instructions don't require fixup if they use the 'ingredients' and
-//: 'products' variables in run_current_routine().
-
-void test_get_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      "  22:num <- copy 95\n"
-      "  30:num <- get 10:&:point/lookup, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 94 in location 30\n"
-  );
-}
-
-void test_get_indirect2() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      "  22:num <- copy 95\n"
-      // skip alloc id for destination
-      "  31:num <- copy 40\n"
-      "  30:&:num/lookup <- get 10:&:point/lookup, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 94 in location 41\n"
-  );
-}
-
-void test_include_nonlookup_properties() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      "  22:num <- copy 95\n"
-      "  30:num <- get 10:&:point/lookup/foo, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 94 in location 30\n"
-  );
-}
-
-:(after "Update GET base in Check")
-if (!canonize_type(base)) break;
-:(after "Update GET product in Check")
-if (!canonize_type(product)) break;
-:(after "Update GET base in Run")
-canonize(base);
-
-:(code)
-void test_put_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      "  22:num <- copy 95\n"
-      "  10:&:point/lookup <- put 10:&:point/lookup, 0:offset, 96\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 96 in location 21\n"
-  );
-}
-
-:(after "Update PUT base in Check")
-if (!canonize_type(base)) break;
-:(after "Update PUT offset in Check")
-if (!canonize_type(offset)) break;
-:(after "Update PUT base in Run")
-canonize(base);
-
-:(code)
-void test_put_product_error_with_lookup() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  11:num <- copy 20\n"
-      "  21:num <- copy 94\n"
-      "  22:num <- copy 95\n"
-      "  10:&:point <- put 10:&:point/lookup, x:offset, 96\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'put' must be first ingredient '10:&:point/lookup', but got '10:&:point'\n"
-  );
-}
-
-:(before "End PUT Product Checks")
-reagent/*copy*/ p = inst.products.at(0);
-if (!canonize_type(p)) break;  // error raised elsewhere
-reagent/*copy*/ i = inst.ingredients.at(0);
-if (!canonize_type(i)) break;  // error raised elsewhere
-if (!types_strictly_match(p, i)) {
-  raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end();
-  break;
-}
-
-:(code)
-void test_new_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num/raw <- new num:type\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'new' has incorrect type: '1:num/raw <- new num:type'\n"
-  );
-}
-
-:(after "Update NEW product in Check")
-canonize_type(product);
-
-:(code)
-void test_copy_array_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:@:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 3\n"  // array length
-      "  22:num <- copy 94\n"
-      "  23:num <- copy 95\n"
-      "  24:num <- copy 96\n"
-      "  30:@:num <- copy 10:&:@:num/lookup\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 30\n"
-      "mem: storing 94 in location 31\n"
-      "mem: storing 95 in location 32\n"
-      "mem: storing 96 in location 33\n"
-  );
-}
-
-void test_create_array_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:@:num:3
-      "  11:num <- copy 3000\n"
-      "  10:&:array:num:3/lookup <- create-array\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 3001\n"
-  );
-}
-
-:(after "Update CREATE_ARRAY product in Check")
-if (!canonize_type(product)) break;
-:(after "Update CREATE_ARRAY product in Run")
-canonize(product);
-
-:(code)
-void test_index_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:@:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 3\n"  // array length
-      "  22:num <- copy 94\n"
-      "  23:num <- copy 95\n"
-      "  24:num <- copy 96\n"
-      "  30:num <- index 10:&:@:num/lookup, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 95 in location 30\n"
-  );
-}
-
-:(before "Update INDEX base in Check")
-if (!canonize_type(base)) break;
-:(before "Update INDEX index in Check")
-if (!canonize_type(index)) break;
-:(before "Update INDEX product in Check")
-if (!canonize_type(product)) break;
-
-:(before "Update INDEX base in Run")
-canonize(base);
-:(before "Update INDEX index in Run")
-canonize(index);
-
-:(code)
-void test_put_index_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:@:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 3\n"  // array length
-      "  22:num <- copy 94\n"
-      "  23:num <- copy 95\n"
-      "  24:num <- copy 96\n"
-      "  10:&:@:num/lookup <- put-index 10:&:@:num/lookup, 1, 97\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 97 in location 23\n"
-  );
-}
-
-void test_put_index_indirect_2() {
-  run(
-      "def main [\n"
-      "  10:num <- copy 3\n"  // array length
-      "  11:num <- copy 94\n"
-      "  12:num <- copy 95\n"
-      "  13:num <- copy 96\n"
-      // skip alloc id for address
-      "  21:num <- copy 30\n"
-      // skip alloc id for payload
-      "  31:num <- copy 1\n"  // index
-      "  10:@:num <- put-index 10:@:num, 20:&:num/lookup, 97\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 97 in location 12\n"
-  );
-}
-
-void test_put_index_product_error_with_lookup() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  11:num <- copy 20\n"
-      "  21:num <- copy 3\n"  // array length
-      "  22:num <- copy 94\n"
-      "  23:num <- copy 95\n"
-      "  24:num <- copy 96\n"
-      "  10:&:@:num <- put-index 10:&:@:num/lookup, 1, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product of 'put-index' must be first ingredient '10:&:@:num/lookup', but got '10:&:@:num'\n"
-  );
-}
-
-:(before "End PUT_INDEX Product Checks")
-reagent/*copy*/ p = inst.products.at(0);
-if (!canonize_type(p)) break;  // error raised elsewhere
-reagent/*copy*/ i = inst.ingredients.at(0);
-if (!canonize_type(i)) break;  // error raised elsewhere
-if (!types_strictly_match(p, i)) {
-  raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end();
-  break;
-}
-
-:(code)
-void test_dilated_reagent_in_static_array() {
-  run(
-      "def main [\n"
-      "  {1: (array (& num) 3)} <- create-array\n"
-      "  10:&:num <- new num:type\n"
-      "  {1: (array (& num) 3)} <- put-index {1: (array (& num) 3)}, 0, 10:&:num\n"
-      "  *10:&:num <- copy 94\n"
-      "  20:num <- copy *10:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: creating array from 7 locations\n"
-      "mem: storing 94 in location 20\n"
-  );
-}
-
-:(before "Update PUT_INDEX base in Check")
-if (!canonize_type(base)) break;
-:(before "Update PUT_INDEX index in Check")
-if (!canonize_type(index)) break;
-:(before "Update PUT_INDEX value in Check")
-if (!canonize_type(value)) break;
-
-:(before "Update PUT_INDEX base in Run")
-canonize(base);
-:(before "Update PUT_INDEX index in Run")
-canonize(index);
-
-:(code)
-void test_length_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:@:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 3\n"  // array length
-      "  22:num <- copy 94\n"
-      "  23:num <- copy 95\n"
-      "  24:num <- copy 96\n"
-      "  30:num <- length 10:&:array:num/lookup\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 30\n"
-  );
-}
-
-:(before "Update LENGTH array in Check")
-if (!canonize_type(array)) break;
-:(before "Update LENGTH array in Run")
-canonize(array);
-
-:(code)
-void test_maybe_convert_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:number-or-point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:number-or-point <- merge 0/number, 94\n"
-      "  30:num, 31:bool <- maybe-convert 10:&:number-or-point/lookup, i:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 31\n"
-      "mem: storing 94 in location 30\n"
-  );
-}
-
-void test_maybe_convert_indirect_2() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:number-or-point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:number-or-point <- merge 0/number, 94\n"
-      // skip alloc id for 30:&:num
-      "  31:num <- copy 40\n"
-      "  30:&:num/lookup, 50:bool <- maybe-convert 10:&:number-or-point/lookup, i:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 50\n"
-      "mem: storing 94 in location 41\n"
-  );
-}
-
-void test_maybe_convert_indirect_3() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:number-or-point
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:number-or-point <- merge 0/number, 94\n"
-      // skip alloc id for 30:&:bool
-      "  31:num <- copy 40\n"
-      "  50:num, 30:&:bool/lookup <- maybe-convert 10:&:number-or-point/lookup, i:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 41\n"
-      "mem: storing 94 in location 50\n"
-  );
-}
-
-:(before "Update MAYBE_CONVERT base in Check")
-if (!canonize_type(base)) break;
-:(before "Update MAYBE_CONVERT product in Check")
-if (!canonize_type(product)) break;
-:(before "Update MAYBE_CONVERT status in Check")
-if (!canonize_type(status)) break;
-
-:(before "Update MAYBE_CONVERT base in Run")
-canonize(base);
-:(before "Update MAYBE_CONVERT product in Run")
-canonize(product);
-:(before "Update MAYBE_CONVERT status in Run")
-canonize(status);
-
-:(code)
-void test_merge_exclusive_container_indirect() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:number-or-point
-      "  11:num <- copy 20\n"
-      "  10:&:number-or-point/lookup <- merge 0/number, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // skip alloc id
-      "mem: storing 0 in location 21\n"
-      "mem: storing 34 in location 22\n"
-  );
-}
-
-:(before "Update size_mismatch Check for MERGE(x)
-canonize(x);
-
-//: abbreviation for '/lookup': a prefix '*'
-
-:(code)
-void test_lookup_abbreviation() {
-  run(
-      "def main [\n"
-      // skip alloc id for 10:&:num
-      "  11:num <- copy 20\n"
-      // skip alloc id for payload
-      "  21:num <- copy 94\n"
-      "  30:num <- copy *10:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: ingredient: {10: (\"&\" \"num\"), \"lookup\": ()}\n"
-      "mem: storing 94 in location 30\n"
-  );
-}
-
-:(before "End Parsing reagent")
-{
-  while (starts_with(name, "*")) {
-    name.erase(0, 1);
-    properties.push_back(pair<string, string_tree*>("lookup", NULL));
-  }
-  if (name.empty())
-    raise << "illegal name '" << original_string << "'\n" << end();
-}
-
-//:: helpers for debugging
-
-:(before "End Primitive Recipe Declarations")
-_DUMP,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump", _DUMP);
-:(before "End Primitive Recipe Implementations")
-case _DUMP: {
-  reagent/*copy*/ after_canonize = current_instruction().ingredients.at(0);
-  canonize(after_canonize);
-  cerr << maybe(current_recipe_name()) << current_instruction().ingredients.at(0).name << ' ' << no_scientific(current_instruction().ingredients.at(0).value) << " => " << no_scientific(after_canonize.value) << " => " << no_scientific(get_or_insert(Memory, after_canonize.value)) << '\n';
-  break;
-}
-
-//: grab an address, and then dump its value at intervals
-//: useful for tracking down memory corruption (writing to an out-of-bounds address)
-:(before "End Globals")
-int Bar = -1;
-:(before "End Primitive Recipe Declarations")
-_BAR,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$bar", _BAR);
-:(before "End Primitive Recipe Implementations")
-case _BAR: {
-  if (current_instruction().ingredients.empty()) {
-    if (Bar != -1) cerr << Bar << ": " << no_scientific(get_or_insert(Memory, Bar)) << '\n';
-    else cerr << '\n';
-  }
-  else {
-    reagent/*copy*/ tmp = current_instruction().ingredients.at(0);
-    canonize(tmp);
-    Bar = tmp.value;
-  }
-  break;
-}
diff --git a/archive/2.vm/036abandon.cc b/archive/2.vm/036abandon.cc
deleted file mode 100644
index a1f66523..00000000
--- a/archive/2.vm/036abandon.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-//: Reclaiming memory when it's no longer used.
-
-void test_new_reclaim() {
-  run(
-      "def main [\n"
-      "  10:&:num <- new number:type\n"
-      "  20:num <- deaddress 10:&:num\n"
-      "  abandon 10:&:num\n"
-      "  30:&:num <- new number:type\n"  // must be same size as abandoned memory to reuse
-      "  40:num <- deaddress 30:&:num\n"
-      "  50:bool <- equal 20:num, 40:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // both allocations should have returned the same address
-      "mem: storing 1 in location 50\n"
-  );
-}
-
-//: When abandoning addresses we'll save them to a 'free list', segregated by size.
-
-//: Before, suppose variable V contains address A which points to payload P:
-//:   location V contains an alloc-id N
-//:   location V+1 contains A
-//:   location A contains alloc-id N
-//:   location A+1 onwards contains P
-//: Additionally, suppose the head of the free list is initially F.
-//: After abandoning:
-//:   location V contains invalid alloc-id -1
-//:   location V+1 contains 0
-//:   location A contains invalid alloc-id N
-//:   location A+1 contains the previous head of free-list F
-
-:(before "End routine Fields")
-map<int, int> free_list;
-
-:(before "End Primitive Recipe Declarations")
-ABANDON,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "abandon", ABANDON);
-:(before "End Primitive Recipe Checks")
-case ABANDON: {
-  if (!inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'abandon' shouldn't write to any products in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_mu_address(inst.ingredients.at(i)))
-      raise << maybe(get(Recipe, r).name) << "ingredients of 'abandon' should be addresses, but ingredient " << i << " is '" << to_string(inst.ingredients.at(i)) << '\n' << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ABANDON: {
-  for (int i = 0;  i < SIZE(current_instruction().ingredients);  ++i) {
-    reagent/*copy*/ ingredient = current_instruction().ingredients.at(i);
-    canonize(ingredient);
-    abandon(get_or_insert(Memory, ingredient.value+/*skip alloc id*/1), payload_size(ingredient));
-//?     cerr << "clear after abandon: " << ingredient.value << '\n';
-    put(Memory, /*alloc id*/ingredient.value, /*invalid*/-1);
-    put(Memory, /*address*/ingredient.value+1, 0);
-  }
-  break;
-}
-
-:(code)
-void abandon(int address, int payload_size) {
-  put(Memory, address, /*invalid alloc-id*/-1);
-//?   cerr << "abandon: " << address << '\n';
-  // clear rest of payload
-  for (int curr = address+1;  curr < address+payload_size;  ++curr)
-    put(Memory, curr, 0);
-  // append existing free list to address
-  trace(Callstack_depth+1, "abandon") << "saving " << address << " in free-list of size " << payload_size << end();
-  put(Memory, address+/*skip invalid alloc-id*/1, get_or_insert(Current_routine->free_list, payload_size));
-  put(Current_routine->free_list, payload_size, address);
-}
-
-int payload_size(reagent/*copy*/ x) {
-  x.properties.push_back(pair<string, string_tree*>("lookup", NULL));
-  lookup_memory_core(x, /*check_for_null*/false);
-  return size_of(x)+/*alloc id*/1;
-}
-
-:(after "Allocate Special-cases")
-if (get_or_insert(Current_routine->free_list, size)) {
-  trace(Callstack_depth+1, "abandon") << "picking up space from free-list of size " << size << end();
-  int result = get_or_insert(Current_routine->free_list, size);
-  trace(Callstack_depth+1, "mem") << "new alloc from free list: " << result << end();
-  put(Current_routine->free_list, size, get_or_insert(Memory, result+/*skip alloc id*/1));
-  // clear 'deleted' tag
-  put(Memory, result, 0);
-  // clear next pointer
-  put(Memory, result+/*skip alloc id*/1, 0);
-  for (int curr = result;  curr < result+size;  ++curr) {
-    if (get_or_insert(Memory, curr) != 0) {
-      raise << maybe(current_recipe_name()) << "memory in free list was not zeroed out: " << curr << '/' << result << "; somebody wrote to us after free!!!\n" << end();
-      break;  // always fatal
-    }
-  }
-  return result;
-}
-
-:(code)
-void test_new_differing_size_no_reclaim() {
-  run(
-      "def main [\n"
-      "  1:&:num <- new number:type\n"
-      "  2:num <- deaddress 1:&:num\n"
-      "  abandon 1:&:num\n"
-      "  3:&:@:num <- new number:type, 2\n"  // different size
-      "  4:num <- deaddress 3:&:@:num\n"
-      "  5:bool <- equal 2:num, 4:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // no reuse
-      "mem: storing 0 in location 5\n"
-  );
-}
-
-void test_new_reclaim_array() {
-  run(
-      "def main [\n"
-      "  10:&:@:num <- new number:type, 2\n"
-      "  20:num <- deaddress 10:&:@:num\n"
-      "  abandon 10:&:@:num\n"
-      "  30:&:@:num <- new number:type, 2\n"  // same size
-      "  40:num <- deaddress 30:&:@:num\n"
-      "  50:bool <- equal 20:num, 40:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // both calls to new returned identical addresses
-      "mem: storing 1 in location 50\n"
-  );
-}
-
-void test_lookup_of_abandoned_address_raises_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:&:num <- new num:type\n"
-      "  3:&:num <- copy 1:&:num\n"
-      "  abandon 1:&:num\n"
-      "  5:num/raw <- copy *3:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: address is already abandoned in '5:num/raw <- copy *3:&:num'\n"
-  );
-}
diff --git a/archive/2.vm/038new_text.cc b/archive/2.vm/038new_text.cc
deleted file mode 100644
index 5317d31d..00000000
--- a/archive/2.vm/038new_text.cc
+++ /dev/null
@@ -1,288 +0,0 @@
-//: Extend 'new' to handle a unicode string literal argument or 'text'.
-
-//: A Mu text is an address to an array of characters.
-:(before "End Mu Types Initialization")
-put(Type_abbreviations, "text", new_type_tree("&:@:character"));
-
-:(code)
-void test_new_string() {
-  run(
-      "def main [\n"
-      "  10:text <- new [abc def]\n"
-      "  20:char <- index *10:text, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // number code for 'e'
-      "mem: storing 101 in location 20\n"
-  );
-}
-
-void test_new_string_handles_unicode() {
-  run(
-      "def main [\n"
-      "  10:text <- new [a«c]\n"
-      "  20:num <- length *10:text\n"
-      "  21:char <- index *10:text, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 20\n"
-      // unicode for '«'
-      "mem: storing 171 in location 21\n"
-  );
-}
-
-:(before "End NEW Check Special-cases")
-if (is_literal_text(inst.ingredients.at(0))) break;
-:(before "Convert 'new' To 'allocate'")
-if (inst.name == "new" && !inst.ingredients.empty() && is_literal_text(inst.ingredients.at(0))) continue;
-:(after "case NEW" following "Primitive Recipe Implementations")
-  if (is_literal_text(current_instruction().ingredients.at(0))) {
-    products.resize(1);
-    products.at(0).push_back(/*alloc id*/0);
-    products.at(0).push_back(new_mu_text(current_instruction().ingredients.at(0).name));
-    trace(Callstack_depth+1, "mem") << "new string alloc: " << products.at(0).at(0) << end();
-    break;
-  }
-
-:(code)
-int new_mu_text(const string& contents) {
-  // allocate an array just large enough for it
-  int string_length = unicode_length(contents);
-//?   Total_alloc += string_length+1;
-//?   ++Num_alloc;
-  int result = allocate(/*array length*/1 + string_length);
-  int curr_address = result;
-  ++curr_address;  // skip alloc id
-  trace(Callstack_depth+1, "mem") << "storing string length " << string_length << " in location " << curr_address << end();
-  put(Memory, curr_address, string_length);
-  ++curr_address;  // skip length
-  int curr = 0;
-  const char* raw_contents = contents.c_str();
-  for (int i = 0;  i < string_length;  ++i) {
-    uint32_t curr_character;
-    assert(curr < SIZE(contents));
-    tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]);
-    trace(Callstack_depth+1, "mem") << "storing string character " << curr_character << " in location " << curr_address << end();
-    put(Memory, curr_address, curr_character);
-    curr += tb_utf8_char_length(raw_contents[curr]);
-    ++curr_address;
-  }
-  // Mu strings are not null-terminated in memory.
-  return result;
-}
-
-//: a new kind of typo
-
-void test_literal_text_without_instruction() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  [abc]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: instruction '[abc]' has no recipe in '[abc]'\n"
-  );
-}
-
-//: stash recognizes texts
-
-void test_stash_text() {
-  run(
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  stash [foo:], 1:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: abc\n"
-  );
-}
-
-:(before "End inspect Special-cases(r, data)")
-if (is_mu_text(r)) {
-  return read_mu_text(data.at(/*skip alloc id*/1));
-}
-
-:(before "End $print Special-cases")
-else if (is_mu_text(current_instruction().ingredients.at(i))) {
-  cout << read_mu_text(ingredients.at(i).at(/*skip alloc id*/1));
-}
-
-:(code)
-void test_unicode_text() {
-  run(
-      "def main [\n"
-      "  1:text <- new [♠]\n"
-      "  stash [foo:], 1:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: foo: ♠\n"
-  );
-}
-
-void test_stash_space_after_text() {
-  run(
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  stash 1:text, [foo]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: abc foo\n"
-  );
-}
-
-void test_stash_text_as_array() {
-  run(
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  stash *1:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: 3 97 98 99\n"
-  );
-}
-
-//: fixes way more than just stash
-:(before "End Preprocess is_mu_text(reagent x)")
-if (!canonize_type(x)) return false;
-
-//: Allocate more to routine when initializing a literal text
-:(code)
-void test_new_text_overflow() {
-  Initial_memory_per_routine = 3;
-  run(
-      "def main [\n"
-      "  10:&:num/raw <- new number:type\n"
-      "  20:text/raw <- new [a]\n"  // not enough room in initial page, if you take the array length into account
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "new: routine allocated memory from 1000 to 1003\n"
-      "new: routine allocated memory from 1003 to 1006\n"
-  );
-}
-
-//: helpers
-:(code)
-int unicode_length(const string& s) {
-  const char* in = s.c_str();
-  int result = 0;
-  int curr = 0;
-  while (curr < SIZE(s)) {  // carefully bounds-check on the string
-    // before accessing its raw pointer
-    ++result;
-    curr += tb_utf8_char_length(in[curr]);
-  }
-  return result;
-}
-
-string read_mu_text(int address) {
-  if (address == 0) return "";
-  int length = get_or_insert(Memory, address+/*alloc id*/1);
-  if (length == 0) return "";
-  return read_mu_characters(address+/*alloc id*/1+/*length*/1, length);
-}
-
-string read_mu_characters(int start, int length) {
-  ostringstream tmp;
-  for (int curr = start;  curr < start+length;  ++curr)
-    tmp << to_unicode(static_cast<uint32_t>(get_or_insert(Memory, curr)));
-  return tmp.str();
-}
-
-//:: some miscellaneous helpers now that we have text
-
-//: assert: perform sanity checks at runtime
-
-void test_assert_literal() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  assert 0, [this is an assert in Mu]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: this is an assert in Mu\n"
-  );
-}
-
-void test_assert() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:text <- new [this is an assert in Mu]\n"
-      "  assert 0, 1:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: this is an assert in Mu\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-ASSERT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "assert", ASSERT);
-:(before "End Primitive Recipe Checks")
-case ASSERT: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'assert' takes exactly two ingredients rather than '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_address(inst.ingredients.at(0)) && !is_mu_scalar(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'assert' requires a scalar or address for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1)) && !is_mu_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "'assert' requires a text as its second ingredient, but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ASSERT: {
-  if (!scalar_ingredient(ingredients, 0)) {
-    if (is_literal_text(current_instruction().ingredients.at(1)))
-      raise << current_instruction().ingredients.at(1).name << '\n' << end();
-    else
-      raise << read_mu_text(ingredients.at(1).at(/*skip alloc id*/1)) << '\n' << end();
-    if (!Hide_errors) exit(1);
-  }
-  break;
-}
-
-//: 'cheating' by using the host system
-
-:(before "End Primitive Recipe Declarations")
-_READ,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$read", _READ);
-:(before "End Primitive Recipe Checks")
-case _READ: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _READ: {
-  skip_whitespace(cin);
-  string result;
-  if (has_data(cin))
-    cin >> result;
-  products.resize(1);
-  products.at(0).push_back(new_mu_text(result));
-  break;
-}
-
-:(code)
-void skip_whitespace(istream& in) {
-  while (true) {
-    if (!has_data(in)) break;
-    if (isspace(in.peek())) in.get();
-    else break;
-  }
-}
diff --git a/archive/2.vm/040brace.cc b/archive/2.vm/040brace.cc
deleted file mode 100644
index 89ff7b01..00000000
--- a/archive/2.vm/040brace.cc
+++ /dev/null
@@ -1,566 +0,0 @@
-//: Structured programming
-//:
-//: Our jump recipes are quite inconvenient to use, so Mu provides a
-//: lightweight tool called 'transform_braces' to work in a slightly more
-//: convenient format with nested braces:
-//:
-//:   {
-//:     some instructions
-//:     {
-//:       more instructions
-//:     }
-//:   }
-//:
-//: Braces are just labels, they require no special parsing. The pseudo
-//: instructions 'loop' and 'break' jump to just after the enclosing '{' and
-//: '}' respectively.
-//:
-//: Conditional and unconditional 'loop' and 'break' should give us 80% of the
-//: benefits of the control-flow primitives we're used to in other languages,
-//: like 'if', 'while', 'for', etc.
-
-void test_brace_conversion() {
-  transform(
-      "def main [\n"
-      "  {\n"
-      "    break\n"
-      "    1:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: jump 1:offset\n"
-      "transform: copy ...\n"
-  );
-}
-
-:(before "End Instruction Modifying Transforms")
-Transform.push_back(transform_braces);  // idempotent
-
-:(code)
-void transform_braces(const recipe_ordinal r) {
-  const bool OPEN = false, CLOSE = true;
-  // use signed integer for step index because we'll be doing arithmetic on it
-  list<pair<bool/*OPEN/CLOSE*/, /*step*/int> > braces;
-  trace(101, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end();
-  for (int index = 0;  index < SIZE(get(Recipe, r).steps);  ++index) {
-    const instruction& inst = get(Recipe, r).steps.at(index);
-    if (inst.label == "{") {
-      trace(103, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end();
-      braces.push_back(pair<bool,int>(OPEN, index));
-    }
-    if (inst.label == "}") {
-      trace(103, "transform") << "push (close, " << index << ")" << end();
-      braces.push_back(pair<bool,int>(CLOSE, index));
-    }
-  }
-  stack</*step*/int> open_braces;
-  for (int index = 0;  index < SIZE(get(Recipe, r).steps);  ++index) {
-    instruction& inst = get(Recipe, r).steps.at(index);
-    if (inst.label == "{") {
-      open_braces.push(index);
-      continue;
-    }
-    if (inst.label == "}") {
-      if (open_braces.empty()) {
-        raise << maybe(get(Recipe, r).name) << "unbalanced '}'\n" << end();
-        return;
-      }
-      open_braces.pop();
-      continue;
-    }
-    if (inst.is_label) continue;
-    if (inst.name != "loop"
-         && inst.name != "loop-if"
-         && inst.name != "loop-unless"
-         && inst.name != "break"
-         && inst.name != "break-if"
-         && inst.name != "break-unless") {
-      trace(102, "transform") << inst.name << " ..." << end();
-      continue;
-    }
-    // check for errors
-    if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) {
-      if (inst.ingredients.empty()) {
-        raise << maybe(get(Recipe, r).name) << "'" << inst.name << "' expects 1 or 2 ingredients, but got none\n" << end();
-        continue;
-      }
-    }
-    // update instruction operation
-    string old_name = inst.name;  // save a copy
-    if (inst.name.find("-if") != string::npos) {
-      inst.name = "jump-if";
-      inst.operation = JUMP_IF;
-    }
-    else if (inst.name.find("-unless") != string::npos) {
-      inst.name = "jump-unless";
-      inst.operation = JUMP_UNLESS;
-    }
-    else {
-      inst.name = "jump";
-      inst.operation = JUMP;
-    }
-    // check for explicitly provided targets
-    if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) {
-      // conditional branches check arg 1
-      if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) {
-        trace(102, "transform") << inst.name << ' ' << inst.ingredients.at(1).name << ":offset" << end();
-        continue;
-      }
-    }
-    else {
-      // unconditional branches check arg 0
-      if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) {
-        trace(102, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end();
-        continue;
-      }
-    }
-    // if implicit, compute target
-    reagent target(new type_tree("offset"));
-    target.set_value(0);
-    if (open_braces.empty())
-      raise << maybe(get(Recipe, r).name) << "'" << old_name << "' needs a '{' before\n" << end();
-    else if (old_name.find("loop") != string::npos)
-      target.set_value(open_braces.top()-index);
-    else  // break instruction
-      target.set_value(matching_brace(open_braces.top(), braces, r) - index - 1);
-    inst.ingredients.push_back(target);
-    // log computed target
-    if (inst.name == "jump")
-      trace(102, "transform") << "jump " << no_scientific(target.value) << ":offset" << end();
-    else
-      trace(102, "transform") << inst.name << ' ' << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end();
-  }
-}
-
-// returns a signed integer not just so that we can return -1 but also to
-// enable future signed arithmetic
-int matching_brace(int index, const list<pair<bool, int> >& braces, recipe_ordinal r) {
-  int stacksize = 0;
-  for (list<pair<bool, int> >::const_iterator p = braces.begin();  p != braces.end();  ++p) {
-    if (p->second < index) continue;
-    stacksize += (p->first ? 1 : -1);
-    if (stacksize == 0) return p->second;
-  }
-  raise << maybe(get(Recipe, r).name) << "unbalanced '{'\n" << end();
-  return SIZE(get(Recipe, r).steps);  // exit current routine
-}
-
-void test_loop() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  {\n"
-      "    3:num <- copy 0\n"
-      "    loop\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: jump -2:offset\n"
-  );
-}
-
-void test_break_empty_block() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    break\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: jump 0:offset\n"
-  );
-}
-
-void test_break_cascading() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    break\n"
-      "  }\n"
-      "  {\n"
-      "    break\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: jump 0:offset\n"
-      "transform: jump 0:offset\n"
-  );
-}
-
-void test_break_cascading_2() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  {\n"
-      "    break\n"
-      "    3:num <- copy 0\n"
-      "  }\n"
-      "  {\n"
-      "    break\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: jump 1:offset\n"
-      "transform: copy ...\n"
-      "transform: jump 0:offset\n"
-  );
-}
-
-void test_break_if() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  {\n"
-      "    break-if 2:num\n"
-      "    3:num <- copy 0\n"
-      "  }\n"
-      "  {\n"
-      "    break\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: jump-if 2, 1:offset\n"
-      "transform: copy ...\n"
-      "transform: jump 0:offset\n"
-  );
-}
-
-void test_break_nested() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    2:num <- copy 0\n"
-      "    break\n"
-      "    {\n"
-      "      3:num <- copy 0\n"
-      "    }\n"
-      "    4:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: jump 4:offset\n"
-  );
-}
-
-void test_break_nested_degenerate() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    2:num <- copy 0\n"
-      "    break\n"
-      "    {\n"
-      "    }\n"
-      "    4:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: jump 3:offset\n"
-  );
-}
-
-void test_break_nested_degenerate_2() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    2:num <- copy 0\n"
-      "    break\n"
-      "    {\n"
-      "    }\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: jump 2:offset\n"
-  );
-}
-
-void test_break_label() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    break +foo:offset\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: jump +foo:offset\n"
-  );
-}
-
-void test_break_unless() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  {\n"
-      "    break-unless 2:num\n"
-      "    3:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: jump-unless 2, 1:offset\n"
-      "transform: copy ...\n"
-  );
-}
-
-void test_loop_unless() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  {\n"
-      "    loop-unless 2:num\n"
-      "    3:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-      "transform: jump-unless 2, -1:offset\n"
-      "transform: copy ...\n"
-  );
-}
-
-void test_loop_nested() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  {\n"
-      "    2:num <- copy 0\n"
-      "    {\n"
-      "      3:num <- copy 0\n"
-      "    }\n"
-      "    loop-if 4:bool\n"
-      "    5:num <- copy 0\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: jump-if 4, -5:offset\n"
-  );
-}
-
-void test_loop_label() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  +foo\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: --- transform braces for recipe main\n"
-      "transform: copy ...\n"
-      "transform: copy ...\n"
-  );
-}
-
-//: test how things actually run
-void test_brace_conversion_and_run() {
-  run(
-      "def test-factorial [\n"
-      "  1:num <- copy 5\n"
-      "  2:num <- copy 1\n"
-      "  {\n"
-      "    3:bool <- equal 1:num, 1\n"
-      "    break-if 3:bool\n"
-      "    2:num <- multiply 2:num, 1:num\n"
-      "    1:num <- subtract 1:num, 1\n"
-      "    loop\n"
-      "  }\n"
-      "  4:num <- copy 2:num\n"  // trigger a read
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: location 2 is 120\n"
-  );
-}
-
-void test_break_outside_braces_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  break\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'break' needs a '{' before\n"
-  );
-}
-
-void test_break_conditional_without_ingredient_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  {\n"
-      "    break-if\n"
-      "  }\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'break-if' expects 1 or 2 ingredients, but got none\n"
-  );
-}
-
-//: Using break we can now implement conditional returns.
-
-void test_return_if() {
-  run(
-      "def main [\n"
-      "  1:num <- test1\n"
-      "]\n"
-      "def test1 [\n"
-      "  return-if 0, 34\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 1\n"
-  );
-}
-
-void test_return_if_2() {
-  run(
-      "def main [\n"
-      "  1:num <- test1\n"
-      "]\n"
-      "def test1 [\n"
-      "  return-if 1, 34\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(before "End Rewrite Instruction(curr, recipe result)")
-// rewrite 'return-if a, b, c, ...' to
-//   ```
-//   {
-//     break-unless a
-//     return b, c, ...
-//   }
-//   ```
-if (curr.name == "return-if" || curr.name == "reply-if") {
-  if (curr.products.empty()) {
-    emit_return_block(result, "break-unless", curr);
-    curr.clear();
-  }
-  else {
-    raise << "'" << curr.name << "' never yields any products\n" << end();
-  }
-}
-// rewrite 'return-unless a, b, c, ...' to
-//   ```
-//   {
-//     break-if a
-//     return b, c, ...
-//   }
-//   ```
-if (curr.name == "return-unless" || curr.name == "reply-unless") {
-  if (curr.products.empty()) {
-    emit_return_block(result, "break-if", curr);
-    curr.clear();
-  }
-  else {
-    raise << "'" << curr.name << "' never yields any products\n" << end();
-  }
-}
-
-:(code)
-void emit_return_block(recipe& out, const string& break_command, const instruction& inst) {
-  const vector<reagent>& ingredients = inst.ingredients;
-  reagent/*copy*/ condition = ingredients.at(0);
-  vector<reagent> return_ingredients;
-  copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end()));
-
-  // {
-  instruction open_label;  open_label.is_label=true;  open_label.label = "{";
-  out.steps.push_back(open_label);
-
-  // <break command> <condition>
-  instruction break_inst;
-  break_inst.operation = get(Recipe_ordinal, break_command);
-  break_inst.name = break_command;
-  break_inst.ingredients.push_back(condition);
-  out.steps.push_back(break_inst);
-
-  // return <return ingredients>
-  instruction return_inst;
-  return_inst.operation = get(Recipe_ordinal, "return");
-  return_inst.name = "return";
-  return_inst.ingredients.swap(return_ingredients);
-  return_inst.original_string = inst.original_string;
-  out.steps.push_back(return_inst);
-
-  // }
-  instruction close_label;  close_label.is_label=true;  close_label.label = "}";
-  out.steps.push_back(close_label);
-}
-
-//: Make sure these pseudo recipes get consistent numbers in all tests, even
-//: though they aren't implemented. Allows greater flexibility in ordering
-//: transforms.
-
-:(before "End Primitive Recipe Declarations")
-BREAK,
-BREAK_IF,
-BREAK_UNLESS,
-LOOP,
-LOOP_IF,
-LOOP_UNLESS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "break", BREAK);
-put(Recipe_ordinal, "break-if", BREAK_IF);
-put(Recipe_ordinal, "break-unless", BREAK_UNLESS);
-put(Recipe_ordinal, "loop", LOOP);
-put(Recipe_ordinal, "loop-if", LOOP_IF);
-put(Recipe_ordinal, "loop-unless", LOOP_UNLESS);
-:(before "End Primitive Recipe Checks")
-case BREAK: break;
-case BREAK_IF: break;
-case BREAK_UNLESS: break;
-case LOOP: break;
-case LOOP_IF: break;
-case LOOP_UNLESS: break;
diff --git a/archive/2.vm/041jump_target.cc b/archive/2.vm/041jump_target.cc
deleted file mode 100644
index ec7adede..00000000
--- a/archive/2.vm/041jump_target.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-//: Support jumps to a specific label (the 'jump target') in the same recipe.
-//: Jump targets must be unique and unambiguous within any recipe.
-//:
-//: The 'break' and 'loop' pseudo instructions can also take jump targets.
-//: Which instruction you use is just documentation about intent; use 'break'
-//: to indicate you're exiting one or more loop nests, and 'loop' to indicate
-//: you're skipping to the next iteration of some containing loop nest.
-
-//: Since they have to be unique in a recipe, not all labels can be jump
-//: targets.
-bool is_jump_target(const string& label) {
-  if (label == "{" || label == "}") return false;
-  // End is_jump_target Special-cases
-  return is_label_word(label);
-}
-
-void test_jump_to_label() {
-  run(
-      "def main [\n"
-      "  jump +target:label\n"
-      "  1:num <- copy 0\n"
-      "  +target\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 1");
-}
-
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "label", 0);
-
-:(before "End Instruction Modifying Transforms")
-Transform.push_back(transform_labels);  // idempotent
-
-:(code)
-void transform_labels(const recipe_ordinal r) {
-  map<string, int> offset;
-  for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
-    const instruction& inst = get(Recipe, r).steps.at(i);
-    if (!inst.is_label) continue;
-    if (is_jump_target(inst.label)) {
-      if (!contains_key(offset, inst.label)) {
-        put(offset, inst.label, i);
-      }
-      else {
-        raise << maybe(get(Recipe, r).name) << "duplicate label '" << inst.label << "'" << end();
-        // have all jumps skip some random but noticeable and deterministic amount of code
-        put(offset, inst.label, 9999);
-      }
-    }
-  }
-  for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
-    instruction& inst = get(Recipe, r).steps.at(i);
-    if (inst.name == "jump") {
-      if (inst.ingredients.empty()) {
-        raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' expects an ingredient but got 0\n" << end();
-        return;
-      }
-      replace_offset(inst.ingredients.at(0), offset, i, r);
-    }
-    if (inst.name == "jump-if" || inst.name == "jump-unless") {
-      if (SIZE(inst.ingredients) < 2) {
-        raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end();
-        return;
-      }
-      replace_offset(inst.ingredients.at(1), offset, i, r);
-    }
-    if ((inst.name == "loop" || inst.name == "break")
-        && SIZE(inst.ingredients) >= 1) {
-      replace_offset(inst.ingredients.at(0), offset, i, r);
-    }
-    if ((inst.name == "loop-if" || inst.name == "loop-unless"
-            || inst.name == "break-if" || inst.name == "break-unless")
-        && SIZE(inst.ingredients) >= 2) {
-      replace_offset(inst.ingredients.at(1), offset, i, r);
-    }
-  }
-}
-
-void replace_offset(reagent& x, /*const*/ map<string, int>& offset, const int current_offset, const recipe_ordinal r) {
-  if (!is_literal(x)) {
-    raise << maybe(get(Recipe, r).name) << "jump target must be offset or label but is '" << x.original_string << "'\n" << end();
-    x.set_value(0);  // no jump by default
-    return;
-  }
-  if (x.initialized) return;
-  if (is_integer(x.name)) return;  // non-labels will be handled like other number operands
-  if (!is_jump_target(x.name)) {
-    raise << maybe(get(Recipe, r).name) << "can't jump to label '" << x.name << "'\n" << end();
-    x.set_value(0);  // no jump by default
-    return;
-  }
-  if (!contains_key(offset, x.name)) {
-    raise << maybe(get(Recipe, r).name) << "can't find label '" << x.name << "'\n" << end();
-    x.set_value(0);  // no jump by default
-    return;
-  }
-  x.set_value(get(offset, x.name) - current_offset);
-}
-
-void test_break_to_label() {
-  run(
-      "def main [\n"
-      "  {\n"
-      "    {\n"
-      "      break +target:label\n"
-      "      1:num <- copy 0\n"
-      "    }\n"
-      "  }\n"
-      "  +target\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 1");
-}
-
-void test_jump_if_to_label() {
-  run(
-      "def main [\n"
-      "  {\n"
-      "    {\n"
-      "      jump-if 1, +target:label\n"
-      "      1:num <- copy 0\n"
-      "    }\n"
-      "  }\n"
-      "  +target\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 1");
-}
-
-void test_loop_unless_to_label() {
-  run(
-      "def main [\n"
-      "  {\n"
-      "    {\n"
-      "      loop-unless 0, +target:label\n"  // loop/break with a label don't care about braces
-      "      1:num <- copy 0\n"
-      "    }\n"
-      "  }\n"
-      "  +target\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 1");
-}
-
-void test_jump_runs_code_after_label() {
-  run(
-      "def main [\n"
-      // first a few lines of padding to exercise the offset computation
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  3:num <- copy 0\n"
-      "  jump +target:label\n"
-      "  4:num <- copy 0\n"
-      "  +target\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 5\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 4");
-}
-
-void test_jump_fails_without_target() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  jump\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'jump' expects an ingredient but got 0\n"
-  );
-}
-
-void test_jump_fails_without_target_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  jump-if true\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'jump-if true' expects 2 ingredients but got 1\n"
-  );
-}
-
-void test_recipe_fails_on_duplicate_jump_target() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  +label\n"
-      "  1:num <- copy 0\n"
-      "  +label\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: duplicate label '+label'\n"
-  );
-}
-
-void test_jump_ignores_nontarget_label() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      // first a few lines of padding to exercise the offset computation
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "  3:num <- copy 0\n"
-      "  jump $target:label\n"
-      "  4:num <- copy 0\n"
-      "  $target\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't jump to label '$target'\n"
-  );
-}
diff --git a/archive/2.vm/042name.cc b/archive/2.vm/042name.cc
deleted file mode 100644
index 557469d0..00000000
--- a/archive/2.vm/042name.cc
+++ /dev/null
@@ -1,414 +0,0 @@
-//: A big convenience high-level languages provide is the ability to name memory
-//: locations. In Mu, a transform called 'transform_names' provides this
-//: convenience.
-
-void test_transform_names() {
-  run(
-      "def main [\n"
-      "  x:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign x 2\n"
-      "mem: storing 0 in location 2\n"
-  );
-}
-
-void test_transform_names_fails_on_use_before_define() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  x:num <- copy y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: tried to read ingredient 'y' in 'x:num <- copy y:num' but it hasn't been written to yet\n"
-  );
-}
-
-// todo: detect conditional defines
-
-:(after "End Type Modifying Transforms")
-Transform.push_back(transform_names);  // idempotent
-
-:(before "End Globals")
-map<recipe_ordinal, map<string, int> > Name;
-
-//: the Name map is a global, so save it before tests and reset it for every
-//: test, just to be safe.
-:(before "End Globals")
-map<recipe_ordinal, map<string, int> > Name_snapshot;
-:(before "End save_snapshots")
-Name_snapshot = Name;
-:(before "End restore_snapshots")
-Name = Name_snapshot;
-
-:(code)
-void transform_names(const recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- transform names for recipe " << caller.name << end();
-  bool names_used = false;
-  bool numeric_locations_used = false;
-  map<string, int>& names = Name[r];
-  // record the indices 'used' so far in the map
-  int& curr_idx = names[""];
-  // reserve indices 0 and 1 for the chaining slot in a later layer.
-  // transform_names may get called multiple times in later layers, so
-  // curr_idx may already be set.
-  if (curr_idx < 2) curr_idx = 2;
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    instruction& inst = caller.steps.at(i);
-    // End transform_names(inst) Special-cases
-    // map names to addresses
-    for (int in = 0;  in < SIZE(inst.ingredients);  ++in) {
-      reagent& ingredient = inst.ingredients.at(in);
-      if (is_disqualified(ingredient, inst, caller.name)) continue;
-      if (is_numeric_location(ingredient)) numeric_locations_used = true;
-      if (is_named_location(ingredient)) names_used = true;
-      if (is_integer(ingredient.name)) continue;
-      if (!already_transformed(ingredient, names)) {
-        raise << maybe(caller.name) << "tried to read ingredient '" << ingredient.name << "' in '" << to_original_string(inst) << "' but it hasn't been written to yet\n" << end();
-        // use-before-set Error
-        return;
-      }
-      int v = lookup_name(ingredient, r);
-      if (v >= 0) {
-        ingredient.set_value(v);
-        // Done Placing Ingredient(ingredient, inst, caller)
-      }
-      else {
-        raise << maybe(caller.name) << "can't find a place to store '" << ingredient.name << "'\n" << end();
-        return;
-      }
-    }
-    for (int out = 0;  out < SIZE(inst.products);  ++out) {
-      reagent& product = inst.products.at(out);
-      if (is_disqualified(product, inst, caller.name)) continue;
-      if (is_numeric_location(product)) numeric_locations_used = true;
-      if (is_named_location(product)) names_used = true;
-      if (is_integer(product.name)) continue;
-      if (names.find(product.name) == names.end()) {
-        trace(103, "name") << "assign " << product.name << " " << curr_idx << end();
-        names[product.name] = curr_idx;
-        curr_idx += size_of(product);
-      }
-      int v = lookup_name(product, r);
-      if (v >= 0) {
-        product.set_value(v);
-        // Done Placing Product(product, inst, caller)
-      }
-      else {
-        raise << maybe(caller.name) << "can't find a place to store '" << product.name << "'\n" << end();
-        return;
-      }
-    }
-  }
-  if (names_used && numeric_locations_used)
-    raise << maybe(caller.name) << "mixing variable names and numeric addresses\n" << end();
-}
-
-bool is_disqualified(/*mutable*/ reagent& x, const instruction& inst, const string& recipe_name) {
-  if (!x.type) {
-    raise << maybe(recipe_name) << "missing type for '" << x.original_string << "' in '" << to_original_string(inst) << "'\n" << end();
-    // missing-type Error 1
-    return true;
-  }
-  if (is_raw(x)) return true;
-  if (is_literal(x)) return true;
-  // End is_disqualified Special-cases
-  if (x.initialized) return true;
-  return false;
-}
-
-bool already_transformed(const reagent& r, const map<string, int>& names) {
-  return contains_key(names, r.name);
-}
-
-int lookup_name(const reagent& r, const recipe_ordinal default_recipe) {
-  return Name[default_recipe][r.name];
-}
-
-type_ordinal skip_addresses(type_tree* type) {
-  while (type && is_compound_type_starting_with(type, "address"))
-    type = type->right;
-  if (!type) return -1;  // error handled elsewhere
-  if (type->atom) return type->value;
-  const type_tree* base_type = type;
-  // Update base_type in skip_addresses
-  if (base_type->atom)
-    return base_type->value;
-  assert(base_type->left->atom);
-  return base_type->left->value;
-}
-
-bool is_compound_type_starting_with(const type_tree* type, const string& expected_name) {
-  if (!type) return false;
-  if (type->atom) return false;
-  if (!type->left->atom) return false;
-  return type->left->value == get(Type_ordinal, expected_name);
-}
-
-int find_element_offset(const type_ordinal t, const string& name, const string& recipe_name) {
-  const type_info& container = get(Type, t);
-  for (int i = 0;  i < SIZE(container.elements);  ++i)
-    if (container.elements.at(i).name == name) return i;
-  raise << maybe(recipe_name) << "unknown element '" << name << "' in container '" << get(Type, t).name << "'\n" << end();
-  return -1;
-}
-int find_element_location(int base_address, const string& name, const type_tree* type, const string& recipe_name) {
-  int offset = find_element_offset(get_base_type(type)->value, name, recipe_name);
-  if (offset == -1) return offset;
-  int result = base_address;
-  for (int i = 0; i < offset; ++i)
-    result += size_of(element_type(type, i));
-  return result;
-}
-
-bool is_numeric_location(const reagent& x) {
-  if (is_literal(x)) return false;
-  if (is_raw(x)) return false;
-  if (x.name == "0") return false;  // used for chaining lexical scopes
-  return is_integer(x.name);
-}
-
-bool is_named_location(const reagent& x) {
-  if (is_literal(x)) return false;
-  if (is_raw(x)) return false;
-  if (is_special_name(x.name)) return false;
-  return !is_integer(x.name);
-}
-
-// all names here should either be disqualified or also in bind_special_scenario_names
-bool is_special_name(const string& s) {
-  if (s == "_") return true;
-  if (s == "0") return true;
-  // End is_special_name Special-cases
-  return false;
-}
-
-bool is_raw(const reagent& r) {
-  return has_property(r, "raw");
-}
-
-void test_transform_names_supports_containers() {
-  transform(
-      "def main [\n"
-      "  x:point <- merge 34, 35\n"
-      "  y:num <- copy 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign x 2\n"
-      // skip location 3 because x occupies two locations
-      "name: assign y 4\n"
-  );
-}
-
-void test_transform_names_supports_static_arrays() {
-  transform(
-      "def main [\n"
-      "  x:@:num:3 <- create-array\n"
-      "  y:num <- copy 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign x 2\n"
-      // skip locations 3, 4, 5 because x occupies four locations
-      "name: assign y 6\n"
-  );
-}
-
-void test_transform_names_passes_dummy() {
-  transform(
-      "def main [\n"
-      // _ is just a dummy result that never gets consumed
-      "  _, x:num <- copy 0, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign x 2\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("name: assign _ 2");
-}
-
-//: an escape hatch to suppress name conversion that we'll use later
-void test_transform_names_passes_raw() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  x:num/raw <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("name: assign x 2");
-  CHECK_TRACE_CONTENTS(
-      "error: can't write to location 0 in 'x:num/raw <- copy 0'\n"
-  );
-}
-
-void test_transform_names_fails_when_mixing_names_and_numeric_locations() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  x:num <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: mixing variable names and numeric addresses\n"
-  );
-}
-
-void test_transform_names_fails_when_mixing_names_and_numeric_locations_2() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  x:num <- copy 1\n"
-      "  1:num <- copy x:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: mixing variable names and numeric addresses\n"
-  );
-}
-
-void test_transform_names_does_not_fail_when_mixing_names_and_raw_locations() {
-  transform(
-      "def main [\n"
-      "  x:num <- copy 1:num/raw\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: main: mixing variable names and numeric addresses");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_transform_names_does_not_fail_when_mixing_names_and_literals() {
-  transform(
-      "def main [\n"
-      "  x:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: main: mixing variable names and numeric addresses");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//:: Support element names for containers in 'get' and 'get-location' and 'put'.
-//: (get-location is implemented later)
-
-:(before "End update GET offset_value in Check")
-else {
-  if (!offset.initialized) {
-    raise << maybe(get(Recipe, r).name) << "uninitialized offset '" << offset.name << "' in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  offset_value = offset.value;
-}
-
-:(code)
-void test_transform_names_transforms_container_elements() {
-  transform(
-      "def main [\n"
-      "  p:&:point <- copy null\n"
-      "  a:num <- get *p:&:point, y:offset\n"
-      "  b:num <- get *p:&:point, x:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: element y of type point is at offset 1\n"
-      "name: element x of type point is at offset 0\n"
-  );
-}
-
-:(before "End transform_names(inst) Special-cases")
-// replace element names of containers with offsets
-if (inst.name == "get" || inst.name == "get-location" || inst.name == "put") {
-  //: avoid raising any errors here; later layers will support overloading new
-  //: instructions with the same names (static dispatch), which could lead to
-  //: spurious errors
-  if (SIZE(inst.ingredients) < 2)
-    break;  // error raised elsewhere
-  if (!is_literal(inst.ingredients.at(1)))
-    break;  // error raised elsewhere
-  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
-    // since first non-address in base type must be a container, we don't have to canonize
-    type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type);
-    if (contains_key(Type, base_type)) {  // otherwise we'll raise an error elsewhere
-      inst.ingredients.at(1).set_value(find_element_offset(base_type, inst.ingredients.at(1).name, get(Recipe, r).name));
-      trace(103, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end();
-    }
-  }
-}
-
-:(code)
-void test_missing_type_in_get() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  get a, x:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'a' in 'get a, x:offset'\n"
-  );
-}
-
-void test_transform_names_handles_containers() {
-  transform(
-      "def main [\n"
-      "  a:point <- merge 0, 0\n"
-      "  b:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign a 2\n"
-      "name: assign b 4\n"
-  );
-}
-
-//:: Support variant names for exclusive containers in 'maybe-convert'.
-
-void test_transform_names_handles_exclusive_containers() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 1\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  20:point, 22:bool <- maybe-convert 12:number-or-point/unsafe, p:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: variant p of type number-or-point has tag 1\n"
-      "mem: storing 1 in location 22\n"
-      "mem: storing 35 in location 20\n"
-      "mem: storing 36 in location 21\n"
-  );
-}
-
-:(before "End transform_names(inst) Special-cases")
-// convert variant names of exclusive containers
-if (inst.name == "maybe-convert") {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "exactly 2 ingredients expected in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  assert(is_literal(inst.ingredients.at(1)));
-  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
-    // since first non-address in base type must be an exclusive container, we don't have to canonize
-    type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type);
-    if (contains_key(Type, base_type)) {  // otherwise we'll raise an error elsewhere
-      inst.ingredients.at(1).set_value(find_element_offset(base_type, inst.ingredients.at(1).name, get(Recipe, r).name));
-      trace(103, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end();
-    }
-  }
-}
-
-:(code)
-void test_missing_type_in_maybe_convert() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  maybe-convert a, x:variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'a' in 'maybe-convert a, x:variant'\n"
-  );
-}
diff --git a/archive/2.vm/043space.cc b/archive/2.vm/043space.cc
deleted file mode 100644
index bd931701..00000000
--- a/archive/2.vm/043space.cc
+++ /dev/null
@@ -1,331 +0,0 @@
-//: Spaces help isolate recipes from each other. You can create them at will,
-//: and all addresses in arguments are implicitly based on the 'default-space'
-//: (unless they have the /raw property)
-//:
-//: Spaces are often called 'scopes' in other languages. Stack frames are a
-//: limited form of space that can't outlive callers.
-//:
-//: Warning: messing with 'default-space' can corrupt memory. Don't share
-//: default-space between recipes. Later we'll see how to chain spaces safely.
-//:
-//: Tests in this layer can write to a location as part of one type, and read
-//: it as part of another. This is unsafe and insecure, and we'll stop doing
-//: this once we switch to variable names.
-
-//: Under the hood, a space is an array of locations in memory.
-:(before "End Mu Types Initialization")
-put(Type_abbreviations, "space", new_type_tree("address:array:location"));
-
-:(code)
-void test_set_default_space() {
-  run(
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // actual start of this recipe
-      "  default-space:space <- copy 10:&:@:location\n"
-         // if default-space is 1000, then:
-         //   1000: alloc id
-         //   1001: array size
-         //   1002: location 0 (space for the chaining slot; described later; often unused)
-         //   1003: location 1 (space for the chaining slot; described later; often unused)
-         //   1004: local 2 (assuming it is a scalar)
-      "  2:num <- copy 93\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 93 in location 1004\n"
-  );
-}
-
-void test_lookup_sidesteps_default_space() {
-  run(
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // prepare payload outside the local scope
-      "  2000:num/alloc-id, 2001:num <- copy 0, 34\n"
-         // actual start of this recipe
-      "  default-space:space <- copy 10:&:@:location\n"
-         // a local address
-      "  2:num, 3:num <- copy 0, 2000\n"
-      "  20:num/raw <- copy *2:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2000 in location 1005\n"
-      "mem: storing 34 in location 20\n"
-  );
-}
-
-//: precondition: disable name conversion for 'default-space'
-
-void test_convert_names_passes_default_space() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  default-space:num <- copy 0\n"
-      "  x:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: assign x 2\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("name: assign default-space 1");
-  CHECK_TRACE_DOESNT_CONTAIN("name: assign default-space 2");
-}
-
-:(before "End is_disqualified Special-cases")
-if (x.name == "default-space")
-  x.initialized = true;
-:(before "End is_special_name Special-cases")
-if (s == "default-space") return true;
-
-//: core implementation
-
-:(before "End call Fields")
-int default_space;
-:(before "End call Constructor")
-default_space = 0;
-
-:(before "Begin canonize(x) Lookups")
-absolutize(x);
-:(code)
-void absolutize(reagent& x) {
-  if (is_raw(x) || is_dummy(x)) return;
-  if (x.name == "default-space") return;
-  if (!x.initialized)
-    raise << to_original_string(current_instruction()) << ": reagent not initialized: '" << x.original_string << "'\n" << end();
-  x.set_value(address(x.value, space_base(x)));
-  x.properties.push_back(pair<string, string_tree*>("raw", NULL));
-  assert(is_raw(x));
-}
-
-//: hook replaced in a later layer
-int space_base(const reagent& x) {
-  return current_call().default_space ? (current_call().default_space + /*skip alloc id*/1) : 0;
-}
-
-int address(int offset, int base) {
-  assert(offset >= 0);
-  if (base == 0) return offset;  // raw
-  int size = get_or_insert(Memory, base);
-  if (offset >= size) {
-    // todo: test
-    raise << current_recipe_name() << ": location " << offset << " is out of bounds " << size << " at " << base << '\n' << end();
-    DUMP("");
-    exit(1);
-    return 0;
-  }
-  return base + /*skip length*/1 + offset;
-}
-
-//: reads and writes to the 'default-space' variable have special behavior
-
-:(after "Begin Preprocess write_memory(x, data)")
-if (x.name == "default-space") {
-  if (!is_mu_space(x))
-    raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but is " << to_string(x.type) << '\n' << end();
-  if (SIZE(data) != 2)
-    raise << maybe(current_recipe_name()) << "'default-space' getting data from non-address\n" << end();
-  current_call().default_space = data.at(/*skip alloc id*/1);
-  return;
-}
-:(code)
-bool is_mu_space(reagent/*copy*/ x) {
-  canonize_type(x);
-  if (!is_compound_type_starting_with(x.type, "address")) return false;
-  drop_from_type(x, "address");
-  if (!is_compound_type_starting_with(x.type, "array")) return false;
-  drop_from_type(x, "array");
-  return x.type && x.type->atom && x.type->name == "location";
-}
-
-void test_get_default_space() {
-  run(
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // actual start of this recipe
-      "  default-space:space <- copy 10:space\n"
-      "  2:space/raw <- copy default-space:space\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1000 in location 3\n"
-  );
-}
-
-:(after "Begin Preprocess read_memory(x)")
-if (x.name == "default-space") {
-  vector<double> result;
-  result.push_back(/*alloc id*/0);
-  result.push_back(current_call().default_space);
-  return result;
-}
-
-//:: fix 'get'
-
-:(code)
-void test_lookup_sidesteps_default_space_in_get() {
-  run(
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // prepare payload outside the local scope
-      "  2000:num/alloc-id, 2001:num/x, 2002:num/y <- copy 0, 34, 35\n"
-         // actual start of this recipe
-      "  default-space:space <- copy 10:space\n"
-         // a local address
-      "  2:num, 3:num <- copy 0, 2000\n"
-      "  3000:num/raw <- get *2:&:point, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 3000\n"
-  );
-}
-
-:(before "Read element" following "case GET:")
-element.properties.push_back(pair<string, string_tree*>("raw", NULL));
-
-//:: fix 'index'
-
-:(code)
-void test_lookup_sidesteps_default_space_in_index() {
-  run(
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // prepare an array address
-      "  20:num/alloc-id, 21:num <- copy 0, 2000\n"
-         // prepare an array payload
-      "  2000:num/alloc-id, 2001:num/length, 2002:num/index:0, 2003:num/index:1 <- copy 0, 2, 34, 35\n"
-         // actual start of this recipe
-      "  default-space:space <- copy 10:&:@:location\n"
-      "  1:&:@:num <- copy 20:&:@:num/raw\n"
-      "  3000:num/raw <- index *1:&:@:num, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 3000\n"
-  );
-}
-
-:(before "Read element" following "case INDEX:")
-element.properties.push_back(pair<string, string_tree*>("raw", NULL));
-
-//:: 'local-scope' is a convenience operation to automatically deduce
-//:: the amount of space to allocate in a default space with names
-
-:(code)
-void test_local_scope() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:num <- copy 0\n"
-      "  y:num <- copy 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // allocate space for x and y, as well as the chaining slot at indices 0 and 1
-      "mem: array length is 4\n"
-  );
-}
-
-:(before "End is_disqualified Special-cases")
-if (x.name == "number-of-locals")
-  x.initialized = true;
-:(before "End is_special_name Special-cases")
-if (s == "number-of-locals") return true;
-
-:(before "End Rewrite Instruction(curr, recipe result)")
-// rewrite 'local-scope' to
-//   ```
-//   default-space:space <- new location:type, number-of-locals:literal
-//   ```
-// where number-of-locals is Name[recipe][""]
-if (curr.name == "local-scope") {
-  rewrite_default_space_instruction(curr);
-}
-:(code)
-void rewrite_default_space_instruction(instruction& curr) {
-  if (!curr.ingredients.empty())
-    raise << "'" << to_original_string(curr) << "' can't take any ingredients\n" << end();
-  curr.name = "new";
-  curr.ingredients.push_back(reagent("location:type"));
-  curr.ingredients.push_back(reagent("number-of-locals:literal"));
-  if (!curr.products.empty())
-    raise << "local-scope can't take any results\n" << end();
-  curr.products.push_back(reagent("default-space:space"));
-}
-:(after "Begin Preprocess read_memory(x)")
-if (x.name == "number-of-locals") {
-  vector<double> result;
-  result.push_back(Name[get(Recipe_ordinal, current_recipe_name())][""]);
-  if (result.back() == 0)
-    raise << "no space allocated for default-space in recipe " << current_recipe_name() << "; are you using names?\n" << end();
-  return result;
-}
-:(after "Begin Preprocess write_memory(x, data)")
-if (x.name == "number-of-locals") {
-  raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end();
-  return;
-}
-
-//:: all recipes must set default-space one way or another
-
-:(before "End Globals")
-bool Hide_missing_default_space_errors = true;
-:(before "End Checks")
-Transform.push_back(check_default_space);  // idempotent
-:(code)
-void check_default_space(const recipe_ordinal r) {
-  if (Hide_missing_default_space_errors) return;  // skip previous core tests; this is only for Mu code
-  const recipe& caller = get(Recipe, r);
-  // End check_default_space Special-cases
-  // assume recipes with only numeric addresses know what they're doing (usually tests)
-  if (!contains_non_special_name(r)) return;
-  trace(101, "transform") << "--- check that recipe " << caller.name << " sets default-space" << end();
-  if (caller.steps.empty()) return;
-  if (!starts_by_setting_default_space(caller))
-    raise << caller.name << " does not seem to start with 'local-scope' or 'default-space'\n" << end();
-}
-bool starts_by_setting_default_space(const recipe& r) {
-  return !r.steps.empty()
-      && !r.steps.at(0).products.empty()
-      && r.steps.at(0).products.at(0).name == "default-space";
-}
-
-:(after "Load Mu Prelude")
-Hide_missing_default_space_errors = false;
-:(after "Test Runs")
-Hide_missing_default_space_errors = true;
-:(after "Running Main")
-Hide_missing_default_space_errors = false;
-
-:(code)
-bool contains_non_special_name(const recipe_ordinal r) {
-  for (map<string, int>::iterator p = Name[r].begin();  p != Name[r].end();  ++p) {
-    if (p->first.empty()) continue;
-    if (p->first.find("stash_") == 0) continue;  // generated by rewrite_stashes_to_text (cross-layer)
-    if (!is_special_name(p->first))
-      return true;
-  }
-  return false;
-}
diff --git a/archive/2.vm/044space_surround.cc b/archive/2.vm/044space_surround.cc
deleted file mode 100644
index 5a4afb5e..00000000
--- a/archive/2.vm/044space_surround.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-//: So far you can have global variables by not setting default-space, and
-//: local variables by setting default-space. You can isolate variables
-//: between those extremes by creating 'surrounding' spaces.
-//:
-//: (Surrounding spaces are like lexical scopes in other languages.)
-
-void test_surrounding_space() {
-  run(
-      // location 2 in space 1 (remember that locations 0 and 1 are reserved in all
-      // spaces) refers to the space surrounding the default space, here 20.
-      "def main [\n"
-         // prepare default-space address
-      "  10:num/alloc-id, 11:num <- copy 0, 1000\n"
-         // prepare default-space payload
-      "  1000:num <- copy 0\n"  // alloc id of payload
-      "  1001:num <- copy 5\n"  // length
-         // prepare address of chained space
-      "  20:num/alloc-id, 21:num <- copy 0, 2000\n"
-         // prepare payload of chained space
-      "  2000:num <- copy 0\n"  // alloc id of payload
-      "  2001:num <- copy 5\n"  // length
-         // actual start of this recipe
-      "  default-space:space <- copy 10:space\n"
-         // later layers will explain the /names: property
-      "  0:space/names:dummy <- copy 20:space/raw\n"
-      "  2:num <- copy 94\n"
-      "  2:num/space:1 <- copy 95\n"
-      "]\n"
-      "def dummy [\n"  // just for the /names: property above
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // chain space: 1000 + (alloc id) 1 + (length) 1
-      "mem: storing 0 in location 1002\n"
-      "mem: storing 2000 in location 1003\n"
-      // store to default space: 1000 + (alloc id) 1 + (length) 1 + (index) 2
-      "mem: storing 94 in location 1004\n"
-      // store to chained space: (contents of location 1003) 2000 + (alloc id) 1 + (length) 1 + (index) 2
-      "mem: storing 95 in location 2004\n"
-  );
-}
-
-//: If you think of a space as a collection of variables with a common
-//: lifetime, surrounding allows managing shorter lifetimes inside a longer
-//: one.
-
-:(replace{} "int space_base(const reagent& x)")
-int space_base(const reagent& x) {
-  int base = current_call().default_space ? (current_call().default_space+/*skip alloc id*/1) : 0;
-  return space_base(x, space_index(x), base);
-}
-
-int space_base(const reagent& x, int space_index, int base) {
-  if (space_index == 0)
-    return base;
-  double chained_space_address = base+/*skip length*/1+/*skip alloc id of chaining slot*/1;
-  double chained_space_base = get_or_insert(Memory, chained_space_address) + /*skip alloc id of chained space*/1;
-  return space_base(x, space_index-1, chained_space_base);
-}
-
-int space_index(const reagent& x) {
-  for (int i = 0;  i < SIZE(x.properties);  ++i) {
-    if (x.properties.at(i).first == "space") {
-      if (!x.properties.at(i).second || x.properties.at(i).second->right)
-        raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in '" << x.original_string << "'\n" << end();
-      return to_integer(x.properties.at(i).second->value);
-    }
-  }
-  return 0;
-}
-
-:(code)
-void test_permit_space_as_variable_name() {
-  run(
-      "def main [\n"
-      "  space:num <- copy 0\n"
-      "]\n"
-  );
-}
diff --git a/archive/2.vm/045closure_name.cc b/archive/2.vm/045closure_name.cc
deleted file mode 100644
index d5f26f81..00000000
--- a/archive/2.vm/045closure_name.cc
+++ /dev/null
@@ -1,204 +0,0 @@
-//: Writing to a literal (not computed) address of 0 in a recipe chains two
-//: spaces together. When a variable has a property of /space:1, it looks up
-//: the variable in the chained/surrounding space. /space:2 looks up the
-//: surrounding space of the surrounding space, etc.
-//:
-//: todo: warn on default-space abuse. default-space for one recipe should
-//: never come from another, otherwise memory will be corrupted.
-
-void test_closure() {
-  run(
-      "def main [\n"
-      "  default-space:space <- new location:type, 30\n"
-      "  2:space/names:new-counter <- new-counter\n"
-      "  10:num/raw <- increment-counter 2:space/names:new-counter\n"
-      "  11:num/raw <- increment-counter 2:space/names:new-counter\n"
-      "]\n"
-      "def new-counter [\n"
-      "  default-space:space <- new location:type, 30\n"
-      "  x:num <- copy 23\n"
-      "  y:num <- copy 13\n"  // variable that will be incremented
-      "  return default-space:space\n"
-      "]\n"
-      "def increment-counter [\n"
-      "  default-space:space <- new location:type, 30\n"
-      "  0:space/names:new-counter <- next-ingredient\n"  // outer space must be created by 'new-counter' above
-      "  y:num/space:1 <- add y:num/space:1, 1\n"  // increment
-      "  y:num <- copy 234\n"  // dummy
-      "  return y:num/space:1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "name: lexically surrounding space for recipe increment-counter comes from new-counter\n"
-      "mem: storing 15 in location 11\n"
-  );
-}
-
-//: To make this work, compute the recipe that provides names for the
-//: surrounding space of each recipe.
-
-:(before "End Globals")
-map<recipe_ordinal, recipe_ordinal> Surrounding_space;  // internal to transform; no need to snapshot
-:(before "End Reset")
-Surrounding_space.clear();
-
-:(before "Begin Type Modifying Transforms")
-Transform.push_back(collect_surrounding_spaces);  // idempotent
-
-:(code)
-void collect_surrounding_spaces(const recipe_ordinal r) {
-  trace(101, "transform") << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << end();
-  for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
-    const instruction& inst = get(Recipe, r).steps.at(i);
-    if (inst.is_label) continue;
-    for (int j = 0;  j < SIZE(inst.products);  ++j) {
-      if (is_literal(inst.products.at(j))) continue;
-      if (inst.products.at(j).name != "0") continue;
-      if (!is_mu_space(inst.products.at(j))) {
-        raise << "slot 0 should always have type address:array:location, but is '" << to_string(inst.products.at(j)) << "'\n" << end();
-        continue;
-      }
-      string_tree* s = property(inst.products.at(j), "names");
-      if (!s) {
-        raise << "slot 0 requires a /names property in recipe '" << get(Recipe, r).name << "'\n" << end();
-        continue;
-      }
-      if (!s->atom) raise << "slot 0 should have a single value in /names, but got '" << to_string(inst.products.at(j)) << "'\n" << end();
-      const string& surrounding_recipe_name = s->value;
-      if (surrounding_recipe_name.empty()) {
-        raise << "slot 0 doesn't initialize its /names property in recipe '" << get(Recipe, r).name << "'\n" << end();
-        continue;
-      }
-      if (contains_key(Surrounding_space, r)
-          && get(Surrounding_space, r) != get(Recipe_ordinal, surrounding_recipe_name)) {
-        raise << "recipe '" << get(Recipe, r).name << "' can have only one 'surrounding' recipe but has '" << get(Recipe, get(Surrounding_space, r)).name << "' and '" << surrounding_recipe_name << "'\n" << end();
-        continue;
-      }
-      trace(103, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end();
-      if (!contains_key(Recipe_ordinal, surrounding_recipe_name)) {
-        raise << "can't find recipe providing surrounding space for '" << get(Recipe, r).name << "'; looking for '" << surrounding_recipe_name << "'\n" << end();
-        continue;
-      }
-      put(Surrounding_space, r, get(Recipe_ordinal, surrounding_recipe_name));
-    }
-  }
-}
-
-//: Once surrounding spaces are available, transform_names uses them to handle
-//: /space properties.
-
-:(replace{} "int lookup_name(const reagent& r, const recipe_ordinal default_recipe)")
-int lookup_name(const reagent& x, const recipe_ordinal default_recipe) {
-  if (!has_property(x, "space")) {
-    if (Name[default_recipe].empty()) raise << "name not found: " << x.name << '\n' << end();
-    return Name[default_recipe][x.name];
-  }
-  string_tree* p = property(x, "space");
-  if (!p || !p->atom) raise << "/space property should have exactly one (non-negative integer) value\n" << end();
-  int n = to_integer(p->value);
-  assert(n >= 0);
-  recipe_ordinal surrounding_recipe = lookup_surrounding_recipe(default_recipe, n);
-  if (surrounding_recipe == -1) return -1;
-  set<recipe_ordinal> done;
-  vector<recipe_ordinal> path;
-  return lookup_name(x, surrounding_recipe, done, path);
-}
-
-// If the recipe we need to lookup this name in doesn't have names done yet,
-// recursively call transform_names on it.
-int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) {
-  if (!Name[r].empty()) return Name[r][x.name];
-  if (contains_key(done, r)) {
-    raise << "can't compute address of '" << to_string(x) << "' because\n" << end();
-    for (int i = 1;  i < SIZE(path);  ++i) {
-      raise << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end();
-    }
-    raise << path.at(SIZE(path)-1) << " requires computing names of " << r << "..ad infinitum\n" << end();
-    return -1;
-  }
-  done.insert(r);
-  path.push_back(r);
-  transform_names(r);  // Not passing 'done' through. Might this somehow cause an infinite loop?
-  assert(!Name[r].empty());
-  return Name[r][x.name];
-}
-
-recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, int n) {
-  if (n == 0) return r;
-  if (!contains_key(Surrounding_space, r)) {
-    raise << "don't know surrounding recipe of '" << get(Recipe, r).name << "'\n" << end();
-    return -1;
-  }
-  assert(contains_key(Surrounding_space, r));
-  return lookup_surrounding_recipe(get(Surrounding_space, r), n-1);
-}
-
-//: weaken use-before-set detection just a tad
-:(replace{} "bool already_transformed(const reagent& r, const map<string, int>& names)")
-bool already_transformed(const reagent& r, const map<string, int>& names) {
-  if (has_property(r, "space")) {
-    string_tree* p = property(r, "space");
-    if (!p || !p->atom) {
-      raise << "/space property should have exactly one (non-negative integer) value in '" << r.original_string << "'\n" << end();
-      return false;
-    }
-    if (p->value != "0") return true;
-  }
-  return contains_key(names, r.name);
-}
-
-:(code)
-void test_missing_surrounding_space() {
-  Hide_errors = true;
-  run(
-      "def f [\n"
-      "  local-scope\n"
-      "  x:num/space:1 <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: don't know surrounding recipe of 'f'\n"
-      "error: f: can't find a place to store 'x'\n"
-  );
-}
-
-//: extra test for try_reclaim_locals() from previous layers
-void test_local_scope_ignores_nonlocal_spaces() {
-  run(
-      "def new-scope [\n"
-      "  local-scope\n"
-      "  x:&:num <- new number:type\n"
-      "  *x:&:num <- copy 34\n"
-      "  return default-space:space\n"
-      "]\n"
-      "def use-scope [\n"
-      "  local-scope\n"
-      "  outer:space/names:new-scope <- next-ingredient\n"
-      "  0:space/names:new-scope <- copy outer:space\n"
-      "  return *x:&:num/space:1\n"
-      "]\n"
-      "def main [\n"
-      "  1:space/raw <- new-scope\n"
-      "  3:num/raw <- use-scope 1:space/raw\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 3\n"
-  );
-}
-
-void test_recursive_transform_names() {
-  run(
-      "def foo [\n"
-      "  local-scope\n"
-      "  x:num <- copy 0\n"
-      "  return default-space:space/names:foo\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  0:space/names:foo <- foo\n"
-      "  x:num/space:1 <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
diff --git a/archive/2.vm/046check_type_by_name.cc b/archive/2.vm/046check_type_by_name.cc
deleted file mode 100644
index 9b123d37..00000000
--- a/archive/2.vm/046check_type_by_name.cc
+++ /dev/null
@@ -1,265 +0,0 @@
-//: Some simple sanity checks for types, and also attempts to guess them where
-//: they aren't provided.
-//:
-//: You still have to provide the full type the first time you mention a
-//: variable in a recipe. You have to explicitly name :offset and :variant
-//: every single time. You can't use the same name with multiple types in a
-//: single recipe.
-
-void test_transform_fails_on_reusing_name_with_different_type() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  x:num <- copy 1\n"
-      "  x:bool <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'x' used with multiple types\n"
-  );
-}
-
-//: we need surrounding-space info for type-checking variables in other spaces
-:(after "Transform.push_back(collect_surrounding_spaces)")
-Transform.push_back(check_or_set_types_by_name);  // idempotent
-
-// Keep the name->type mapping for all recipes around for the entire
-// transformation phase.
-:(before "End Globals")
-map<recipe_ordinal, set<reagent, name_lt> > Types_by_space;  // internal to transform; no need to snapshot
-:(before "End Reset")
-Types_by_space.clear();
-:(before "End transform_all")
-Types_by_space.clear();
-:(before "End Types")
-struct name_lt {
-  bool operator()(const reagent& a, const reagent& b) const { return a.name < b.name; }
-};
-
-:(code)
-void check_or_set_types_by_name(const recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- deduce types for recipe " << caller.name << end();
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    instruction& inst = caller.steps.at(i);
-    for (int in = 0;  in < SIZE(inst.ingredients);  ++in)
-      check_or_set_type(inst.ingredients.at(in), caller);
-    for (int out = 0;  out < SIZE(inst.products);  ++out)
-      check_or_set_type(inst.products.at(out), caller);
-  }
-}
-
-void check_or_set_type(reagent& curr, const recipe& caller) {
-  if (is_literal(curr)) return;
-  if (is_integer(curr.name)) return;  // no type-checking for raw locations
-  set<reagent, name_lt>& known_types = Types_by_space[owning_recipe(curr, caller.ordinal)];
-  deduce_missing_type(known_types, curr, caller);
-  check_type(known_types, curr, caller);
-}
-
-void deduce_missing_type(set<reagent, name_lt>& known_types, reagent& x, const recipe& caller) {
-  // Deduce Missing Type(x, caller)
-  if (x.type) return;
-  if (is_jump_target(x.name)) {
-    x.type = new type_tree("label");
-    return;
-  }
-  if (known_types.find(x) == known_types.end()) return;
-  const reagent& exemplar = *known_types.find(x);
-  x.type = new type_tree(*exemplar.type);
-  trace(102, "transform") << x.name << " <= " << names_to_string(x.type) << end();
-  // spaces are special; their type includes their /names property
-  if (is_mu_space(x) && !has_property(x, "names")) {
-    if (!has_property(exemplar, "names")) {
-      raise << maybe(caller.name) << "missing /names property for space variable '" << exemplar.name << "'\n" << end();
-      return;
-    }
-    x.properties.push_back(pair<string, string_tree*>("names", new string_tree(*property(exemplar, "names"))));
-  }
-}
-
-void check_type(set<reagent, name_lt>& known_types, const reagent& x, const recipe& caller) {
-  if (is_literal(x)) return;
-  if (!x.type) return;  // might get filled in by other logic later
-  if (is_jump_target(x.name)) {
-    if (!x.type->atom || x.type->name != "label")
-      raise << maybe(caller.name) << "non-label '" << x.name << "' must begin with a letter\n" << end();
-    return;
-  }
-  if (known_types.find(x) == known_types.end()) {
-    trace(102, "transform") << x.name << " => " << names_to_string(x.type) << end();
-    known_types.insert(x);
-  }
-  if (!types_strictly_match(known_types.find(x)->type, x.type)) {
-    raise << maybe(caller.name) << "'" << x.name << "' used with multiple types\n" << end();
-    raise << "  " << to_string(known_types.find(x)->type) << " vs " << to_string(x.type) << '\n' << end();
-    return;
-  }
-  if (is_mu_array(x)) {
-    if (!x.type->right) {
-      raise << maybe(caller.name) << "'" << x.name << ": can't be just an array. What is it an array of?\n" << end();
-      return;
-    }
-    if (!x.type->right->right) {
-      raise << caller.name << " can't determine the size of array variable '" << x.name << "'. Either allocate it separately and make the type of '" << x.name << "' an address, or specify the length of the array in the type of '" << x.name << "'.\n" << end();
-      return;
-    }
-  }
-}
-
-recipe_ordinal owning_recipe(const reagent& x, recipe_ordinal r) {
-  for (int s = space_index(x); s > 0; --s) {
-    if (!contains_key(Surrounding_space, r)) break;  // error raised elsewhere
-    r = Surrounding_space[r];
-  }
-  return r;
-}
-
-void test_transform_fills_in_missing_types() {
-  run(
-      "def main [\n"
-      "  x:num <- copy 11\n"
-      "  y:num <- add x, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // x is in location 2, y in location 3
-      "mem: storing 12 in location 3\n"
-  );
-}
-
-void test_transform_fills_in_missing_types_in_product() {
-  run(
-      "def main [\n"
-      "  x:num <- copy 11\n"
-      "  x <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // x is in location 2
-      "mem: storing 12 in location 2\n"
-  );
-}
-
-void test_transform_fills_in_missing_types_in_product_and_ingredient() {
-  run(
-      "def main [\n"
-      "  x:num <- copy 11\n"
-      "  x <- add x, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // x is in location 2
-      "mem: storing 12 in location 2\n"
-  );
-}
-
-void test_transform_fills_in_missing_label_type() {
-  run(
-      "def main [\n"
-      "  jump +target\n"
-      "  1:num <- copy 0\n"
-      "  +target\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 1");
-}
-
-void test_transform_fails_on_missing_types_in_first_mention() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  x <- copy 1\n"
-      "  x:num <- copy 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'x' in 'x <- copy 1'\n"
-  );
-}
-
-void test_transform_fails_on_wrong_type_for_label() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  +foo:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: non-label '+foo' must begin with a letter\n"
-  );
-}
-
-void test_typo_in_address_type_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  y:&:charcter <- new character:type\n"
-      "  *y <- copy 67\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: unknown type charcter in 'y:&:charcter <- new character:type'\n"
-  );
-}
-
-void test_array_type_without_size_fails() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  x:@:num <- merge 2, 12, 13\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main can't determine the size of array variable 'x'. Either allocate it separately and make the type of 'x' an address, or specify the length of the array in the type of 'x'.\n"
-  );
-}
-
-void test_transform_checks_types_of_identical_reagents_in_multiple_spaces() {
-  transform(
-      "def foo [\n"  // dummy function for names
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  0:space/names:foo <- copy null\n"  // specify surrounding space
-      "  x:bool <- copy true\n"
-      "  x:num/space:1 <- copy 34\n"
-      "  x/space:1 <- copy 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_transform_handles_empty_reagents() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  add *\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: illegal name '*'\n"
-  );
-  // no crash
-}
-
-void test_transform_checks_types_in_surrounding_spaces() {
-  Hide_errors = true;
-  transform(
-      // 'x' is a bool in foo's space
-      "def foo [\n"
-      "  local-scope\n"
-      "  x:bool <- copy false\n"
-      "  return default-space/names:foo\n"
-      "]\n"
-      // try to read 'x' as a num in foo's space
-      "def main [\n"
-      "  local-scope\n"
-      "  0:space/names:foo <- foo\n"
-      "  x:num/space:1 <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: 'x' used with multiple types\n"
-  );
-}
diff --git a/archive/2.vm/050scenario.cc b/archive/2.vm/050scenario.cc
deleted file mode 100644
index 5b9dcc14..00000000
--- a/archive/2.vm/050scenario.cc
+++ /dev/null
@@ -1,1039 +0,0 @@
-//: Mu scenarios. This will get long, but these are the tests we want to
-//: support in this layer.
-
-//: We avoid raw numeric locations in Mu -- except in scenarios, where they're
-//: handy to check the values of specific variables
-
-void test_scenario_block() {
-  run_mu_scenario(
-      "scenario foo [\n"
-      "  run [\n"
-      "    1:num <- copy 13\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 13\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-void test_scenario_multiple_blocks() {
-  run_mu_scenario(
-      "scenario foo [\n"
-      "  run [\n"
-      "    1:num <- copy 13\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 13\n"
-      "  ]\n"
-      "  run [\n"
-      "    2:num <- copy 13\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 13\n"
-      "    2 <- 13\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-void test_scenario_check_memory_and_trace() {
-  run_mu_scenario(
-      "scenario foo [\n"
-      "  run [\n"
-      "    1:num <- copy 13\n"
-      "    trace 1, [a], [a b c]\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 13\n"
-      "  ]\n"
-      "  trace-should-contain [\n"
-      "    a: a b c\n"
-      "  ]\n"
-      "  trace-should-not-contain [\n"
-      "    a: x y z\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-//:: Core data structure
-
-:(before "End Types")
-struct scenario {
-  string name;
-  string to_run;
-  void clear() {
-    name.clear();
-    to_run.clear();
-  }
-};
-
-:(before "End Globals")
-vector<scenario> Scenarios, Scenarios_snapshot;
-set<string> Scenario_names, Scenario_names_snapshot;
-:(before "End save_snapshots")
-Scenarios_snapshot = Scenarios;
-Scenario_names_snapshot = Scenario_names;
-:(before "End restore_snapshots")
-Scenarios = Scenarios_snapshot;
-Scenario_names = Scenario_names_snapshot;
-
-//:: Parse the 'scenario' form.
-//: Simply store the text of the scenario.
-
-:(before "End Command Handlers")
-else if (command == "scenario") {
-  scenario result = parse_scenario(in);
-  if (!result.name.empty())
-    Scenarios.push_back(result);
-}
-else if (command == "pending-scenario") {
-  // for temporary use only
-  parse_scenario(in);  // discard
-}
-
-:(code)
-scenario parse_scenario(istream& in) {
-  scenario result;
-  result.name = next_word(in);
-  if (contains_key(Scenario_names, result.name))
-    raise << "duplicate scenario name: '" << result.name << "'\n" << end();
-  Scenario_names.insert(result.name);
-  if (result.name.empty()) {
-    assert(!has_data(in));
-    raise << "incomplete scenario at end of file\n" << end();
-    return result;
-  }
-  skip_whitespace_and_comments(in);
-  if (in.peek() != '[') {
-    raise << "Expected '[' after scenario '" << result.name << "'\n" << end();
-    exit(0);
-  }
-  // scenarios are take special 'code' strings so we need to ignore brackets
-  // inside comments
-  result.to_run = slurp_quoted(in);
-  // delete [] delimiters
-  if (!starts_with(result.to_run, "[")) {
-    raise << "scenario " << result.name << " should start with '['\n" << end();
-    result.clear();
-    return result;
-  }
-  result.to_run.erase(0, 1);
-  if (result.to_run.at(SIZE(result.to_run)-1) != ']') {
-    raise << "scenario " << result.name << " has an unbalanced '['\n" << end();
-    result.clear();
-    return result;
-  }
-  result.to_run.erase(SIZE(result.to_run)-1);
-  return result;
-}
-
-void test_read_scenario_with_bracket_in_comment() {
-  run_mu_scenario(
-      "scenario foo [\n"
-      "  # ']' in comment\n"
-      "  1:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {1: \"number\"} <- copy {0: \"literal\"}\n"
-  );
-}
-
-void test_read_scenario_with_bracket_in_comment_in_nested_string() {
-  run_mu_scenario(
-      "scenario foo [\n"
-      "  1:text <- new [# not a comment]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {1: (\"address\" \"array\" \"character\")} <- new {\"# not a comment\": \"literal-string\"}\n"
-  );
-}
-
-void test_duplicate_scenarios() {
-  Hide_errors = true;
-  run(
-      "scenario foo [\n"
-      "  1:num <- copy 0\n"
-      "]\n"
-      "scenario foo [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: duplicate scenario name: 'foo'\n"
-  );
-}
-
-//:: Run scenarios when we run './mu test'.
-//: Treat the text of the scenario as a regular series of instructions.
-
-:(before "End Globals")
-int Num_core_mu_scenarios = 0;
-:(after "Check For .mu Files")
-Num_core_mu_scenarios = SIZE(Scenarios);
-:(before "End Tests")
-Hide_missing_default_space_errors = false;
-if (Num_core_mu_scenarios > 0) {
-  time(&t);
-  cerr << "Mu tests: " << ctime(&t);
-  for (int i = 0;  i < Num_core_mu_scenarios;  ++i) {
-//?     cerr << '\n' << i << ": " << Scenarios.at(i).name;
-    run_mu_scenario(Scenarios.at(i));
-    if (Passed) cerr << ".";
-    else ++num_failures;
-  }
-  cerr << "\n";
-}
-run_app_scenarios:
-if (Num_core_mu_scenarios != SIZE(Scenarios)) {
-  time(&t);
-  cerr << "App tests: " << ctime(&t);
-  for (int i = Num_core_mu_scenarios;  i < SIZE(Scenarios);  ++i) {
-//?     cerr << '\n' << i << ": " << Scenarios.at(i).name;
-    run_mu_scenario(Scenarios.at(i));
-    if (Passed) cerr << ".";
-    else ++num_failures;
-  }
-  cerr << "\n";
-}
-
-//: For faster debugging, support running tests for just the Mu app(s) we are
-//: loading.
-:(before "End Globals")
-bool Test_only_app = false;
-:(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--test-only-app")) {
-  Test_only_app = true;
-}
-:(after "End Test Run Initialization")
-if (Test_only_app && Num_core_mu_scenarios < SIZE(Scenarios)) {
-  goto run_app_scenarios;
-}
-
-//: Convenience: run a single named scenario.
-:(after "Test Runs")
-for (int i = 0;  i < SIZE(Scenarios);  ++i) {
-  if (Scenarios.at(i).name == argv[argc-1]) {
-    run_mu_scenario(Scenarios.at(i));
-    if (Passed) cerr << ".\n";
-    return 0;
-  }
-}
-
-:(before "End Globals")
-// this isn't a constant, just a global of type const*
-const scenario* Current_scenario = NULL;
-:(code)
-void run_mu_scenario(const scenario& s) {
-  Current_scenario = &s;
-  bool not_already_inside_test = !Trace_stream;
-//?   cerr << s.name << '\n';
-  if (not_already_inside_test) {
-    Trace_stream = new trace_stream;
-    reset();
-  }
-  vector<recipe_ordinal> tmp = load("recipe scenario_"+s.name+" [ "+s.to_run+" ]");
-  mark_autogenerated(tmp.at(0));
-  bind_special_scenario_names(tmp.at(0));
-  transform_all();
-  if (!trace_contains_errors())
-    run(tmp.front());
-  // End Mu Test Teardown
-  if (!Hide_errors && trace_contains_errors() && !Scenario_testing_scenario)
-    Passed = false;
-  if (not_already_inside_test && Trace_stream) {
-    delete Trace_stream;
-    Trace_stream = NULL;
-  }
-  Current_scenario = NULL;
-}
-
-//: Permit numeric locations to be accessed in scenarios.
-:(before "End check_default_space Special-cases")
-// user code should never create recipes with underscores in their names
-if (starts_with(caller.name, "scenario_")) return;  // skip Mu scenarios which will use raw memory locations
-if (starts_with(caller.name, "run_")) return;  // skip calls to 'run', which should be in scenarios and will also use raw memory locations
-
-:(before "End maybe(recipe_name) Special-cases")
-if (starts_with(recipe_name, "scenario_"))
-  return recipe_name.substr(strlen("scenario_")) + ": ";
-
-//: Some variables for fake resources always get special /raw addresses in scenarios.
-
-:(code)
-// Should contain everything passed by is_special_name but failed by is_disqualified.
-void bind_special_scenario_names(const recipe_ordinal r) {
-  // Special Scenario Variable Names(r)
-  // End Special Scenario Variable Names(r)
-}
-:(before "Done Placing Ingredient(ingredient, inst, caller)")
-maybe_make_raw(ingredient, caller);
-:(before "Done Placing Product(product, inst, caller)")
-maybe_make_raw(product, caller);
-:(code)
-void maybe_make_raw(reagent& r, const recipe& caller) {
-  if (!is_special_name(r.name)) return;
-  if (starts_with(caller.name, "scenario_"))
-    r.properties.push_back(pair<string, string_tree*>("raw", NULL));
-  // End maybe_make_raw
-}
-
-//: Test with some setup.
-:(before "End is_special_name Special-cases")
-if (s == "__maybe_make_raw_test__") return true;
-:(before "End Special Scenario Variable Names(r)")
-//: ugly: we only need this for this one test, but need to define it for all time
-Name[r]["__maybe_make_raw_test__"] = Reserved_for_tests-1;
-:(code)
-void test_maybe_make_raw() {
-  // check that scenarios can use local-scope and special variables together
-  vector<recipe_ordinal> tmp = load(
-      "def scenario_foo [\n"
-      "  local-scope\n"
-      "  __maybe_make_raw_test__:num <- copy 34\n"
-      "]\n");
-  mark_autogenerated(tmp.at(0));
-  bind_special_scenario_names(tmp.at(0));
-  transform_all();
-  run(tmp.at(0));
-  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
-}
-
-//: Watch out for redefinitions of scenario routines. We should never ever be
-//: doing that, regardless of anything else.
-
-void test_forbid_redefining_scenario_even_if_forced() {
-  Hide_errors = true;
-  Disable_redefine_checks = true;
-  run(
-      "def scenario-foo [\n"
-      "  1:num <- copy 34\n"
-      "]\n"
-      "def scenario-foo [\n"
-      "  1:num <- copy 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: redefining recipe scenario-foo\n"
-  );
-}
-
-void test_scenario_containing_parse_error() {
-  Hide_errors = true;
-  run(
-      "scenario foo [\n"
-      "  memory-should-contain [\n"
-      "    1 <- 0\n"
-         // missing ']'
-      "]\n"
-  );
-  // no crash
-}
-
-void test_scenario_containing_transform_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  add x, 1\n"
-      "]\n"
-  );
-  // no crash
-}
-
-:(after "bool should_check_for_redefine(const string& recipe_name)")
-  if (recipe_name.find("scenario-") == 0) return true;
-
-//:: The special instructions we want to support inside scenarios.
-//: These are easy to support in an interpreter, but will require more work
-//: when we eventually build a compiler.
-
-//: 'run' is a purely lexical convenience to separate the code actually being
-//: tested from any setup
-
-:(code)
-void test_run() {
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    1:num <- copy 13\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 13 in location 1\n"
-  );
-}
-
-:(before "End Rewrite Instruction(curr, recipe result)")
-if (curr.name == "run") {
-  // Just inline all instructions inside the run block in the containing
-  // recipe. 'run' is basically a comment; pretend it doesn't exist.
-  istringstream in2("[\n"+curr.ingredients.at(0).name+"\n]\n");
-  slurp_body(in2, result);
-  curr.clear();
-}
-
-:(code)
-void test_run_multiple() {
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    1:num <- copy 13\n"
-      "  ]\n"
-      "  run [\n"
-      "    2:num <- copy 13\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 13 in location 1\n"
-      "mem: storing 13 in location 2\n"
-  );
-}
-
-//: 'memory-should-contain' raises errors if specific locations aren't as expected
-//: Also includes some special support for checking Mu texts.
-
-:(before "End Globals")
-bool Scenario_testing_scenario = false;
-:(before "End Reset")
-Scenario_testing_scenario = false;
-
-:(code)
-void test_memory_check() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  memory-should-contain [\n"
-      "    1 <- 13\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: checking location 1\n"
-      "error: F - main: expected location '1' to contain 13 but saw 0\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-MEMORY_SHOULD_CONTAIN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "memory-should-contain", MEMORY_SHOULD_CONTAIN);
-:(before "End Primitive Recipe Checks")
-case MEMORY_SHOULD_CONTAIN: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MEMORY_SHOULD_CONTAIN: {
-  if (!Passed) break;
-  check_memory(current_instruction().ingredients.at(0).name);
-  break;
-}
-
-:(code)
-void check_memory(const string& s) {
-  istringstream in(s);
-  in >> std::noskipws;
-  set<int> locations_checked;
-  while (true) {
-    skip_whitespace_and_comments(in);
-    if (!has_data(in)) break;
-    string lhs = next_word(in);
-    if (lhs.empty()) {
-      assert(!has_data(in));
-      raise << maybe(current_recipe_name()) << "incomplete 'memory-should-contain' block at end of file (0)\n" << end();
-      return;
-    }
-    if (!is_integer(lhs)) {
-      check_type(lhs, in);
-      continue;
-    }
-    int address = to_integer(lhs);
-    skip_whitespace_and_comments(in);
-    string _assign;  in >> _assign;  assert(_assign == "<-");
-    skip_whitespace_and_comments(in);
-    string rhs = next_word(in);
-    if (rhs.empty()) {
-      assert(!has_data(in));
-      raise << maybe(current_recipe_name()) << "incomplete 'memory-should-contain' block at end of file (1)\n" << end();
-      return;
-    }
-    if (!is_integer(rhs) && !is_noninteger(rhs)) {
-      if (!Hide_errors) cerr << '\n';
-      raise << "F - " << maybe(current_recipe_name()) << "location '" << address << "' can't contain non-number " << rhs << '\n' << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-    double value = to_double(rhs);
-    if (contains_key(locations_checked, address))
-      raise << maybe(current_recipe_name()) << "duplicate expectation for location '" << address << "'\n" << end();
-    trace(Callstack_depth+1, "run") << "checking location " << address << end();
-    if (get_or_insert(Memory, address) != value) {
-      if (!Hide_errors) cerr << '\n';
-      raise << "F - " << maybe(current_recipe_name()) << "expected location '" << address << "' to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-    locations_checked.insert(address);
-  }
-}
-
-void check_type(const string& lhs, istream& in) {
-  reagent x(lhs);
-  if (is_mu_array(x.type) && is_mu_character(array_element(x.type))) {
-    x.set_value(to_integer(x.name));
-    skip_whitespace_and_comments(in);
-    string _assign = next_word(in);
-    if (_assign.empty()) {
-      assert(!has_data(in));
-      raise << maybe(current_recipe_name()) << "incomplete 'memory-should-contain' block at end of file (2)\n" << end();
-      return;
-    }
-    assert(_assign == "<-");
-    skip_whitespace_and_comments(in);
-    string literal = next_word(in);
-    if (literal.empty()) {
-      assert(!has_data(in));
-      raise << maybe(current_recipe_name()) << "incomplete 'memory-should-contain' block at end of file (3)\n" << end();
-      return;
-    }
-    int address = x.value;
-    // exclude quoting brackets
-    if (*literal.begin() != '[') {
-      raise << maybe(current_recipe_name()) << "array:character types inside 'memory-should-contain' can only be compared with text literals surrounded by [], not '" << literal << "'\n" << end();
-      return;
-    }
-    literal.erase(literal.begin());
-    assert(*--literal.end() == ']');  literal.erase(--literal.end());
-    check_mu_text(address, literal);
-    return;
-  }
-  // End Scenario Type Special-cases
-  raise << "don't know how to check memory for '" << lhs << "'\n" << end();
-}
-
-void check_mu_text(int start, const string& literal) {
-  trace(Callstack_depth+1, "run") << "checking text length at " << start << end();
-  int array_length = static_cast<int>(get_or_insert(Memory, start));
-  if (array_length != SIZE(literal)) {
-    if (!Hide_errors) cerr << '\n';
-    raise << "F - " << maybe(current_recipe_name()) << "expected location '" << start << "' to contain length " << SIZE(literal) << " of text [" << literal << "] but saw " << array_length << " (for text [" << read_mu_characters(start+/*skip length*/1, array_length) << "])\n" << end();
-    if (!Scenario_testing_scenario) Passed = false;
-    return;
-  }
-  int curr = start+1;  // now skip length
-  for (int i = 0;  i < SIZE(literal);  ++i) {
-    trace(Callstack_depth+1, "run") << "checking location " << curr+i << end();
-    if (get_or_insert(Memory, curr+i) != literal.at(i)) {
-      if (!Hide_errors) cerr << '\n';
-      raise << "F - " << maybe(current_recipe_name()) << "expected location " << (curr+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, curr+i)) << '\n' << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-  }
-}
-
-void test_memory_check_multiple() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  memory-should-contain [\n"
-      "    1 <- 0\n"
-      "    1 <- 0\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: duplicate expectation for location '1'\n"
-  );
-}
-
-void test_memory_check_mu_text_length() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- copy 3\n"
-      "  2:num <- copy 97  # 'a'\n"
-      "  3:num <- copy 98  # 'b'\n"
-      "  4:num <- copy 99  # 'c'\n"
-      "  memory-should-contain [\n"
-      "    1:array:character <- [ab]\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: expected location '1' to contain length 2 of text [ab] but saw 3 (for text [abc])\n"
-  );
-}
-
-void test_memory_check_mu_text() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 3\n"
-      "  2:num <- copy 97\n"  // 'a'
-      "  3:num <- copy 98\n"  // 'b'
-      "  4:num <- copy 99\n"  // 'c'
-      "  memory-should-contain [\n"
-      "    1:array:character <- [abc]\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: checking text length at 1\n"
-      "run: checking location 2\n"
-      "run: checking location 3\n"
-      "run: checking location 4\n"
-  );
-}
-
-void test_memory_invalid_string_check() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  memory-should-contain [\n"
-      "    1 <- [abc]\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: location '1' can't contain non-number [abc]\n"
-  );
-}
-
-void test_memory_invalid_string_check2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- copy 3\n"
-      "  2:num <- copy 97\n"  // 'a'
-      "  3:num <- copy 98\n"  // 'b'
-      "  4:num <- copy 99\n"  // 'c'
-      "  memory-should-contain [\n"
-      "    1:array:character <- 0\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: array:character types inside 'memory-should-contain' can only be compared with text literals surrounded by [], not '0'\n"
-  );
-}
-
-void test_memory_check_with_comment() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  memory-should-contain [\n"
-      "    1 <- 34  # comment\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: location 1 can't contain non-number 34  # comment");
-  // but there'll be an error signalled by memory-should-contain
-}
-
-//: 'trace-should-contain' is like the '+' lines in our scenarios so far
-//: Like runs of contiguous '+' lines, order is important. The trace checks
-//: that the lines are present *and* in the specified sequence. (There can be
-//: other lines in between.)
-
-void test_trace_check_fails() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-         // nothing added to the trace
-      "  trace-should-contain [\n"
-      "    a: b\n"
-      "    a: d\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: missing [b] in trace with label 'a'\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-TRACE_SHOULD_CONTAIN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "trace-should-contain", TRACE_SHOULD_CONTAIN);
-:(before "End Primitive Recipe Checks")
-case TRACE_SHOULD_CONTAIN: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TRACE_SHOULD_CONTAIN: {
-  if (!Passed) break;
-  check_trace(current_instruction().ingredients.at(0).name);
-  break;
-}
-
-:(code)
-// simplified version of check_trace_contents() that emits errors rather
-// than just printing to stderr
-void check_trace(const string& expected) {
-  Trace_stream->newline();
-  vector<trace_line> expected_lines = parse_trace(expected);
-  if (expected_lines.empty()) return;
-  int curr_expected_line = 0;
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin();  p != Trace_stream->past_lines.end();  ++p) {
-    if (expected_lines.at(curr_expected_line).label != p->label) continue;
-    if (expected_lines.at(curr_expected_line).contents != trim(p->contents)) continue;
-    // match
-    ++curr_expected_line;
-    if (curr_expected_line == SIZE(expected_lines)) return;
-  }
-  if (!Hide_errors) cerr << '\n';
-  raise << "F - " << maybe(current_recipe_name()) << "missing [" << expected_lines.at(curr_expected_line).contents << "] "
-        << "in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end();
-  if (!Hide_errors)
-    DUMP(expected_lines.at(curr_expected_line).label);
-  if (!Scenario_testing_scenario) Passed = false;
-}
-
-vector<trace_line> parse_trace(const string& expected) {
-  vector<string> buf = split(expected, "\n");
-  vector<trace_line> result;
-  const string separator = ": ";
-  for (int i = 0;  i < SIZE(buf);  ++i) {
-    buf.at(i) = trim(buf.at(i));
-    if (buf.at(i).empty()) continue;
-    int delim = buf.at(i).find(separator);
-    if (delim == -1) {
-      raise << maybe(current_recipe_name()) << "lines in 'trace-should-contain' should be of the form <label>: <contents>. Both parts are required.\n" << end();
-      result.clear();
-      return result;
-    }
-    result.push_back(trace_line(/*contents*/  trim(buf.at(i).substr(delim+SIZE(separator)        )),
-                                /*label*/     trim(buf.at(i).substr(0,                      delim))));
-  }
-  return result;
-}
-
-void test_trace_check_fails_in_nonfirst_line() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [b]\n"
-      "  ]\n"
-      "  trace-should-contain [\n"
-      "    a: b\n"
-      "    a: d\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: missing [d] in trace with label 'a'\n"
-  );
-}
-
-void test_trace_check_passes_silently() {
-  Scenario_testing_scenario = true;
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [b]\n"
-      "  ]\n"
-      "  trace-should-contain [\n"
-      "    a: b\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: missing [b] in trace with label 'a'");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: 'trace-should-not-contain' checks each line in its argument for absence.
-//: Order is *not* important, so you can't say things like "B should not exist
-//: after A."
-
-void test_trace_negative_check_fails() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [b]\n"
-      "  ]\n"
-      "  trace-should-not-contain [\n"
-      "    a: b\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: unexpected [b] in trace with label 'a'\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-TRACE_SHOULD_NOT_CONTAIN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "trace-should-not-contain", TRACE_SHOULD_NOT_CONTAIN);
-:(before "End Primitive Recipe Checks")
-case TRACE_SHOULD_NOT_CONTAIN: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TRACE_SHOULD_NOT_CONTAIN: {
-  if (!Passed) break;
-  check_trace_missing(current_instruction().ingredients.at(0).name);
-  break;
-}
-
-:(code)
-// simplified version of check_trace_contents() that emits errors rather
-// than just printing to stderr
-bool check_trace_missing(const string& in) {
-  Trace_stream->newline();
-  vector<trace_line> lines = parse_trace(in);
-  for (int i = 0;  i < SIZE(lines);  ++i) {
-    if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) {
-      raise << "F - " << maybe(current_recipe_name()) << "unexpected [" << lines.at(i).contents << "] in trace with label '" << lines.at(i).label << "'\n" << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return false;
-    }
-  }
-  return true;
-}
-
-void test_trace_negative_check_passes_silently() {
-  Scenario_testing_scenario = true;
-  run(
-      "def main [\n"
-      "  trace-should-not-contain [\n"
-      "    a: b\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: unexpected [b] in trace with label 'a'");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_trace_negative_check_fails_on_any_unexpected_line() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [d]\n"
-      "  ]\n"
-      "  trace-should-not-contain [\n"
-      "    a: b\n"
-      "    a: d\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: unexpected [d] in trace with label 'a'\n"
-  );
-}
-
-void test_trace_count_check() {
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [foo]\n"
-      "  ]\n"
-      "  check-trace-count-for-label 1, [a]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-:(before "End Primitive Recipe Declarations")
-CHECK_TRACE_COUNT_FOR_LABEL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "check-trace-count-for-label", CHECK_TRACE_COUNT_FOR_LABEL);
-:(before "End Primitive Recipe Checks")
-case CHECK_TRACE_COUNT_FOR_LABEL: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'check-trace-count-for-label' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-count-for-label' should be a number (count), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-count-for-label' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CHECK_TRACE_COUNT_FOR_LABEL: {
-  if (!Passed) break;
-  int expected_count = ingredients.at(0).at(0);
-  string label = current_instruction().ingredients.at(1).name;
-  int count = trace_count(label);
-  if (count != expected_count) {
-    if (!Hide_errors) cerr << '\n';
-    raise << "F - " << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label '" << label << "' in trace\n" << end();
-    if (!Hide_errors) DUMP(label);
-    if (!Scenario_testing_scenario) Passed = false;
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CHECK_TRACE_COUNT_FOR_LABEL_GREATER_THAN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "check-trace-count-for-label-greater-than", CHECK_TRACE_COUNT_FOR_LABEL_GREATER_THAN);
-:(before "End Primitive Recipe Checks")
-case CHECK_TRACE_COUNT_FOR_LABEL_GREATER_THAN: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'check-trace-count-for-label' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-count-for-label' should be a number (count), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-count-for-label' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CHECK_TRACE_COUNT_FOR_LABEL_GREATER_THAN: {
-  if (!Passed) break;
-  int expected_count = ingredients.at(0).at(0);
-  string label = current_instruction().ingredients.at(1).name;
-  int count = trace_count(label);
-  if (count <= expected_count) {
-    if (!Hide_errors) cerr << '\n';
-    raise << maybe(current_recipe_name()) << "expected more than " << expected_count << " lines in trace with label '" << label << "' in trace\n" << end();
-    if (!Hide_errors) {
-      cerr << "trace contents:\n";
-      DUMP(label);
-    }
-    if (!Scenario_testing_scenario) Passed = false;
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CHECK_TRACE_COUNT_FOR_LABEL_LESSER_THAN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "check-trace-count-for-label-lesser-than", CHECK_TRACE_COUNT_FOR_LABEL_LESSER_THAN);
-:(before "End Primitive Recipe Checks")
-case CHECK_TRACE_COUNT_FOR_LABEL_LESSER_THAN: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'check-trace-count-for-label' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-count-for-label' should be a number (count), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-count-for-label' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CHECK_TRACE_COUNT_FOR_LABEL_LESSER_THAN: {
-  if (!Passed) break;
-  int expected_count = ingredients.at(0).at(0);
-  string label = current_instruction().ingredients.at(1).name;
-  int count = trace_count(label);
-  if (count >= expected_count) {
-    if (!Hide_errors) cerr << '\n';
-    raise << "F - " << maybe(current_recipe_name()) << "expected less than " << expected_count << " lines in trace with label '" << label << "' in trace\n" << end();
-    if (!Hide_errors) {
-      cerr << "trace contents:\n";
-      DUMP(label);
-    }
-    if (!Scenario_testing_scenario) Passed = false;
-  }
-  break;
-}
-
-:(code)
-void test_trace_count_check_2() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  run [\n"
-      "    trace 1, [a], [foo]\n"
-      "  ]\n"
-      "  check-trace-count-for-label 2, [a]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - main: expected 2 lines in trace with label 'a' in trace\n"
-  );
-}
-
-//: Minor detail: ignore 'system' calls in scenarios, since anything we do
-//: with them is by definition impossible to test through Mu.
-:(after "case _SYSTEM:")
-  if (Current_scenario) break;
-
-//:: Warn if people use '_' manually in recipe names. They're reserved for internal use.
-
-:(code)
-void test_recipe_name_with_underscore() {
-  Hide_errors = true;
-  run(
-      "def foo_bar [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo_bar: don't create recipes with '_' in the name\n"
-  );
-}
-
-:(before "End recipe Fields")
-bool is_autogenerated;
-:(before "End recipe Constructor")
-is_autogenerated = false;
-:(code)
-void mark_autogenerated(recipe_ordinal r) {
-  get(Recipe, r).is_autogenerated = true;
-}
-
-:(after "void transform_all()")
-  for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin();  p != Recipe.end();  ++p) {
-    const recipe& r = p->second;
-    if (r.name.find('_') == string::npos) continue;
-    if (r.is_autogenerated) continue;  // created by previous call to transform_all()
-    raise << r.name << ": don't create recipes with '_' in the name\n" << end();
-  }
-
-//:: Helpers
-
-:(code)
-// just for the scenarios running scenarios in C++ layers
-void run_mu_scenario(const string& form) {
-  Scenario_names.clear();
-  istringstream in(form);
-  in >> std::noskipws;
-  skip_whitespace_and_comments(in);
-  string _scenario = next_word(in);
-  if (_scenario.empty()) {
-    assert(!has_data(in));
-    raise << "no scenario in string passed into run_mu_scenario()\n" << end();
-    return;
-  }
-  assert(_scenario == "scenario");
-  scenario s = parse_scenario(in);
-  run_mu_scenario(s);
-}
diff --git a/archive/2.vm/051scenario_test.mu b/archive/2.vm/051scenario_test.mu
deleted file mode 100644
index 0d6f04a6..00000000
--- a/archive/2.vm/051scenario_test.mu
+++ /dev/null
@@ -1,70 +0,0 @@
-# tests for 'scenario' in previous layer
-
-scenario first_scenario_in_mu [
-  run [
-    10:num <- add 2, 2
-  ]
-  memory-should-contain [
-    10 <- 4
-  ]
-]
-
-scenario scenario_with_comment_in_mu [
-  run [
-    # comment
-    10:num <- add 2, 2
-  ]
-  memory-should-contain [
-    10 <- 4
-  ]
-]
-
-scenario scenario_with_multiple_comments_in_mu [
-  run [
-    # comment1
-    # comment2
-    10:num <- add 2, 2
-  ]
-  memory-should-contain [
-    10 <- 4
-  ]
-]
-
-scenario check_text_in_memory [
-  run [
-    10:num <- copy 3
-    11:char <- copy 97  # 'a'
-    12:char <- copy 98  # 'b'
-    13:char <- copy 99  # 'c'
-  ]
-  memory-should-contain [
-    10:array:character <- [abc]
-  ]
-]
-
-scenario check_trace [
-  run [
-    10:num <- add 2, 2
-  ]
-  trace-should-contain [
-    mem: storing 4 in location 10
-  ]
-]
-
-scenario check_trace_negative [
-  run [
-    10:num <- add 2, 2
-  ]
-  trace-should-not-contain [
-    mem: storing 3 in location 10
-  ]
-]
-
-scenario check_trace_instruction [
-  run [
-    trace 1, [foo], [aaa]
-  ]
-  trace-should-contain [
-    foo: aaa
-  ]
-]
diff --git a/archive/2.vm/052tangle.cc b/archive/2.vm/052tangle.cc
deleted file mode 100644
index a5332e1b..00000000
--- a/archive/2.vm/052tangle.cc
+++ /dev/null
@@ -1,529 +0,0 @@
-//: Allow code for recipes to be pulled in from multiple places and inserted
-//: at special labels called 'waypoints' using two new top-level commands:
-//:   before
-//:   after
-
-//: Most labels are local: they must be unique to a recipe, and are invisible
-//: outside the recipe. However, waypoints are global: a recipe can have
-//: multiple of them, you can't use them as jump targets.
-:(before "End is_jump_target Special-cases")
-if (is_waypoint(label)) return false;
-//: Waypoints are always surrounded by '<>', e.g. <handle-request>.
-:(code)
-bool is_waypoint(string label) {
-  return *label.begin() == '<' && *label.rbegin() == '>';
-}
-
-void test_tangle_before() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  <label1>\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 0 in location 2\n"
-      "mem: storing 0 in location 3\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 3);
-}
-
-//: while loading recipes, load before/after fragments
-
-:(before "End Globals")
-map<string /*label*/, recipe> Before_fragments, After_fragments;
-set<string /*label*/> Fragments_used;
-:(before "End Reset")
-Before_fragments.clear();
-After_fragments.clear();
-Fragments_used.clear();
-
-:(before "End Command Handlers")
-else if (command == "before") {
-  string label = next_word(in);
-  if (label.empty()) {
-    assert(!has_data(in));
-    raise << "incomplete 'before' block at end of file\n" << end();
-    return result;
-  }
-  recipe tmp;
-  slurp_body(in, tmp);
-  if (is_waypoint(label))
-    Before_fragments[label].steps.insert(Before_fragments[label].steps.end(), tmp.steps.begin(), tmp.steps.end());
-  else
-    raise << "can't tangle before non-waypoint " << label << '\n' << end();
-  // End before Command Handler
-}
-else if (command == "after") {
-  string label = next_word(in);
-  if (label.empty()) {
-    assert(!has_data(in));
-    raise << "incomplete 'after' block at end of file\n" << end();
-    return result;
-  }
-  recipe tmp;
-  slurp_body(in, tmp);
-  if (is_waypoint(label))
-    After_fragments[label].steps.insert(After_fragments[label].steps.begin(), tmp.steps.begin(), tmp.steps.end());
-  else
-    raise << "can't tangle after non-waypoint " << label << '\n' << end();
-  // End after Command Handler
-}
-
-//: after all recipes are loaded, insert fragments at appropriate labels.
-
-:(after "Begin Instruction Inserting/Deleting Transforms")
-Transform.push_back(insert_fragments);  // NOT idempotent
-
-//: We might need to perform multiple passes, in case inserted fragments
-//: include more labels that need further insertions. Track which labels we've
-//: already processed using an extra field.
-:(before "End instruction Fields")
-mutable bool tangle_done;
-:(before "End instruction Constructor")
-tangle_done = false;
-
-:(code)
-void insert_fragments(const recipe_ordinal r) {
-  insert_fragments(get(Recipe, r));
-}
-
-void insert_fragments(recipe& r) {
-  trace(101, "transform") << "--- insert fragments into recipe " << r.name << end();
-  bool made_progress = true;
-  int pass = 0;
-  while (made_progress) {
-    made_progress = false;
-    // create a new vector because insertions invalidate iterators
-    vector<instruction> result;
-    for (int i = 0;  i < SIZE(r.steps);  ++i) {
-      const instruction& inst = r.steps.at(i);
-      if (!inst.is_label || !is_waypoint(inst.label) || inst.tangle_done) {
-        result.push_back(inst);
-        continue;
-      }
-      inst.tangle_done = true;
-      made_progress = true;
-      Fragments_used.insert(inst.label);
-      ostringstream prefix;
-      prefix << '+' << r.name << '_' << pass << '_' << i;
-      // ok to use contains_key even though Before_fragments uses [],
-      // because appending an empty recipe is a noop
-      if (contains_key(Before_fragments, inst.label)) {
-        trace(102, "transform") << "insert fragments before label " << inst.label << end();
-        append_fragment(result, Before_fragments[inst.label].steps, prefix.str());
-      }
-      result.push_back(inst);
-      if (contains_key(After_fragments, inst.label)) {
-        trace(102, "transform") << "insert fragments after label " << inst.label << end();
-        append_fragment(result, After_fragments[inst.label].steps, prefix.str());
-      }
-    }
-    r.steps.swap(result);
-    ++pass;
-  }
-}
-
-void append_fragment(vector<instruction>& base, const vector<instruction>& patch, const string prefix) {
-  // append 'patch' to 'base' while keeping 'base' oblivious to any new jump
-  // targets in 'patch' oblivious to 'base' by prepending 'prefix' to them.
-  // we might tangle the same fragment at multiple points in a single recipe,
-  // and we need to avoid duplicate jump targets.
-  // so we'll keep jump targets local to the specific before/after fragment
-  // that introduces them.
-  set<string> jump_targets;
-  for (int i = 0;  i < SIZE(patch);  ++i) {
-    const instruction& inst = patch.at(i);
-    if (inst.is_label && is_jump_target(inst.label))
-      jump_targets.insert(inst.label);
-  }
-  for (int i = 0;  i < SIZE(patch);  ++i) {
-    instruction inst = patch.at(i);
-    if (inst.is_label) {
-      if (contains_key(jump_targets, inst.label))
-        inst.label = prefix+inst.label;
-      base.push_back(inst);
-      continue;
-    }
-    for (int j = 0;  j < SIZE(inst.ingredients);  ++j) {
-      reagent& x = inst.ingredients.at(j);
-      if (is_jump_target(x.name) && contains_key(jump_targets, x.name))
-        x.name = prefix+x.name;
-    }
-    base.push_back(inst);
-  }
-}
-
-//: complain about unapplied fragments
-//: This can't run during transform because later (shape-shifting recipes)
-//: we'll encounter situations where fragments might get used long after
-//: they're loaded, and we might run transform_all in between. To avoid
-//: spurious errors, run this check right at the end, after all code is
-//: loaded, right before we run main.
-:(before "End Commandline Parsing")
-check_insert_fragments();
-:(code)
-void check_insert_fragments() {
-  for (map<string, recipe>::iterator p = Before_fragments.begin();  p != Before_fragments.end();  ++p) {
-    if (!contains_key(Fragments_used, p->first))
-      raise << "could not locate insert before label " << p->first << '\n' << end();
-  }
-  for (map<string, recipe>::iterator p = After_fragments.begin();  p != After_fragments.end();  ++p) {
-    if (!contains_key(Fragments_used, p->first))
-      raise << "could not locate insert after label " << p->first << '\n' << end();
-  }
-}
-
-void test_tangle_before_and_after() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  <label1>\n"
-      "  4:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 0 in location 2\n"
-      // label1
-      "mem: storing 0 in location 3\n"
-      "mem: storing 0 in location 4\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 4);
-}
-
-void test_tangle_ignores_jump_target() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  +label1\n"
-      "  4:num <- copy 0\n"
-      "]\n"
-      "before +label1 [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: can't tangle before non-waypoint +label1\n"
-  );
-}
-
-void test_tangle_keeps_labels_separate() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  <label1>\n"
-      "  <label2>\n"
-      "  6:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-      "before <label2> [\n"
-      "  4:num <- copy 0\n"
-      "]\n"
-      "after <label2> [\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 0 in location 2\n"
-      // label1
-      "mem: storing 0 in location 3\n"
-      // 'after' fragments for earlier label always go before 'before'
-      // fragments for later label
-      "mem: storing 0 in location 4\n"
-      // label2
-      "mem: storing 0 in location 5\n"
-      "mem: storing 0 in location 6\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 6);
-}
-
-void test_tangle_stacks_multiple_fragments() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  <label1>\n"
-      "  6:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  4:num <- copy 0\n"
-      "]\n"
-      "after <label1> [\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      // 'before' fragments stack in order
-      "mem: storing 0 in location 2\n"
-      "mem: storing 0 in location 4\n"
-      // label1
-      // 'after' fragments stack in reverse order
-      "mem: storing 0 in location 5\n"
-      "mem: storing 0 in location 3\n"
-      "mem: storing 0 in location 6\n"
-  );
-  // nothing
-  CHECK_TRACE_COUNT("mem", 6);
-}
-
-void test_tangle_supports_fragments_with_multiple_instructions() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"
-      "  <label1>\n"
-      "  6:num <- copy 0\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 0\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-      "after <label1> [\n"
-      "  4:num <- copy 0\n"
-      "  5:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-      "mem: storing 0 in location 2\n"
-      "mem: storing 0 in location 3\n"
-      // label1
-      "mem: storing 0 in location 4\n"
-      "mem: storing 0 in location 5\n"
-      "mem: storing 0 in location 6\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 6);
-}
-
-void test_tangle_tangles_into_all_labels_with_same_name() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  4:num <- copy 10\n"
-      "  recipe2\n"
-      "]\n"
-      "def recipe2 [\n"
-      "  1:num <- copy 11\n"
-      "  <label1>\n"
-      "  4:num <- copy 11\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 12\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      "mem: storing 12 in location 2\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 10 in location 4\n"
-      // recipe2
-      "mem: storing 11 in location 1\n"
-      "mem: storing 12 in location 2\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 11 in location 4\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 8);
-}
-
-void test_tangle_tangles_into_all_labels_with_same_name_2() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  <label1>\n"
-      "  4:num <- copy 10\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 12\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      "mem: storing 12 in location 2\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 12 in location 2\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 10 in location 4\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 6);
-}
-
-void test_tangle_tangles_into_all_labels_with_same_name_3() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  <foo>\n"
-      "  4:num <- copy 10\n"
-      "]\n"
-      "before <label1> [\n"
-      "  2:num <- copy 12\n"
-      "]\n"
-      "after <label1> [\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-      "after <foo> [\n"
-      "  <label1>\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      "mem: storing 12 in location 2\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 12 in location 2\n"
-      // foo/label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 10 in location 4\n"
-  );
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 6);
-}
-
-void test_tangle_handles_jump_target_inside_fragment() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  4:num <- copy 10\n"
-      "]\n"
-      "before <label1> [\n"
-      "  jump +label2:label\n"
-      "  2:num <- copy 12\n"
-      "  +label2\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 10 in location 4\n"
-  );
-  // ignored by jump
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 12 in label 2");
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 3);
-}
-
-void test_tangle_renames_jump_target() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  +label2\n"
-      "  4:num <- copy 10\n"
-      "]\n"
-      "before <label1> [\n"
-      "  jump +label2:label\n"
-      "  2:num <- copy 12\n"
-      "  +label2  # renamed\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      // label1
-      "mem: storing 12 in location 3\n"
-      "mem: storing 10 in location 4\n"
-  );
-  // ignored by jump
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 12 in label 2");
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 3);
-}
-
-void test_tangle_jump_to_base_recipe() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 10\n"
-      "  <label1>\n"
-      "  +label2\n"
-      "  4:num <- copy 10\n"
-      "]\n"
-      "before <label1> [\n"
-      "  jump +label2:label\n"
-      "  2:num <- copy 12\n"
-      "  3:num <- copy 12\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 10 in location 1\n"
-      // label1
-      "mem: storing 10 in location 4\n"
-  );
-  // ignored by jump
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 12 in label 2");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 12 in location 3");
-  // nothing else
-  CHECK_TRACE_COUNT("mem", 2);
-}
-
-//: ensure that there are no new fragments created for a label after it's already been inserted to
-
-void test_new_fragment_after_tangle() {
-  // define a recipe
-  load("def foo [\n"
-       "  local-scope\n"
-       "  <label>\n"
-       "]\n"
-       "after <label> [\n"
-       "  1:num/raw <- copy 34\n"
-       "]\n");
-  transform_all();
-  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
-  Hide_errors = true;
-  // try to tangle into recipe foo after transform
-  load("before <label> [\n"
-       "  2:num/raw <- copy 35\n"
-       "]\n");
-  CHECK_TRACE_CONTAINS_ERRORS();
-}
-
-:(before "End before Command Handler")
-if (contains_key(Fragments_used, label))
-  raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end();
-:(before "End after Command Handler")
-if (contains_key(Fragments_used, label))
-  raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end();
diff --git a/archive/2.vm/053recipe_header.cc b/archive/2.vm/053recipe_header.cc
deleted file mode 100644
index 73fde510..00000000
--- a/archive/2.vm/053recipe_header.cc
+++ /dev/null
@@ -1,793 +0,0 @@
-//: Advanced notation for the common/easy case where a recipe takes some fixed
-//: number of ingredients and yields some fixed number of products.
-
-void test_recipe_with_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:num <- add x, y\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-//: When loading recipes save any header.
-
-:(before "End recipe Fields")
-bool has_header;
-vector<reagent> ingredients;
-vector<reagent> products;
-:(before "End recipe Constructor")
-has_header = false;
-
-:(before "End Recipe Refinements")
-if (in.peek() != '[') {
-  trace(101, "parse") << "recipe has a header; parsing" << end();
-  load_recipe_header(in, result);
-}
-
-:(code)
-void load_recipe_header(istream& in, recipe& result) {
-  result.has_header = true;
-  while (has_data(in) && in.peek() != '[' && in.peek() != '\n') {
-    string s = next_word(in);
-    if (s.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete recipe header at end of file (0)\n" << end();
-      return;
-    }
-    if (s == "<-")
-      raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end();
-    if (s == "->") break;
-    result.ingredients.push_back(reagent(s));
-    trace(101, "parse") << "header ingredient: " << result.ingredients.back().original_string << end();
-    skip_whitespace_but_not_newline(in);
-  }
-  while (has_data(in) && in.peek() != '[' && in.peek() != '\n') {
-    string s = next_word(in);
-    if (s.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete recipe header at end of file (1)\n" << end();
-      return;
-    }
-    result.products.push_back(reagent(s));
-    trace(101, "parse") << "header product: " << result.products.back().original_string << end();
-    skip_whitespace_but_not_newline(in);
-  }
-  // End Load Recipe Header(result)
-}
-
-void test_recipe_handles_stray_comma() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num, [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:num <- add x, y\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-void test_recipe_handles_stray_comma_2() {
-  run(
-      "def main [\n"
-      "  foo\n"
-      "]\n"
-      "def foo, [\n"
-      "  1:num/raw <- add 2, 2\n"
-      "]\n"
-      "def bar [\n"
-      "  1:num/raw <- add 2, 3\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-void test_recipe_handles_wrong_arrow() {
-  Hide_errors = true;
-  run(
-      "def foo a:num <- b:num [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: recipe foo should say '->' and not '<-'\n"
-  );
-}
-
-void test_recipe_handles_missing_bracket() {
-  Hide_errors = true;
-  run(
-      "def main\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: recipe body must begin with '['\n"
-  );
-}
-
-void test_recipe_handles_missing_bracket_2() {
-  Hide_errors = true;
-  run(
-      "def main\n"
-      "  local-scope\n"
-      "  {\n"
-      "  }\n"
-      "]\n"
-  );
-  // doesn't overflow line when reading header
-  CHECK_TRACE_DOESNT_CONTAIN("parse: header ingredient: local-scope");
-  CHECK_TRACE_CONTENTS(
-      "error: main: recipe body must begin with '['\n"
-  );
-}
-
-void test_recipe_handles_missing_bracket_3() {
-  Hide_errors = true;
-  run(
-      "def main  # comment\n"
-      "  local-scope\n"
-      "  {\n"
-      "  }\n"
-      "]\n"
-  );
-  // doesn't overflow line when reading header
-  CHECK_TRACE_DOESNT_CONTAIN("parse: header ingredient: local-scope");
-  CHECK_TRACE_CONTENTS(
-      "error: main: recipe body must begin with '['\n"
-  );
-}
-
-:(after "Begin debug_string(recipe x)")
-out << "ingredients:\n";
-for (int i = 0;  i < SIZE(x.ingredients);  ++i)
-  out << "  " << debug_string(x.ingredients.at(i)) << '\n';
-out << "products:\n";
-for (int i = 0;  i < SIZE(x.products);  ++i)
-  out << "  " << debug_string(x.products.at(i)) << '\n';
-
-//: If a recipe never mentions any ingredients or products, assume it has a header.
-
-:(code)
-void test_recipe_without_ingredients_or_products_has_header() {
-  run(
-      "def test [\n"
-      "  1:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "parse: recipe test has a header\n"
-  );
-}
-
-:(before "End Recipe Body(result)")
-if (!result.has_header) {
-  result.has_header = true;
-  for (int i = 0;  i < SIZE(result.steps);  ++i) {
-    const instruction& inst = result.steps.at(i);
-    if ((inst.name == "reply" && !inst.ingredients.empty())
-        || (inst.name == "return" && !inst.ingredients.empty())
-        || inst.name == "next-ingredient"
-        || inst.name == "ingredient"
-        || inst.name == "rewind-ingredients") {
-      result.has_header = false;
-      break;
-    }
-  }
-}
-if (result.has_header) {
-  trace(101, "parse") << "recipe " << result.name << " has a header" << end();
-}
-
-//: Support type abbreviations in headers.
-
-:(code)
-void test_type_abbreviations_in_recipe_headers() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  a:text <- foo\n"
-      "  1:char/raw <- index *a, 0\n"
-      "]\n"
-      "def foo -> a:text [  # 'text' is an abbreviation\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  a <- new [abc]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 97 in location 1\n"
-  );
-}
-
-:(before "End Expand Type Abbreviations(caller)")
-for (long int i = 0;  i < SIZE(caller.ingredients);  ++i)
-  expand_type_abbreviations(caller.ingredients.at(i).type);
-for (long int i = 0;  i < SIZE(caller.products);  ++i)
-  expand_type_abbreviations(caller.products.at(i).type);
-
-//: Rewrite 'load-ingredients' to instructions to create all reagents in the header.
-
-:(before "End Rewrite Instruction(curr, recipe result)")
-if (curr.name == "load-ingredients" || curr.name == "load-inputs") {
-  curr.clear();
-  recipe_ordinal op = get(Recipe_ordinal, "next-ingredient-without-typechecking");
-  for (int i = 0;  i < SIZE(result.ingredients);  ++i) {
-    curr.operation = op;
-    curr.name = "next-ingredient-without-typechecking";
-    curr.products.push_back(result.ingredients.at(i));
-    result.steps.push_back(curr);
-    curr.clear();
-  }
-}
-if (curr.name == "next-ingredient-without-typechecking") {
-  raise << maybe(result.name) << "never call 'next-ingredient-without-typechecking' directly\n" << end();
-  curr.clear();
-}
-
-//: internal version of next-ingredient; don't call this directly
-:(before "End Primitive Recipe Declarations")
-NEXT_INGREDIENT_WITHOUT_TYPECHECKING,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "next-ingredient-without-typechecking", NEXT_INGREDIENT_WITHOUT_TYPECHECKING);
-:(before "End Primitive Recipe Checks")
-case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: {
-  assert(!Current_routine->calls.empty());
-  if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) {
-    products.push_back(
-        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
-    assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
-    products.at(1).push_back(1);
-    ++current_call().next_ingredient_to_process;
-  }
-  else {
-    products.resize(2);
-    // pad the first product with sufficient zeros to match its type
-    products.at(0).resize(size_of(current_instruction().products.at(0)));
-    products.at(1).push_back(0);
-  }
-  break;
-}
-
-//: more useful error messages if someone forgets 'load-ingredients'
-:(code)
-void test_load_ingredients_missing_error() {
-  Hide_errors = true;
-  run(
-      "def foo a:num [\n"
-      "  local-scope\n"
-      "  b:num <- add a:num, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: tried to read ingredient 'a' in 'b:num <- add a:num, 1' but it hasn't been written to yet\n"
-      "error:   did you forget 'load-ingredients'?\n"
-  );
-}
-
-:(after "use-before-set Error")
-if (is_present_in_ingredients(caller, ingredient.name))
-  raise << "  did you forget 'load-ingredients'?\n" << end();
-
-:(code)
-void test_load_ingredients_missing_error_2() {
-  Hide_errors = true;
-  run(
-      "def foo a:num [\n"
-      "  local-scope\n"
-      "  b:num <- add a, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: missing type for 'a' in 'b:num <- add a, 1'\n"
-      "error:   did you forget 'load-ingredients'?\n"
-  );
-}
-
-:(after "missing-type Error 1")
-if (is_present_in_ingredients(get(Recipe, get(Recipe_ordinal, recipe_name)), x.name))
-  raise << "  did you forget 'load-ingredients'?\n" << end();
-
-:(code)
-bool is_present_in_ingredients(const recipe& callee, const string& ingredient_name) {
-  for (int i = 0;  i < SIZE(callee.ingredients);  ++i) {
-    if (callee.ingredients.at(i).name == ingredient_name)
-      return true;
-  }
-  return false;
-}
-
-//:: Check all calls against headers.
-
-void test_show_clear_error_on_bad_call() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- foo 34\n"
-      "]\n"
-      "def foo x:point -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: ingredient 0 has the wrong type at '1:num <- foo 34'\n"
-  );
-}
-
-void test_show_clear_error_on_bad_call_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:point <- foo 34\n"
-      "]\n"
-      "def foo x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: product 0 has the wrong type at '1:point <- foo 34'\n"
-  );
-}
-
-:(after "Transform.push_back(check_instruction)")
-Transform.push_back(check_calls_against_header);  // idempotent
-:(code)
-void check_calls_against_header(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- type-check calls inside recipe " << caller.name << end();
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    if (is_primitive(inst.operation)) continue;
-    const recipe& callee = get(Recipe, inst.operation);
-    if (!callee.has_header) continue;
-    for (long int i = 0;  i < min(SIZE(inst.ingredients), SIZE(callee.ingredients));  ++i) {
-      // ingredients coerced from call to callee
-      if (!types_coercible(callee.ingredients.at(i), inst.ingredients.at(i))) {
-        raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end();
-        raise << "  ['" << to_string(callee.ingredients.at(i).type) << "' vs '" << to_string(inst.ingredients.at(i).type) << "']\n" << end();
-      }
-    }
-    for (long int i = 0;  i < min(SIZE(inst.products), SIZE(callee.products));  ++i) {
-      if (is_dummy(inst.products.at(i))) continue;
-      // products coerced from callee to call
-      if (!types_coercible(inst.products.at(i), callee.products.at(i))) {
-        raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end();
-        raise << "  ['" << to_string(inst.products.at(i).type) << "' vs '" << to_string(callee.products.at(i).type) << "']\n" << end();
-      }
-    }
-  }
-}
-
-//:: Check types going in and out of all recipes with headers.
-
-void test_recipe_headers_are_checked() {
-  Hide_errors = true;
-  transform(
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:&:num <- copy 0/unsafe\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: add2: replied with the wrong type at 'return z'\n"
-  );
-}
-
-:(before "End Checks")
-Transform.push_back(check_return_instructions_against_header);  // idempotent
-
-:(code)
-void check_return_instructions_against_header(const recipe_ordinal r) {
-  const recipe& caller_recipe = get(Recipe, r);
-  if (!caller_recipe.has_header) return;
-  trace(101, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end();
-  for (int i = 0;  i < SIZE(caller_recipe.steps);  ++i) {
-    const instruction& inst = caller_recipe.steps.at(i);
-    if (inst.name != "reply" && inst.name != "return") continue;
-    if (SIZE(caller_recipe.products) != SIZE(inst.ingredients)) {
-      raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << to_original_string(inst) << "'\n" << end();
-      continue;
-    }
-    for (int i = 0;  i < SIZE(caller_recipe.products);  ++i) {
-      if (!types_match(caller_recipe.products.at(i), inst.ingredients.at(i)))
-        raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << to_original_string(inst) << "'\n" << end();
-    }
-  }
-}
-
-void test_recipe_headers_are_checked_2() {
-  Hide_errors = true;
-  transform(
-      "def add2 x:num, y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:&:num <- copy 0/unsafe\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: add2: replied with the wrong number of products at 'return z'\n"
-  );
-}
-
-void test_recipe_headers_are_checked_against_pre_transformed_instructions() {
-  Hide_errors = true;
-  transform(
-      "def foo -> x:num [\n"
-      "  local-scope\n"
-      "  x:num <- copy 0\n"
-      "  z:bool <- copy false\n"
-      "  return-if z, z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: replied with the wrong type at 'return-if z, z'\n"
-  );
-}
-
-void test_recipe_headers_check_for_duplicate_names() {
-  Hide_errors = true;
-  transform(
-      "def foo x:num, x:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: 'x' can't repeat in the ingredients\n"
-  );
-}
-
-void test_recipe_headers_check_for_duplicate_names_2() {
-  Hide_errors = true;
-  transform(
-      "def foo x:num, x:num [  # no result\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: 'x' can't repeat in the ingredients\n"
-  );
-}
-
-void test_recipe_headers_check_for_missing_types() {
-  Hide_errors = true;
-  transform(
-      "def main [\n"
-      "  foo 0\n"
-      "]\n"
-      "def foo a [\n"  // no type for 'a'
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: ingredient 'a' has no type\n"
-  );
-}
-
-:(before "End recipe Fields")
-map<string, int> ingredient_index;
-
-:(after "Begin Instruction Modifying Transforms")
-Transform.push_back(check_header_ingredients);  // idempotent
-
-:(code)
-void check_header_ingredients(const recipe_ordinal r) {
-  recipe& caller_recipe = get(Recipe, r);
-  caller_recipe.ingredient_index.clear();
-  trace(101, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end();
-  for (int i = 0;  i < SIZE(caller_recipe.ingredients);  ++i) {
-    if (caller_recipe.ingredients.at(i).type == NULL)
-      raise << maybe(caller_recipe.name) << "ingredient '" << caller_recipe.ingredients.at(i).name << "' has no type\n" << end();
-    if (contains_key(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name))
-      raise << maybe(caller_recipe.name) << "'" << caller_recipe.ingredients.at(i).name << "' can't repeat in the ingredients\n" << end();
-    put(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name, i);
-  }
-}
-
-//: Deduce types from the header if possible.
-
-void test_deduce_instruction_types_from_recipe_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- add x, y  # no type for z\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-:(after "Begin Type Modifying Transforms")
-Transform.push_back(deduce_types_from_header);  // idempotent
-
-:(code)
-void deduce_types_from_header(const recipe_ordinal r) {
-  recipe& caller_recipe = get(Recipe, r);
-  if (caller_recipe.products.empty()) return;
-  trace(101, "transform") << "--- deduce types from header for " << caller_recipe.name << end();
-  map<string, const type_tree*> header_type;
-  for (int i = 0;  i < SIZE(caller_recipe.ingredients);  ++i) {
-    if (!caller_recipe.ingredients.at(i).type) continue;  // error handled elsewhere
-    put(header_type, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).type);
-    trace(103, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end();
-  }
-  for (int i = 0;  i < SIZE(caller_recipe.products);  ++i) {
-    if (!caller_recipe.products.at(i).type) continue;  // error handled elsewhere
-    put(header_type, caller_recipe.products.at(i).name, caller_recipe.products.at(i).type);
-    trace(103, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end();
-  }
-  for (int i = 0;  i < SIZE(caller_recipe.steps);  ++i) {
-    instruction& inst = caller_recipe.steps.at(i);
-    trace(102, "transform") << "instruction: " << to_string(inst) << end();
-    for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-      if (inst.ingredients.at(i).type) continue;
-      if (header_type.find(inst.ingredients.at(i).name) == header_type.end())
-        continue;
-      if (!contains_key(header_type, inst.ingredients.at(i).name)) continue;  // error handled elsewhere
-      inst.ingredients.at(i).type = new type_tree(*get(header_type, inst.ingredients.at(i).name));
-      trace(103, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end();
-    }
-    for (int i = 0;  i < SIZE(inst.products);  ++i) {
-      trace(103, "transform") << "  product: " << to_string(inst.products.at(i)) << end();
-      if (inst.products.at(i).type) continue;
-      if (header_type.find(inst.products.at(i).name) == header_type.end())
-        continue;
-      if (!contains_key(header_type, inst.products.at(i).name)) continue;  // error handled elsewhere
-      inst.products.at(i).type = new type_tree(*get(header_type, inst.products.at(i).name));
-      trace(103, "transform") << "type of " << inst.products.at(i).name << " is " << names_to_string(inst.products.at(i).type) << end();
-    }
-  }
-}
-
-//: One final convenience: no need to say what to return if the information is
-//: in the header.
-
-void test_return_based_on_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- add x, y\n"
-      "  return\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-:(after "Transform.push_back(check_header_ingredients)")
-Transform.push_back(fill_in_return_ingredients);  // idempotent
-
-:(code)
-void fill_in_return_ingredients(const recipe_ordinal r) {
-  recipe& caller_recipe = get(Recipe, r);
-  trace(101, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe.name << end();
-  if (!caller_recipe.has_header) return;
-  for (int i = 0;  i < SIZE(caller_recipe.steps);  ++i) {
-    instruction& inst = caller_recipe.steps.at(i);
-    if (inst.name == "reply" || inst.name == "return")
-      add_header_products(inst, caller_recipe);
-  }
-  // fall through return
-  if (!caller_recipe.steps.empty()) {
-    const instruction& final_instruction = caller_recipe.steps.at(SIZE(caller_recipe.steps)-1);
-    if (final_instruction.name == "reply" || final_instruction.name == "return")
-      return;
-  }
-  instruction inst;
-  inst.name = "return";
-  add_header_products(inst, caller_recipe);
-  caller_recipe.steps.push_back(inst);
-}
-
-void add_header_products(instruction& inst, const recipe& caller_recipe) {
-  assert(inst.name == "reply" || inst.name == "return");
-  // collect any products with the same names as ingredients
-  for (int i = 0;  i < SIZE(caller_recipe.products);  ++i) {
-    // if the ingredient is missing, add it from the header
-    if (SIZE(inst.ingredients) == i)
-      inst.ingredients.push_back(caller_recipe.products.at(i));
-    // if it's missing /same_as_ingredient, try to fill it in
-    if (contains_key(caller_recipe.ingredient_index, caller_recipe.products.at(i).name) && !has_property(inst.ingredients.at(i), "same_as_ingredient")) {
-      ostringstream same_as_ingredient;
-      same_as_ingredient << get(caller_recipe.ingredient_index, caller_recipe.products.at(i).name);
-      inst.ingredients.at(i).properties.push_back(pair<string, string_tree*>("same-as-ingredient", new string_tree(same_as_ingredient.str())));
-    }
-  }
-}
-
-void test_explicit_return_ignores_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw, 2:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 a:num, b:num -> y:num, z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- add a, b\n"
-      "  z <- subtract a, b\n"
-      "  return a, z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 1\n"
-      "mem: storing -2 in location 2\n"
-  );
-}
-
-void test_return_on_fallthrough_based_on_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- add x, y\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: instruction: return {z: \"number\"}\n"
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-void test_return_on_fallthrough_already_exists() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- add x, y  # no type for z\n"
-      "  return z\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: instruction: return {z: ()}\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("transform: instruction: return z:num");
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-void test_return_causes_error_in_empty_recipe() {
-  Hide_errors = true;
-  run(
-      "def foo -> x:num [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: tried to read ingredient 'x' in 'return x:num' but it hasn't been written to yet\n"
-  );
-}
-
-void test_return_after_conditional_return_based_on_header() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- add2 3, 5\n"
-      "]\n"
-      "def add2 x:num, y:num -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- add x, y\n"  // no type for z
-      "  return-if false, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
-
-void test_recipe_headers_perform_same_ingredient_check() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:num <- add2 1:num, 2:num\n"
-      "]\n"
-      "def add2 x:num, y:num -> x:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: '3:num <- add2 1:num, 2:num' should write to '1:num' rather than '3:num'\n"
-  );
-}
-
-//: One special-case is recipe 'main'. Make sure it's only ever taking in text
-//: ingredients, and returning a single number.
-
-void test_recipe_header_ingredients_constrained_for_main() {
-  Hide_errors = true;
-  run(
-      "def main x:num [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: ingredients of recipe 'main' must all be text (address:array:character)\n"
-  );
-}
-void test_recipe_header_products_constrained_for_main() {
-  Hide_errors = true;
-  run(
-      "def main -> x:text [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: recipe 'main' must return at most a single product, a number\n"
-  );
-}
-void test_recipe_header_products_constrained_for_main_2() {
-  Hide_errors = true;
-  run(
-      "def main -> x:num, y:num [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: recipe 'main' must return at most a single product, a number\n"
-  );
-}
-
-:(after "Transform.push_back(expand_type_abbreviations)")
-Transform.push_back(check_recipe_header_constraints);
-:(code)
-void check_recipe_header_constraints(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  if (caller.name != "main") return;
-  trace(102, "transform") << "check recipe header constraints for recipe " << caller.name << end();
-  if (!caller.has_header) return;
-  reagent/*local*/ expected_ingredient("x:address:array:character");
-  for (int i = 0; i < SIZE(caller.ingredients); ++i) {
-    if (!types_strictly_match(expected_ingredient, caller.ingredients.at(i))) {
-      raise << "ingredients of recipe 'main' must all be text (address:array:character)\n" << end();
-      break;
-    }
-  }
-  int nprod = SIZE(caller.products);
-  reagent/*local*/ expected_product("x:number");
-  if (nprod > 1
-      || (nprod == 1 && !types_strictly_match(expected_product, caller.products.at(0)))) {
-    raise << "recipe 'main' must return at most a single product, a number\n" << end();
-  }
-}
diff --git a/archive/2.vm/054static_dispatch.cc b/archive/2.vm/054static_dispatch.cc
deleted file mode 100644
index 289dce87..00000000
--- a/archive/2.vm/054static_dispatch.cc
+++ /dev/null
@@ -1,683 +0,0 @@
-//: Transform to maintain multiple variants of a recipe depending on the
-//: number and types of the ingredients and products. Allows us to use nice
-//: names like 'print' or 'length' in many mutually extensible ways.
-
-void test_static_dispatch() {
-  run(
-      "def main [\n"
-      "  7:num/raw <- test 3\n"
-      "]\n"
-      "def test a:num -> z:num [\n"
-      "  z <- copy 1\n"
-      "]\n"
-      "def test a:num, b:num -> z:num [\n"
-      "  z <- copy 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 7\n"
-  );
-}
-
-//: When loading recipes, accumulate variants if headers don't collide, and
-//: flag an error if headers collide.
-
-:(before "End Globals")
-map<string, vector<recipe_ordinal> > Recipe_variants;
-:(before "End One-time Setup")
-put(Recipe_variants, "main", vector<recipe_ordinal>());  // since we manually added main to Recipe_ordinal
-
-:(before "End Globals")
-map<string, vector<recipe_ordinal> > Recipe_variants_snapshot;
-:(before "End save_snapshots")
-Recipe_variants_snapshot = Recipe_variants;
-:(before "End restore_snapshots")
-Recipe_variants = Recipe_variants_snapshot;
-
-:(before "End Load Recipe Header(result)")
-// there can only ever be one variant for main
-if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
-  const recipe_ordinal r = get(Recipe_ordinal, result.name);
-  if (!contains_key(Recipe, r) || get(Recipe, r).has_header) {
-    string new_name = matching_variant_name(result);
-    if (new_name.empty()) {
-      // variant doesn't already exist
-      new_name = next_unused_recipe_name(result.name);
-      put(Recipe_ordinal, new_name, Next_recipe_ordinal++);
-      get_or_insert(Recipe_variants, result.name).push_back(get(Recipe_ordinal, new_name));
-    }
-    trace(101, "load") << "switching " << result.name << " to " << new_name << end();
-    result.name = new_name;
-    result.is_autogenerated = true;
-  }
-}
-else {
-  // save first variant
-  put(Recipe_ordinal, result.name, Next_recipe_ordinal++);
-  get_or_insert(Recipe_variants, result.name).push_back(get(Recipe_ordinal, result.name));
-}
-
-:(code)
-string matching_variant_name(const recipe& rr) {
-  const vector<recipe_ordinal>& variants = get_or_insert(Recipe_variants, rr.name);
-  for (int i = 0;  i < SIZE(variants);  ++i) {
-    if (!contains_key(Recipe, variants.at(i))) continue;
-    const recipe& candidate = get(Recipe, variants.at(i));
-    if (!all_reagents_match(rr, candidate)) continue;
-    return candidate.name;
-  }
-  return "";
-}
-
-bool all_reagents_match(const recipe& r1, const recipe& r2) {
-  if (SIZE(r1.ingredients) != SIZE(r2.ingredients)) return false;
-  if (SIZE(r1.products) != SIZE(r2.products)) return false;
-  for (int i = 0;  i < SIZE(r1.ingredients);  ++i) {
-    expand_type_abbreviations(r1.ingredients.at(i).type);
-    expand_type_abbreviations(r2.ingredients.at(i).type);
-    if (!deeply_equal_type_names(r1.ingredients.at(i), r2.ingredients.at(i)))
-      return false;
-  }
-  for (int i = 0;  i < SIZE(r1.products);  ++i) {
-    expand_type_abbreviations(r1.products.at(i).type);
-    expand_type_abbreviations(r2.products.at(i).type);
-    if (!deeply_equal_type_names(r1.products.at(i), r2.products.at(i)))
-      return false;
-  }
-  return true;
-}
-
-:(before "End Globals")
-set<string> Literal_type_names;
-:(before "End One-time Setup")
-Literal_type_names.insert("number");
-Literal_type_names.insert("character");
-:(code)
-bool deeply_equal_type_names(const reagent& a, const reagent& b) {
-  return deeply_equal_type_names(a.type, b.type);
-}
-bool deeply_equal_type_names(const type_tree* a, const type_tree* b) {
-  if (!a) return !b;
-  if (!b) return !a;
-  if (a->atom != b->atom) return false;
-  if (a->atom) {
-    if (a->name == "literal" && b->name == "literal")
-      return true;
-    if (a->name == "literal")
-      return Literal_type_names.find(b->name) != Literal_type_names.end();
-    if (b->name == "literal")
-      return Literal_type_names.find(a->name) != Literal_type_names.end();
-    return a->name == b->name;
-  }
-  return deeply_equal_type_names(a->left, b->left)
-      && deeply_equal_type_names(a->right, b->right);
-}
-
-string next_unused_recipe_name(const string& recipe_name) {
-  for (int i = 2;  /*forever*/;  ++i) {
-    ostringstream out;
-    out << recipe_name << '_' << i;
-    if (!contains_key(Recipe_ordinal, out.str()))
-      return out.str();
-  }
-}
-
-//: Once all the recipes are loaded, transform their bodies to replace each
-//: call with the most suitable variant.
-
-void test_static_dispatch_picks_most_similar_variant() {
-  run(
-      "def main [\n"
-      "  7:num/raw <- test 3, 4, 5\n"
-      "]\n"
-      "def test a:num -> z:num [\n"
-      "  z <- copy 1\n"
-      "]\n"
-      "def test a:num, b:num -> z:num [\n"
-      "  z <- copy 2\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 7\n"
-  );
-}
-
-//: support recipe headers in a previous transform to fill in missing types
-:(before "End check_or_set_invalid_types")
-for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-  check_or_set_invalid_types(caller.ingredients.at(i).type, maybe(caller.name), "recipe header ingredient");
-for (int i = 0;  i < SIZE(caller.products);  ++i)
-  check_or_set_invalid_types(caller.products.at(i).type, maybe(caller.name), "recipe header product");
-
-//: save original name of recipes before renaming them
-:(before "End recipe Fields")
-string original_name;
-//: original name is only set during load
-:(before "End Load Recipe Name")
-result.original_name = result.name;
-
-//: after filling in all missing types (because we'll be introducing 'blank' types in this transform in a later layer, for shape-shifting recipes)
-:(after "Transform.push_back(transform_names)")
-Transform.push_back(resolve_ambiguous_calls);  // idempotent
-
-//: In a later layer we'll introduce recursion in resolve_ambiguous_calls, by
-//: having it generate code for shape-shifting recipes and then transform such
-//: code. This data structure will help error messages be more useful.
-//:
-//: We're punning the 'call' data structure just because it has slots for
-//: calling recipe and calling instruction.
-:(before "End Globals")
-list<call> Resolve_stack;
-
-:(code)
-void resolve_ambiguous_calls(const recipe_ordinal r) {
-  recipe& caller_recipe = get(Recipe, r);
-  trace(101, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end();
-  for (int index = 0;  index < SIZE(caller_recipe.steps);  ++index) {
-    instruction& inst = caller_recipe.steps.at(index);
-    if (inst.is_label) continue;
-    resolve_ambiguous_call(r, index, inst, caller_recipe);
-  }
-}
-
-void resolve_ambiguous_call(const recipe_ordinal r, int index, instruction& inst, const recipe& caller_recipe) {
-  // End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases
-  if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) return;
-  trace(102, "transform") << "instruction " << to_original_string(inst) << end();
-  Resolve_stack.push_front(call(r, index));
-  string new_name = best_variant(inst, caller_recipe);
-  if (!new_name.empty())
-    inst.name = new_name;
-  assert(Resolve_stack.front().running_recipe == r);
-  assert(Resolve_stack.front().running_step_index == index);
-  Resolve_stack.pop_front();
-}
-
-string best_variant(const instruction& inst, const recipe& caller_recipe) {
-  const vector<recipe_ordinal>& variants = get(Recipe_variants, inst.name);
-  vector<recipe_ordinal> candidates;
-
-  // Static Dispatch Phase 1
-//?   cerr << inst.name << " phase 1\n";
-  candidates = strictly_matching_variants(inst, variants);
-  if (!candidates.empty()) return best_variant(inst, candidates).name;
-
-//?   cerr << inst.name << " phase 3\n";
-  // Static Dispatch Phase 2
-  //: (shape-shifting recipes in a later layer)
-  // End Static Dispatch Phase 2
-
-  // Static Dispatch Phase 3
-//?   cerr << inst.name << " phase 4\n";
-  candidates = matching_variants(inst, variants);
-  if (!candidates.empty()) return best_variant(inst, candidates).name;
-
-  // error messages
-  if (!is_primitive(get(Recipe_ordinal, inst.name))) {  // we currently don't check types for primitive variants
-    if (SIZE(variants) == 1) {
-      raise << maybe(caller_recipe.name) << "types don't match in call for '" << to_original_string(inst) << "'\n" << end();
-      raise << "  which tries to call '" << original_header_label(get(Recipe, variants.at(0))) << "'\n" << end();
-    }
-    else {
-      raise << maybe(caller_recipe.name) << "failed to find a matching call for '" << to_original_string(inst) << "'\n" << end();
-      raise << "  available variants are:\n" << end();
-      for (int i = 0;  i < SIZE(variants);  ++i)
-        raise << "    " << original_header_label(get(Recipe, variants.at(i))) << '\n' << end();
-    }
-    for (list<call>::iterator p = /*skip*/++Resolve_stack.begin();  p != Resolve_stack.end();  ++p) {
-      const recipe& specializer_recipe = get(Recipe, p->running_recipe);
-      const instruction& specializer_inst = specializer_recipe.steps.at(p->running_step_index);
-      if (specializer_recipe.name != "interactive")
-        raise << "  (from '" << to_original_string(specializer_inst) << "' in " << specializer_recipe.name << ")\n" << end();
-      else
-        raise << "  (from '" << to_original_string(specializer_inst) << "')\n" << end();
-      // One special-case to help with the rewrite_stash transform. (cross-layer)
-      if (specializer_inst.products.at(0).name.find("stash_") == 0) {
-        instruction stash_inst;
-        if (next_stash(*p, &stash_inst)) {
-          if (specializer_recipe.name != "interactive")
-            raise << "  (part of '" << to_original_string(stash_inst) << "' in " << specializer_recipe.name << ")\n" << end();
-          else
-            raise << "  (part of '" << to_original_string(stash_inst) << "')\n" << end();
-        }
-      }
-    }
-  }
-  return "";
-}
-
-// phase 1
-vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, const vector<recipe_ordinal>& variants) {
-  vector<recipe_ordinal> result;
-  for (int i = 0;  i < SIZE(variants);  ++i) {
-    if (variants.at(i) == -1) continue;
-    trace(102, "transform") << "checking variant (strict) " << i << ": " << header_label(variants.at(i)) << end();
-    if (all_header_reagents_strictly_match(inst, get(Recipe, variants.at(i))))
-      result.push_back(variants.at(i));
-  }
-  return result;
-}
-
-bool all_header_reagents_strictly_match(const instruction& inst, const recipe& variant) {
-  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
-    if (!types_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) {
-      trace(103, "transform") << "strict match failed: ingredient " << i << end();
-      return false;
-    }
-  }
-  for (int i = 0;  i < min(SIZE(inst.products), SIZE(variant.products));  ++i) {
-    if (is_dummy(inst.products.at(i))) continue;
-    if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) {
-      trace(103, "transform") << "strict match failed: product " << i << end();
-      return false;
-    }
-  }
-  return true;
-}
-
-// phase 3
-vector<recipe_ordinal> matching_variants(const instruction& inst, const vector<recipe_ordinal>& variants) {
-  vector<recipe_ordinal> result;
-  for (int i = 0;  i < SIZE(variants);  ++i) {
-    if (variants.at(i) == -1) continue;
-    trace(102, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end();
-    if (all_header_reagents_match(inst, get(Recipe, variants.at(i))))
-      result.push_back(variants.at(i));
-  }
-  return result;
-}
-
-bool all_header_reagents_match(const instruction& inst, const recipe& variant) {
-  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
-    if (!types_match(variant.ingredients.at(i), inst.ingredients.at(i))) {
-      trace(103, "transform") << "match failed: ingredient " << i << end();
-      return false;
-    }
-  }
-  for (int i = 0;  i < min(SIZE(variant.products), SIZE(inst.products));  ++i) {
-    if (is_dummy(inst.products.at(i))) continue;
-    if (!types_match(variant.products.at(i), inst.products.at(i))) {
-      trace(103, "transform") << "match failed: product " << i << end();
-      return false;
-    }
-  }
-  return true;
-}
-
-// tie-breaker for each phase
-const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& candidates) {
-  assert(!candidates.empty());
-  if (SIZE(candidates) == 1) return get(Recipe, candidates.at(0));
-  int min_score = 999;
-  int min_index = 0;
-  for (int i = 0;  i < SIZE(candidates);  ++i) {
-    const recipe& candidate = get(Recipe, candidates.at(i));
-    // prefer variants without extra or missing ingredients or products
-    int score = abs(SIZE(candidate.products)-SIZE(inst.products))
-                          + abs(SIZE(candidate.ingredients)-SIZE(inst.ingredients));
-    // prefer variants with non-address ingredients or products
-    for (int j = 0;  j < SIZE(candidate.ingredients);  ++j) {
-      if (is_mu_address(candidate.ingredients.at(j)))
-        ++score;
-    }
-    for (int j = 0;  j < SIZE(candidate.products);  ++j) {
-      if (is_mu_address(candidate.products.at(j)))
-        ++score;
-    }
-    assert(score < 999);
-    if (score < min_score) {
-      min_score = score;
-      min_index = i;
-    }
-  }
-  return get(Recipe, candidates.at(min_index));
-}
-
-int non_ghost_size(vector<recipe_ordinal>& variants) {
-  int result = 0;
-  for (int i = 0;  i < SIZE(variants);  ++i)
-    if (variants.at(i) != -1) ++result;
-  return result;
-}
-
-bool next_stash(const call& c, instruction* stash_inst) {
-  const recipe& specializer_recipe = get(Recipe, c.running_recipe);
-  int index = c.running_step_index;
-  for (++index;  index < SIZE(specializer_recipe.steps);  ++index) {
-    const instruction& inst = specializer_recipe.steps.at(index);
-    if (inst.name == "stash") {
-      *stash_inst = inst;
-      return true;
-    }
-  }
-  return false;
-}
-
-void test_static_dispatch_disabled_in_recipe_without_variants() {
-  run(
-      "def main [\n"
-      "  1:num <- test 3\n"
-      "]\n"
-      "def test [\n"
-      "  2:num <- next-ingredient  # ensure no header\n"
-      "  return 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_static_dispatch_disabled_on_headerless_definition() {
-  Hide_errors = true;
-  run(
-      "def test a:num -> z:num [\n"
-      "  z <- copy 1\n"
-      "]\n"
-      "def test [\n"
-      "  return 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: redefining recipe test\n"
-  );
-}
-
-void test_static_dispatch_disabled_on_headerless_definition_2() {
-  Hide_errors = true;
-  run(
-      "def test [\n"
-      "  return 34\n"
-      "]\n"
-      "def test a:num -> z:num [\n"
-      "  z <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: redefining recipe test\n"
-  );
-}
-
-void test_static_dispatch_on_primitive_names() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 34\n"
-      "  3:bool <- equal 1:num, 2:num\n"
-      "  4:bool <- copy false\n"
-      "  5:bool <- copy false\n"
-      "  6:bool <- equal 4:bool, 5:bool\n"
-      "]\n"
-      // temporarily hardcode number equality to always fail
-      "def equal x:num, y:num -> z:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- copy false\n"
-      "]\n"
-      "# comparing numbers used overload\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // comparing numbers used overload
-      "mem: storing 0 in location 3\n"
-      // comparing booleans continues to use primitive
-      "mem: storing 1 in location 6\n"
-  );
-}
-
-void test_static_dispatch_works_with_dummy_results_for_containers() {
-  run(
-      "def main [\n"
-      "  _ <- test 3, 4\n"
-      "]\n"
-      "def test a:num -> z:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- merge a, 0\n"
-      "]\n"
-      "def test a:num, b:num -> z:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z <- merge a, b\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_static_dispatch_works_with_compound_type_containing_container_defined_after_first_use() {
-  run(
-      "def main [\n"
-      "  x:&:foo <- new foo:type\n"
-      "  test x\n"
-      "]\n"
-      "container foo [\n"
-      "  x:num\n"
-      "]\n"
-      "def test a:&:foo -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:num <- get *a, x:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_static_dispatch_works_with_compound_type_containing_container_defined_after_second_use() {
-  run(
-      "def main [\n"
-      "  x:&:foo <- new foo:type\n"
-      "  test x\n"
-      "]\n"
-      "def test a:&:foo -> z:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  z:num <- get *a, x:offset\n"
-      "]\n"
-      "container foo [\n"
-      "  x:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_static_dispatch_on_non_literal_character_ignores_variant_with_numbers() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:char <- copy 10/newline\n"
-      "  1:num/raw <- foo x\n"
-      "]\n"
-      "def foo x:num -> y:num [\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: ingredient 0 has the wrong type at '1:num/raw <- foo x'\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 34 in location 1");
-}
-
-void test_static_dispatch_dispatches_literal_to_character() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- foo 97\n"
-      "]\n"
-      "def foo x:char -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "# character variant is preferred\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_static_dispatch_dispatches_literal_to_number_if_at_all_possible() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- foo 97\n"
-      "]\n"
-      "def foo x:char -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      // number variant is preferred
-      "mem: storing 35 in location 1\n"
-  );
-}
-
-:(replace{} "string header_label(const recipe_ordinal r)")
-string header_label(const recipe_ordinal r) {
-  return header_label(get(Recipe, r));
-}
-:(code)
-string header_label(const recipe& caller) {
-  ostringstream out;
-  out << "recipe " << caller.name;
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-    out << ' ' << to_string(caller.ingredients.at(i));
-  if (!caller.products.empty()) out << " ->";
-  for (int i = 0;  i < SIZE(caller.products);  ++i)
-    out << ' ' << to_string(caller.products.at(i));
-  return out.str();
-}
-
-string original_header_label(const recipe& caller) {
-  ostringstream out;
-  out << "recipe " << caller.original_name;
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-    out << ' ' << caller.ingredients.at(i).original_string;
-  if (!caller.products.empty()) out << " ->";
-  for (int i = 0;  i < SIZE(caller.products);  ++i)
-    out << ' ' << caller.products.at(i).original_string;
-  return out.str();
-}
-
-void test_reload_variant_retains_other_variants() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- foo 1:num\n"
-      "]\n"
-      "def foo x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo x:&:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-      "def! foo x:&:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 2\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_dispatch_errors_come_after_unknown_name_errors() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  y:num <- foo x\n"
-      "]\n"
-      "def foo a:num -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo a:bool -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'x' in 'y:num <- foo x'\n"
-      "error: main: failed to find a matching call for 'y:num <- foo x'\n"
-  );
-}
-
-void test_override_methods_with_type_abbreviations() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  s:text <- new [abc]\n"
-      "  1:num/raw <- foo s\n"
-      "]\n"
-      "def foo a:address:array:character -> result:number [\n"
-      "  return 34\n"
-      "]\n"
-      // identical to previous variant once you take type abbreviations into account
-      "def! foo a:text -> result:num [\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 1\n"
-  );
-}
-
-void test_ignore_static_dispatch_in_type_errors_without_overloading() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:&:num <- copy 0\n"
-      "  foo x\n"
-      "]\n"
-      "def foo x:&:char [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: types don't match in call for 'foo x'\n"
-      "error:   which tries to call 'recipe foo x:&:char'\n"
-  );
-}
-
-void test_show_available_variants_in_dispatch_errors() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:&:num <- copy 0\n"
-      "  foo x\n"
-      "]\n"
-      "def foo x:&:char [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-      "def foo x:&:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: failed to find a matching call for 'foo x'\n"
-      "error:   available variants are:\n"
-      "error:     recipe foo x:&:char\n"
-      "error:     recipe foo x:&:bool\n"
-  );
-}
-
-:(before "End Includes")
-using std::abs;
diff --git a/archive/2.vm/055shape_shifting_container.cc b/archive/2.vm/055shape_shifting_container.cc
deleted file mode 100644
index 909e6fc5..00000000
--- a/archive/2.vm/055shape_shifting_container.cc
+++ /dev/null
@@ -1,773 +0,0 @@
-//:: Container definitions can contain 'type ingredients'
-
-//: pre-requisite: extend our notion of containers to not necessarily be
-//: atomic types
-:(after "Update GET base_type in Check")
-base_type = get_base_type(base_type);
-:(after "Update GET base_type in Run")
-base_type = get_base_type(base_type);
-:(after "Update PUT base_type in Check")
-base_type = get_base_type(base_type);
-:(after "Update PUT base_type in Run")
-base_type = get_base_type(base_type);
-:(after "Update MAYBE_CONVERT base_type in Check")
-base_type = get_base_type(base_type);
-:(after "Update base_type in element_type")
-base_type = get_base_type(base_type);
-:(after "Update base_type in skip_addresses")
-base_type = get_base_type(base_type);
-:(replace{} "const type_tree* get_base_type(const type_tree* t)")
-const type_tree* get_base_type(const type_tree* t) {
-  const type_tree* result = t->atom ? t : t->left;
-  if (!result->atom)
-    raise << "invalid type " << to_string(t) << '\n' << end();
-  return result;
-}
-
-:(code)
-void test_ill_formed_container() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  {1: ((foo) num)} <- copy 0\n"
-      "]\n"
-  );
-  // no crash
-}
-
-//: update size_of to handle non-atom container types
-
-void test_size_of_shape_shifting_container() {
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:num <- merge 12, 13\n"
-      "  3:foo:point <- merge 14, 15, 16\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 12 in location 1\n"
-      "mem: storing 13 in location 2\n"
-      "mem: storing 14 in location 3\n"
-      "mem: storing 15 in location 4\n"
-      "mem: storing 16 in location 5\n"
-  );
-}
-void test_size_of_shape_shifting_container_2() {
-  run(
-      // multiple type ingredients
-      "container foo:_a:_b [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:num:bool <- merge 34, true\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-void test_size_of_shape_shifting_container_3() {
-  run(
-      "container foo:_a:_b [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "]\n"
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-         // compound types for type ingredients
-      "  {3: (foo number (address array character))} <- merge 34/x, 1:text/y\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_size_of_shape_shifting_container_4() {
-  run(
-      "container foo:_a:_b [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "]\n"
-      "container bar:_a:_b [\n"
-         // dilated element
-      "  {data: (foo _a (address _b))}\n"
-      "]\n"
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  3:bar:num:@:char <- merge 34/x, 1:text/y\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_shape_shifting_container_extend() {
-  run(
-      "container foo:_a [\n"
-      "  x:_a\n"
-      "]\n"
-      "container foo:_a [\n"
-      "  y:_a\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_shape_shifting_container_extend_error() {
-  Hide_errors = true;
-  run(
-      "container foo:_a [\n"
-      "  x:_a\n"
-      "]\n"
-      "container foo:_b [\n"
-      "  y:_b\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: headers of container 'foo' must use identical type ingredients\n"
-  );
-}
-
-void test_type_ingredient_must_start_with_underscore() {
-  Hide_errors = true;
-  run(
-      "container foo:t [\n"
-      "  x:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: type ingredient 't' must begin with an underscore\n"
-  );
-}
-
-:(before "End Globals")
-// We'll use large type ordinals to mean "the following type of the variable".
-// For example, if we have a generic type called foo:_elem, the type
-// ingredient _elem in foo's type_info will have value START_TYPE_INGREDIENTS,
-// and we'll handle it by looking in the current reagent for the next type
-// that appears after foo.
-extern const int START_TYPE_INGREDIENTS = 2000;
-:(before "End Commandline Parsing")  // after loading .mu files
-assert(Next_type_ordinal < START_TYPE_INGREDIENTS);
-
-:(before "End type_info Fields")
-map<string, type_ordinal> type_ingredient_names;
-
-//: Suppress unknown type checks in shape-shifting containers.
-
-:(before "Check Container Field Types(info)")
-if (!info.type_ingredient_names.empty()) continue;
-
-:(before "End container Name Refinements")
-if (name.find(':') != string::npos) {
-  trace(101, "parse") << "container has type ingredients; parsing" << end();
-  if (!read_type_ingredients(name, command)) {
-    // error; skip rest of the container definition and continue
-    slurp_balanced_bracket(in);
-    return;
-  }
-}
-
-:(code)
-bool read_type_ingredients(string& name, const string& command) {
-  string save_name = name;
-  istringstream in(save_name);
-  name = slurp_until(in, ':');
-  map<string, type_ordinal> type_ingredient_names;
-  if (!slurp_type_ingredients(in, type_ingredient_names, name)) {
-    return false;
-  }
-  if (contains_key(Type_ordinal, name)
-      && contains_key(Type, get(Type_ordinal, name))) {
-    const type_info& previous_info = get(Type, get(Type_ordinal, name));
-    // we've already seen this container; make sure type ingredients match
-    if (!type_ingredients_match(type_ingredient_names, previous_info.type_ingredient_names)) {
-      raise << "headers of " << command << " '" << name << "' must use identical type ingredients\n" << end();
-      return false;
-    }
-    return true;
-  }
-  // we haven't seen this container before
-  if (!contains_key(Type_ordinal, name) || get(Type_ordinal, name) == 0)
-    put(Type_ordinal, name, Next_type_ordinal++);
-  type_info& info = get_or_insert(Type, get(Type_ordinal, name));
-  info.type_ingredient_names.swap(type_ingredient_names);
-  return true;
-}
-
-bool slurp_type_ingredients(istream& in, map<string, type_ordinal>& out, const string& container_name) {
-  int next_type_ordinal = START_TYPE_INGREDIENTS;
-  while (has_data(in)) {
-    string curr = slurp_until(in, ':');
-    if (curr.empty()) {
-      raise << container_name << ": empty type ingredients not permitted\n" << end();
-      return false;
-    }
-    if (!starts_with(curr, "_")) {
-      raise << container_name << ": type ingredient '" << curr << "' must begin with an underscore\n" << end();
-      return false;
-    }
-    if (out.find(curr) != out.end()) {
-      raise << container_name << ": can't repeat type ingredient name'" << curr << "' in a single container definition\n" << end();
-      return false;
-    }
-    put(out, curr, next_type_ordinal++);
-  }
-  return true;
-}
-
-bool type_ingredients_match(const map<string, type_ordinal>& a, const map<string, type_ordinal>& b) {
-  if (SIZE(a) != SIZE(b)) return false;
-  for (map<string, type_ordinal>::const_iterator p = a.begin();  p != a.end();  ++p) {
-    if (!contains_key(b, p->first)) return false;
-    if (p->second != get(b, p->first)) return false;
-  }
-  return true;
-}
-
-:(before "End insert_container Special-cases")
-// check for use of type ingredients
-else if (is_type_ingredient_name(type->name)) {
-  type->value = get(info.type_ingredient_names, type->name);
-}
-:(code)
-bool is_type_ingredient_name(const string& type) {
-  return starts_with(type, "_");
-}
-
-:(before "End Container Type Checks")
-if (type->value >= START_TYPE_INGREDIENTS
-    && (type->value - START_TYPE_INGREDIENTS) < SIZE(get(Type, type->value).type_ingredient_names))
-  return;
-
-:(code)
-void test_size_of_shape_shifting_exclusive_container() {
-  run(
-      "exclusive-container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:num <- merge 0/x, 34\n"
-      "  3:foo:point <- merge 0/x, 15, 16\n"
-      "  6:foo:point <- merge 1/y, 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: {1: (\"foo\" \"number\")} <- merge {0: \"literal\", \"x\": ()}, {34: \"literal\"}\n"
-      "mem: storing 0 in location 1\n"
-      "mem: storing 34 in location 2\n"
-      "run: {3: (\"foo\" \"point\")} <- merge {0: \"literal\", \"x\": ()}, {15: \"literal\"}, {16: \"literal\"}\n"
-      "mem: storing 0 in location 3\n"
-      "mem: storing 15 in location 4\n"
-      "mem: storing 16 in location 5\n"
-      "run: {6: (\"foo\" \"point\")} <- merge {1: \"literal\", \"y\": ()}, {23: \"literal\"}\n"
-      "mem: storing 1 in location 6\n"
-      "mem: storing 23 in location 7\n"
-      "run: return\n"
-  );
-  // no other stores
-  CHECK_EQ(trace_count_prefix("mem", "storing"), 7);
-}
-
-:(before "End variant_type Special-cases")
-if (contains_type_ingredient(element))
-  replace_type_ingredients(element.type, type->right, info, " while computing variant type of exclusive-container");
-
-:(code)
-void test_get_on_shape_shifting_container() {
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:point <- merge 14, 15, 16\n"
-      "  4:num <- get 1:foo:point, y:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 16 in location 4\n"
-  );
-}
-
-void test_get_on_shape_shifting_container_2() {
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:point <- merge 14, 15, 16\n"
-      "  4:point <- get 1:foo:point, x:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 4\n"
-      "mem: storing 15 in location 5\n"
-  );
-}
-
-void test_get_on_shape_shifting_container_3() {
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:num/alloc-id, 2:num <- copy 0, 34\n"
-      "  3:foo:&:point <- merge 1:&:point, 48\n"
-      "  6:&:point <- get 1:foo:&:point, x:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 6\n"
-      "mem: storing 34 in location 7\n"
-  );
-}
-
-void test_get_on_shape_shifting_container_inside_container() {
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "container bar [\n"
-      "  x:foo:point\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:bar <- merge 14, 15, 16, 17\n"
-      "  5:num <- get 1:bar, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 17 in location 5\n"
-  );
-}
-
-void test_get_on_complex_shape_shifting_container() {
-  run(
-      "container foo:_a:_b [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "]\n"
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  {3: (foo number (address array character))} <- merge 34/x, 1:text/y\n"
-      "  6:text <- get {3: (foo number (address array character))}, y:offset\n"
-      "  8:bool <- equal 1:text, 6:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 8\n"
-  );
-}
-
-:(before "End element_type Special-cases")
-replace_type_ingredients(element, type, info, " while computing element type of container");
-
-:(before "End size_of(type) Non-atom Special-cases")
-assert(type->left->atom);
-if (!contains_key(Type, type->left->value)) {
-  raise << "no such type " << type->left->value << '\n' << end();
-  return 0;
-}
-type_info t = get(Type, type->left->value);
-if (t.kind == CONTAINER) {
-  // size of a container is the sum of the sizes of its elements
-  int result = 0;
-  for (int i = 0; i < SIZE(t.elements); ++i) {
-    // todo: strengthen assertion to disallow mutual type recursion
-    if (get_base_type(t.elements.at(i).type)->value == get_base_type(type)->value) {
-      raise << "container " << t.name << " can't include itself as a member\n" << end();
-      return 0;
-    }
-    result += size_of(element_type(type, i));
-  }
-  return result;
-}
-if (t.kind == EXCLUSIVE_CONTAINER) {
-  // size of an exclusive container is the size of its largest variant
-  // (So like containers, it can't contain arrays.)
-  int result = 0;
-  for (int i = 0; i < SIZE(t.elements); ++i) {
-    reagent tmp;
-    tmp.type = new type_tree(*type);
-    int size = size_of(variant_type(tmp, i));
-    if (size > result) result = size;
-  }
-  // ...+1 for its tag.
-  return result+1;
-}
-
-:(code)
-void test_complex_shape_shifting_exclusive_container() {
-  run(
-      "exclusive-container foo:_a [\n"
-      "  x:_a\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  3:foo:point <- merge 0/variant, 34/xx, 35/xy\n"
-      "  10:point, 20:bool <- maybe-convert 3:foo:point, 0/variant\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 20\n"
-      "mem: storing 35 in location 11\n"
-  );
-}
-
-bool contains_type_ingredient(const reagent& x) {
-  return contains_type_ingredient(x.type);
-}
-
-bool contains_type_ingredient(const type_tree* type) {
-  if (!type) return false;
-  if (type->atom) return type->value >= START_TYPE_INGREDIENTS;
-  return contains_type_ingredient(type->left) || contains_type_ingredient(type->right);
-}
-
-void replace_type_ingredients(reagent& element, const type_tree* caller_type, const type_info& info, const string& location_for_error_messages) {
-  if (contains_type_ingredient(element)) {
-    if (!caller_type->right)
-      raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end();
-    replace_type_ingredients(element.type, caller_type->right, info, location_for_error_messages);
-  }
-}
-
-// replace all type_ingredients in element_type with corresponding elements of callsite_type
-void replace_type_ingredients(type_tree* element_type, const type_tree* callsite_type, const type_info& container_info, const string& location_for_error_messages) {
-  if (!callsite_type) return;  // error but it's already been raised above
-  if (!element_type) return;
-  if (!element_type->atom) {
-    if (element_type->right == NULL && is_type_ingredient(element_type->left)) {
-      int type_ingredient_index = to_type_ingredient_index(element_type->left);
-      if (corresponding(callsite_type, type_ingredient_index, is_final_type_ingredient(type_ingredient_index, container_info))->right) {
-        // replacing type ingredient at end of list, and replacement is a non-degenerate compound type -- (a b) but not (a)
-        replace_type_ingredient_at(type_ingredient_index, element_type, callsite_type, container_info, location_for_error_messages);
-        return;
-      }
-    }
-    replace_type_ingredients(element_type->left, callsite_type, container_info, location_for_error_messages);
-    replace_type_ingredients(element_type->right, callsite_type, container_info, location_for_error_messages);
-    return;
-  }
-  if (is_type_ingredient(element_type))
-    replace_type_ingredient_at(to_type_ingredient_index(element_type), element_type, callsite_type, container_info, location_for_error_messages);
-}
-
-const type_tree* corresponding(const type_tree* type, int index, bool final) {
-  for (const type_tree* curr = type;  curr;  curr = curr->right, --index) {
-    assert_for_now(!curr->atom);
-    if (index == 0)
-      return final ? curr : curr->left;
-  }
-  assert_for_now(false);
-}
-
-bool is_type_ingredient(const type_tree* type) {
-  return type->atom && type->value >= START_TYPE_INGREDIENTS;
-}
-
-int to_type_ingredient_index(const type_tree* type) {
-  assert(type->atom);
-  return type->value-START_TYPE_INGREDIENTS;
-}
-
-void replace_type_ingredient_at(const int type_ingredient_index, type_tree* element_type, const type_tree* callsite_type, const type_info& container_info, const string& location_for_error_messages) {
-  if (!has_nth_type(callsite_type, type_ingredient_index)) {
-    raise << "illegal type " << names_to_string(callsite_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end();
-    return;
-  }
-  *element_type = *nth_type_ingredient(callsite_type, type_ingredient_index, container_info);
-}
-
-const type_tree* nth_type_ingredient(const type_tree* callsite_type, int type_ingredient_index, const type_info& container_info) {
-  bool final = is_final_type_ingredient(type_ingredient_index, container_info);
-  const type_tree* curr = callsite_type;
-  for (int i = 0;  i < type_ingredient_index;  ++i) {
-    assert(curr);
-    assert(!curr->atom);
-//?     cerr << "type ingredient " << i << " is " << to_string(curr->left) << '\n';
-    curr = curr->right;
-  }
-  assert(curr);
-  if (curr->atom) return curr;
-  if (!final) return curr->left;
-  if (!curr->right) return curr->left;
-  return curr;
-}
-
-bool is_final_type_ingredient(int type_ingredient_index, const type_info& container_info) {
-  for (map<string, type_ordinal>::const_iterator p = container_info.type_ingredient_names.begin();
-       p != container_info.type_ingredient_names.end();
-       ++p) {
-    if (p->second > START_TYPE_INGREDIENTS+type_ingredient_index) return false;
-  }
-  return true;
-}
-
-:(before "End Unit Tests")
-void test_replace_type_ingredients_entire() {
-  run("container foo:_elem [\n"
-      "  x:_elem\n"
-      "  y:num\n"
-      "]\n");
-  reagent callsite("x:foo:point");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{x: \"point\"}");
-}
-
-void test_replace_type_ingredients_tail() {
-  run("container foo:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-      "container bar:_elem [\n"
-      "  x:foo:_elem\n"
-      "]\n");
-  reagent callsite("x:bar:point");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{x: (\"foo\" \"point\")}");
-}
-
-void test_replace_type_ingredients_head_tail_multiple() {
-  run("container foo:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-      "container bar:_elem [\n"
-      "  x:foo:_elem\n"
-      "]\n");
-  reagent callsite("x:bar:address:array:character");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{x: (\"foo\" \"address\" \"array\" \"character\")}");
-}
-
-void test_replace_type_ingredients_head_middle() {
-  run("container foo:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-      "container bar:_elem [\n"
-      "  x:foo:_elem:num\n"
-      "]\n");
-  reagent callsite("x:bar:address");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{x: (\"foo\" \"address\" \"number\")}");
-}
-
-void test_replace_last_type_ingredient_with_multiple() {
-  run("container foo:_a:_b [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "]\n");
-  reagent callsite("{f: (foo number (address array character))}");
-  reagent element1 = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element1), "{x: \"number\"}");
-  reagent element2 = element_type(callsite.type, 1);
-  CHECK_EQ(to_string(element2), "{y: (\"address\" \"array\" \"character\")}");
-}
-
-void test_replace_last_type_ingredient_inside_compound() {
-  run("container foo:_a:_b [\n"
-      "  {x: (bar _a (address _b))}\n"
-      "]\n");
-  reagent callsite("f:foo:number:array:character");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(names_to_string_without_quotes(element.type), "(bar number (address array character))");
-}
-
-void test_replace_middle_type_ingredient_with_multiple() {
-  run("container foo:_a:_b:_c [\n"
-      "  x:_a\n"
-      "  y:_b\n"
-      "  z:_c\n"
-      "]\n");
-  reagent callsite("{f: (foo number (address array character) boolean)}");
-  reagent element1 = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element1), "{x: \"number\"}");
-  reagent element2 = element_type(callsite.type, 1);
-  CHECK_EQ(to_string(element2), "{y: (\"address\" \"array\" \"character\")}");
-  reagent element3 = element_type(callsite.type, 2);
-  CHECK_EQ(to_string(element3), "{z: \"boolean\"}");
-}
-
-void test_replace_middle_type_ingredient_with_multiple2() {
-  run("container foo:_key:_value [\n"
-      "  key:_key\n"
-      "  value:_value\n"
-      "]\n");
-  reagent callsite("{f: (foo (address array character) number)}");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{key: (\"address\" \"array\" \"character\")}");
-}
-
-void test_replace_middle_type_ingredient_with_multiple3() {
-  run("container foo_table:_key:_value [\n"
-      "  data:&:@:foo_table_row:_key:_value\n"
-      "]\n"
-      "\n"
-      "container foo_table_row:_key:_value [\n"
-      "  key:_key\n"
-      "  value:_value\n"
-      "]\n");
-  reagent callsite("{f: (foo_table (address array character) number)}");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(to_string(element), "{data: (\"address\" \"array\" \"foo_table_row\" (\"address\" \"array\" \"character\") \"number\")}");
-}
-
-:(code)
-bool has_nth_type(const type_tree* base, int n) {
-  assert(n >= 0);
-  if (!base) return false;
-  if (n == 0) return true;
-  return has_nth_type(base->right, n-1);
-}
-
-void test_get_on_shape_shifting_container_error() {
-  Hide_errors = true;
-  run(
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:point <- merge 14, 15, 16\n"
-      "  10:num <- get 1:foo, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: illegal type \"foo\" seems to be missing a type ingredient or three while computing element type of container\n"
-  );
-  // todo: improve error message
-}
-
-void test_typos_in_container_definitions() {
-  Hide_errors = true;
-  run(
-      "container foo:_t [\n"
-      "  x:adress:_t  # typo\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  x:address:foo:num <- new {(foo num): type}\n"
-      "]\n"
-  );
-  // no crash
-}
-
-void test_typos_in_recipes() {
-  Hide_errors = true;
-  run(
-      "def foo [\n"
-      "  local-scope\n"
-      "  x:adress:array:number <- copy null  # typo\n"
-      "]\n"
-  );
-  // shouldn't crash
-}
-
-//:: 'merge' on shape-shifting containers
-
-void test_merge_check_shape_shifting_container_containing_exclusive_container() {
-  run(
-      "container foo:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:bar <- merge 23, 1/y, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 23 in location 1\n"
-      "mem: storing 1 in location 2\n"
-      "mem: storing 34 in location 3\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_shape_shifting_container_containing_exclusive_container_2() {
-  Hide_errors = true;
-  run(
-      "container foo:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-      "exclusive-container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:bar <- merge 23, 1/y, 34, 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too many ingredients in '1:foo:bar <- merge 23, 1/y, 34, 35'\n"
-  );
-}
-
-void test_merge_check_shape_shifting_exclusive_container_containing_container() {
-  run(
-      "exclusive-container foo:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:bar <- merge 1/y, 23, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 1\n"
-      "mem: storing 23 in location 2\n"
-      "mem: storing 34 in location 3\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_shape_shifting_exclusive_container_containing_container_2() {
-  run(
-      "exclusive-container foo:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:bar <- merge 0/x, 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_merge_check_shape_shifting_exclusive_container_containing_container_3() {
-  Hide_errors = true;
-  run(
-      "exclusive-container foo:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo:bar <- merge 1/y, 23\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: too few ingredients in '1:foo:bar <- merge 1/y, 23'\n"
-  );
-}
diff --git a/archive/2.vm/056shape_shifting_recipe.cc b/archive/2.vm/056shape_shifting_recipe.cc
deleted file mode 100644
index 3e3d9a8d..00000000
--- a/archive/2.vm/056shape_shifting_recipe.cc
+++ /dev/null
@@ -1,1307 +0,0 @@
-//:: Like container definitions, recipes too can contain type parameters.
-
-void test_shape_shifting_recipe() {
-  run(
-      "def main [\n"
-      "  10:point <- merge 14, 15\n"
-      "  12:point <- foo 10:point\n"
-      "]\n"
-      // non-matching variant
-      "def foo a:num -> result:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy 34\n"
-      "]\n"
-      // matching shape-shifting variant
-      "def foo a:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy a\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 12\n"
-      "mem: storing 15 in location 13\n"
-  );
-}
-
-//: Before anything else, disable transforms for shape-shifting recipes and
-//: make sure we never try to actually run a shape-shifting recipe. We should
-//: be rewriting such instructions to *specializations* with the type
-//: ingredients filled in.
-
-//: One exception (and this makes things very ugly): we need to expand type
-//: abbreviations in shape-shifting recipes because we need them types for
-//: deciding which variant to specialize.
-
-:(before "End Transform Checks")
-r.transformed_until = t;
-if (Transform.at(t) != static_cast<transform_fn>(expand_type_abbreviations) && any_type_ingredient_in_header(/*recipe_ordinal*/p->first)) continue;
-
-:(after "Running One Instruction")
-if (Current_routine->calls.front().running_step_index == 0
-    && any_type_ingredient_in_header(Current_routine->calls.front().running_recipe)) {
-//?   DUMP("");
-  raise << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end();
-//?   exit(0);
-}
-
-//: Make sure we don't match up literals with type ingredients without
-//: specialization.
-:(before "End Matching Types For Literal(to)")
-if (contains_type_ingredient_name(to)) return false;
-
-:(after "Static Dispatch Phase 2")
-candidates = strictly_matching_shape_shifting_variants(inst, variants);
-if (!candidates.empty()) {
-  recipe_ordinal exemplar = best_shape_shifting_variant(inst, candidates);
-  trace(102, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end();
-  string new_recipe_name = insert_new_variant(exemplar, inst, caller_recipe);
-  if (new_recipe_name != "") {
-    trace(102, "transform") << "new specialization: " << new_recipe_name << end();
-    return new_recipe_name;
-  }
-}
-
-//: before running Mu programs, make sure no unspecialized shape-shifting
-//: recipes can be called
-
-:(before "End Instruction Operation Checks")
-if (contains_key(Recipe, inst.operation) && !is_primitive(inst.operation)
-    && any_type_ingredient_in_header(inst.operation)) {
-  raise << maybe(caller.name) << "instruction '" << inst.name << "' has no valid specialization\n" << end();
-  return;
-}
-
-:(code)
-// phase 3 of static dispatch
-vector<recipe_ordinal> strictly_matching_shape_shifting_variants(const instruction& inst, const vector<recipe_ordinal>& variants) {
-  vector<recipe_ordinal> result;
-  for (int i = 0;  i < SIZE(variants);  ++i) {
-    if (variants.at(i) == -1) continue;
-    if (!any_type_ingredient_in_header(variants.at(i))) continue;
-    if (!all_concrete_header_reagents_strictly_match(inst, get(Recipe, variants.at(i)))) continue;
-    result.push_back(variants.at(i));
-  }
-  return result;
-}
-
-bool all_concrete_header_reagents_strictly_match(const instruction& inst, const recipe& variant) {
-  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
-    if (!concrete_type_names_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) {
-      trace(103, "transform") << "concrete-type match failed: ingredient " << i << end();
-      return false;
-    }
-  }
-  for (int i = 0;  i < min(SIZE(inst.products), SIZE(variant.products));  ++i) {
-    if (is_dummy(inst.products.at(i))) continue;
-    if (!concrete_type_names_strictly_match(variant.products.at(i), inst.products.at(i))) {
-      trace(103, "transform") << "concrete-type match failed: product " << i << end();
-      return false;
-    }
-  }
-  return true;
-}
-
-// manual prototype
-vector<recipe_ordinal> keep_max(const instruction&, const vector<recipe_ordinal>&,
-                                int (*)(const instruction&, recipe_ordinal));
-
-// tie-breaker for phase 3
-recipe_ordinal best_shape_shifting_variant(const instruction& inst, const vector<recipe_ordinal>& candidates) {
-  assert(!candidates.empty());
-  if (SIZE(candidates) == 1) return candidates.at(0);
-//?   cerr << "A picking shape-shifting variant:\n";
-  vector<recipe_ordinal> result1 = keep_max(inst, candidates, number_of_concrete_type_names);
-  assert(!result1.empty());
-  if (SIZE(result1) == 1) return result1.at(0);
-//?   cerr << "B picking shape-shifting variant:\n";
-  vector<recipe_ordinal> result2 = keep_max(inst, result1, arity_fit);
-  assert(!result2.empty());
-  if (SIZE(result2) == 1) return result2.at(0);
-//?   cerr << "C picking shape-shifting variant:\n";
-  vector<recipe_ordinal> result3 = keep_max(inst, result2, number_of_type_ingredients);
-  if (SIZE(result3) > 1) {
-    raise << "\nCouldn't decide the best shape-shifting variant for instruction '" << to_original_string(inst) << "'\n" << end();
-    cerr << "This is a hole in Mu. Please copy the following candidates into an email to Kartik Agaram <mu@akkartik.com>\n";
-    for (int i = 0;  i < SIZE(candidates);  ++i)
-      cerr << "  " << header_label(get(Recipe, candidates.at(i))) << '\n';
-  }
-  return result3.at(0);
-}
-
-vector<recipe_ordinal> keep_max(const instruction& inst, const vector<recipe_ordinal>& in,
-                                int (*scorer)(const instruction&, recipe_ordinal)) {
-  assert(!in.empty());
-  vector<recipe_ordinal> out;
-  out.push_back(in.at(0));
-  int best_score = (*scorer)(inst, in.at(0));
-//?   cerr << best_score << " " << header_label(get(Recipe, in.at(0))) << '\n';
-  for (int i = 1;  i < SIZE(in);  ++i) {
-    int score = (*scorer)(inst, in.at(i));
-//?     cerr << score << " " << header_label(get(Recipe, in.at(i))) << '\n';
-    if (score == best_score) {
-      out.push_back(in.at(i));
-    }
-    else if (score > best_score) {
-      best_score = score;
-      out.clear();
-      out.push_back(in.at(i));
-    }
-  }
-  return out;
-}
-
-int arity_fit(const instruction& inst, recipe_ordinal candidate) {
-  const recipe& r = get(Recipe, candidate);
-  return (SIZE(inst.products) - SIZE(r.products))
-       + (SIZE(r.ingredients) - SIZE(inst.ingredients));
-}
-
-bool any_type_ingredient_in_header(recipe_ordinal variant) {
-  const recipe& caller = get(Recipe, variant);
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i) {
-    if (contains_type_ingredient_name(caller.ingredients.at(i)))
-      return true;
-  }
-  for (int i = 0;  i < SIZE(caller.products);  ++i) {
-    if (contains_type_ingredient_name(caller.products.at(i)))
-      return true;
-  }
-  return false;
-}
-
-bool concrete_type_names_strictly_match(reagent/*copy*/ to, reagent/*copy*/ from) {
-  canonize_type(to);
-  canonize_type(from);
-  return concrete_type_names_strictly_match(to.type, from.type, from);
-}
-
-bool concrete_type_names_strictly_match(const type_tree* to, const type_tree* from, const reagent& rhs_reagent) {
-  if (!to) return !from;
-  if (!from) return !to;
-  if (to->atom && is_type_ingredient_name(to->name)) return true;  // type ingredient matches anything
-  if (!to->atom && to->right == NULL && to->left != NULL && to->left->atom && is_type_ingredient_name(to->left->name)) return true;
-  if (from->atom && is_mu_address(to))
-    return from->name == "literal-address" && rhs_reagent.name == "null";
-  if (!from->atom && !to->atom)
-    return concrete_type_names_strictly_match(to->left, from->left, rhs_reagent)
-        && concrete_type_names_strictly_match(to->right, from->right, rhs_reagent);
-  if (from->atom != to->atom) return false;
-  // both from and to are atoms
-  if (from->name == "literal")
-    return Literal_type_names.find(to->name) != Literal_type_names.end();
-  if (to->name == "literal")
-    return Literal_type_names.find(from->name) != Literal_type_names.end();
-  return to->name == from->name;
-}
-
-bool contains_type_ingredient_name(const reagent& x) {
-  return contains_type_ingredient_name(x.type);
-}
-
-bool contains_type_ingredient_name(const type_tree* type) {
-  if (!type) return false;
-  if (is_type_ingredient_name(type->name)) return true;
-  return contains_type_ingredient_name(type->left) || contains_type_ingredient_name(type->right);
-}
-
-int number_of_concrete_type_names(const instruction& /*unused*/, recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  int result = 0;
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-    result += number_of_concrete_type_names(caller.ingredients.at(i).type);
-  for (int i = 0;  i < SIZE(caller.products);  ++i)
-    result += number_of_concrete_type_names(caller.products.at(i).type);
-  return result;
-}
-
-int number_of_concrete_type_names(const type_tree* type) {
-  if (!type) return 0;
-  if (type->atom)
-    return is_type_ingredient_name(type->name) ? 0 : 1;
-  return number_of_concrete_type_names(type->left)
-       + number_of_concrete_type_names(type->right);
-}
-
-int number_of_type_ingredients(const instruction& /*unused*/, recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  int result = 0;
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-    result += number_of_type_ingredients(caller.ingredients.at(i).type);
-  for (int i = 0;  i < SIZE(caller.products);  ++i)
-    result += number_of_type_ingredients(caller.products.at(i).type);
-  return result;
-}
-
-int number_of_type_ingredients(const type_tree* type) {
-  if (!type) return 0;
-  if (type->atom)
-    return is_type_ingredient_name(type->name) ? 1 : 0;
-  return number_of_type_ingredients(type->left)
-       + number_of_type_ingredients(type->right);
-}
-
-// returns name of new variant
-string insert_new_variant(recipe_ordinal exemplar, const instruction& inst, const recipe& caller_recipe) {
-  string new_name = next_unused_recipe_name(inst.name);
-  assert(!contains_key(Recipe_ordinal, new_name));
-  recipe_ordinal new_recipe_ordinal = put(Recipe_ordinal, new_name, Next_recipe_ordinal++);
-  // make a copy
-  assert(contains_key(Recipe, exemplar));
-  assert(!contains_key(Recipe, new_recipe_ordinal));
-  put(Recipe, new_recipe_ordinal, /*copy*/get(Recipe, exemplar));
-  recipe& new_recipe = get(Recipe, new_recipe_ordinal);
-  new_recipe.name = new_name;
-  new_recipe.ordinal = new_recipe_ordinal;
-  new_recipe.is_autogenerated = true;
-  trace(103, "transform") << "switching " << inst.name << " to specialized " << header_label(new_recipe) << end();
-
-  trace(102, "transform") << "transforming new specialization: " << new_recipe.name << end();
-  trace(102, "transform") << new_recipe.name << ": performing transforms until check_or_set_types_by_name" << end();
-  int transform_index = 0;
-  for (transform_index = 0;  transform_index < SIZE(Transform);  ++transform_index) {
-    if (Transform.at(transform_index) == check_or_set_types_by_name) break;
-    (*Transform.at(transform_index))(new_recipe_ordinal);
-  }
-  new_recipe.transformed_until = transform_index-1;
-
-  trace(102, "transform") << new_recipe.name << ": performing type-ingredient-aware version of transform check_or_set_types_by_name" << end();
-  compute_type_names(new_recipe);
-  new_recipe.transformed_until++;
-
-  trace(102, "transform") << new_recipe.name << ": replacing type ingredients" << end();
-  {
-    map<string, const type_tree*> mappings;
-    bool error = false;
-    compute_type_ingredient_mappings(get(Recipe, exemplar), inst, mappings, caller_recipe, &error);
-    if (!error) error = (SIZE(mappings) != type_ingredient_count_in_header(exemplar));
-    if (!error) replace_type_ingredients(new_recipe, mappings);
-    for (map<string, const type_tree*>::iterator p = mappings.begin();  p != mappings.end();  ++p)
-      delete p->second;
-    if (error) return "";
-  }
-  ensure_all_concrete_types(new_recipe, get(Recipe, exemplar));
-
-  trace(102, "transform") << new_recipe.name << ": recording the new variant before recursively calling resolve_ambiguous_calls" << end();
-  get(Recipe_variants, inst.name).push_back(new_recipe_ordinal);
-  trace(102, "transform") << new_recipe.name << ": performing remaining transforms (including resolve_ambiguous_calls)" << end();
-  for (/*nada*/;  transform_index < SIZE(Transform);  ++transform_index)
-    (*Transform.at(transform_index))(new_recipe_ordinal);
-  new_recipe.transformed_until = SIZE(Transform)-1;
-  return new_recipe.name;
-}
-
-void compute_type_names(recipe& variant) {
-  trace(103, "transform") << "-- compute type names: " << variant.name << end();
-  map<string, type_tree*> type_names;
-  for (int i = 0;  i < SIZE(variant.ingredients);  ++i)
-    save_or_deduce_type_name(variant.ingredients.at(i), type_names, variant, "");
-  for (int i = 0;  i < SIZE(variant.products);  ++i)
-    save_or_deduce_type_name(variant.products.at(i), type_names, variant, "");
-  for (int i = 0;  i < SIZE(variant.steps);  ++i) {
-    instruction& inst = variant.steps.at(i);
-    trace(103, "transform") << "  instruction: " << to_string(inst) << end();
-    for (int in = 0;  in < SIZE(inst.ingredients);  ++in)
-      save_or_deduce_type_name(inst.ingredients.at(in), type_names, variant, " in '" + to_original_string(inst) + "'");
-    for (int out = 0;  out < SIZE(inst.products);  ++out)
-      save_or_deduce_type_name(inst.products.at(out), type_names, variant, " in '" + to_original_string(inst) + "'");
-  }
-}
-
-void save_or_deduce_type_name(reagent& x, map<string, type_tree*>& type, const recipe& variant, const string& context) {
-  trace(104, "transform") << "    checking " << to_string(x) << ": " << names_to_string(x.type) << end();
-  if (!x.type && contains_key(type, x.name)) {
-    x.type = new type_tree(*get(type, x.name));
-    trace(104, "transform") << "    deducing type to " << names_to_string(x.type) << end();
-    return;
-  }
-  // Type Check in Type-ingredient-aware check_or_set_types_by_name
-  // This is different from check_or_set_types_by_name.
-  // We've found it useful in the past for tracking down bugs in
-  // specialization.
-  if (!x.type) {
-    raise << maybe(variant.original_name) << "unknown type for '" << x.original_string << "'" << context << " (check the name for typos)\n" << end();
-    return;
-  }
-  if (contains_key(type, x.name)) return;
-  if (x.type->name == "offset" || x.type->name == "variant") return;  // special-case for container-access instructions
-  put(type, x.name, x.type);
-  trace(103, "transform") << "type of '" << x.name << "' is " << names_to_string(x.type) << end();
-}
-
-void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map<string, const type_tree*>& mappings, const recipe& caller_recipe, bool* error) {
-  int limit = min(SIZE(inst.ingredients), SIZE(exemplar.ingredients));
-  for (int i = 0;  i < limit;  ++i) {
-    const reagent& exemplar_reagent = exemplar.ingredients.at(i);
-    reagent/*copy*/ ingredient = inst.ingredients.at(i);
-    canonize_type(ingredient);
-    if (is_mu_address(exemplar_reagent) && ingredient.name == "null") continue;  // assume it matches
-    accumulate_type_ingredients(exemplar_reagent, ingredient, mappings, exemplar, inst, caller_recipe, error);
-  }
-  limit = min(SIZE(inst.products), SIZE(exemplar.products));
-  for (int i = 0;  i < limit;  ++i) {
-    const reagent& exemplar_reagent = exemplar.products.at(i);
-    reagent/*copy*/ product = inst.products.at(i);
-    if (is_dummy(product)) continue;
-    canonize_type(product);
-    accumulate_type_ingredients(exemplar_reagent, product, mappings, exemplar, inst, caller_recipe, error);
-  }
-}
-
-void accumulate_type_ingredients(const reagent& exemplar_reagent, reagent& refinement, map<string, const type_tree*>& mappings, const recipe& exemplar, const instruction& call_instruction, const recipe& caller_recipe, bool* error) {
-  assert(refinement.type);
-  accumulate_type_ingredients(exemplar_reagent.type, refinement.type, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
-}
-
-void accumulate_type_ingredients(const type_tree* exemplar_type, const type_tree* refinement_type, map<string, const type_tree*>& mappings, const recipe& exemplar, const reagent& exemplar_reagent, const instruction& call_instruction, const recipe& caller_recipe, bool* error) {
-  if (!exemplar_type) return;
-  if (!refinement_type) {
-    // probably a bug in mu
-    // todo: make this smarter; only flag an error if exemplar_type contains some *new* type ingredient
-    raise << maybe(exemplar.name) << "missing type ingredient for " << exemplar_reagent.original_string << '\n' << end();
-    raise << "  (called from '" << to_original_string(call_instruction) << "')\n" << end();
-    return;
-  }
-  if (!exemplar_type->atom && exemplar_type->right == NULL && !refinement_type->atom && refinement_type->right != NULL) {
-    exemplar_type = exemplar_type->left;
-    assert_for_now(exemplar_type->atom);
-  }
-  if (exemplar_type->atom) {
-    if (is_type_ingredient_name(exemplar_type->name)) {
-      const type_tree* curr_refinement_type = NULL;  // temporary heap allocation; must always be deleted before it goes out of scope
-      if (exemplar_type->atom)
-        curr_refinement_type = new type_tree(*refinement_type);
-      else {
-        assert(!refinement_type->atom);
-        curr_refinement_type = new type_tree(*refinement_type->left);
-      }
-      if (!contains_key(mappings, exemplar_type->name)) {
-        trace(103, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end();
-        put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type));
-      }
-      else {
-        if (!deeply_equal_type_names(get(mappings, exemplar_type->name), curr_refinement_type)) {
-          raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end();
-          *error = true;
-          delete curr_refinement_type;
-          return;
-        }
-        if (get(mappings, exemplar_type->name)->name == "literal") {
-          delete get(mappings, exemplar_type->name);
-          put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type));
-        }
-      }
-      delete curr_refinement_type;
-    }
-  }
-  else {
-    accumulate_type_ingredients(exemplar_type->left, refinement_type->left, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
-    accumulate_type_ingredients(exemplar_type->right, refinement_type->right, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
-  }
-}
-
-void replace_type_ingredients(recipe& new_recipe, const map<string, const type_tree*>& mappings) {
-  // update its header
-  if (mappings.empty()) return;
-  trace(103, "transform") << "replacing in recipe header ingredients" << end();
-  for (int i = 0;  i < SIZE(new_recipe.ingredients);  ++i)
-    replace_type_ingredients(new_recipe.ingredients.at(i), mappings, new_recipe);
-  trace(103, "transform") << "replacing in recipe header products" << end();
-  for (int i = 0;  i < SIZE(new_recipe.products);  ++i)
-    replace_type_ingredients(new_recipe.products.at(i), mappings, new_recipe);
-  // update its body
-  for (int i = 0;  i < SIZE(new_recipe.steps);  ++i) {
-    instruction& inst = new_recipe.steps.at(i);
-    trace(103, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end();
-    for (int j = 0;  j < SIZE(inst.ingredients);  ++j)
-      replace_type_ingredients(inst.ingredients.at(j), mappings, new_recipe);
-    for (int j = 0;  j < SIZE(inst.products);  ++j)
-      replace_type_ingredients(inst.products.at(j), mappings, new_recipe);
-    // special-case for new: replace type ingredient in first ingredient *value*
-    if (inst.name == "new" && inst.ingredients.at(0).type->name != "literal-string") {
-      type_tree* type = parse_type_tree(inst.ingredients.at(0).name);
-      replace_type_ingredients(type, mappings);
-      inst.ingredients.at(0).name = inspect(type);
-      delete type;
-    }
-  }
-}
-
-void replace_type_ingredients(reagent& x, const map<string, const type_tree*>& mappings, const recipe& caller) {
-  string before = to_string(x);
-  trace(103, "transform") << "replacing in ingredient " << x.original_string << end();
-  if (!x.type) {
-    raise << "specializing " << caller.original_name << ": missing type for '" << x.original_string << "'\n" << end();
-    return;
-  }
-  replace_type_ingredients(x.type, mappings);
-}
-
-void replace_type_ingredients(type_tree* type, const map<string, const type_tree*>& mappings) {
-  if (!type) return;
-  if (!type->atom) {
-    if (type->right == NULL && type->left != NULL && type->left->atom && contains_key(mappings, type->left->name) && !get(mappings, type->left->name)->atom && get(mappings, type->left->name)->right != NULL) {
-      *type = *get(mappings, type->left->name);
-      return;
-    }
-    replace_type_ingredients(type->left, mappings);
-    replace_type_ingredients(type->right, mappings);
-    return;
-  }
-  if (contains_key(Type_ordinal, type->name))  // todo: ugly side effect
-    type->value = get(Type_ordinal, type->name);
-  if (!contains_key(mappings, type->name))
-    return;
-  const type_tree* replacement = get(mappings, type->name);
-  trace(103, "transform") << type->name << " => " << names_to_string(replacement) << end();
-  if (replacement->atom) {
-    if (!contains_key(Type_ordinal, replacement->name)) {
-      // error in program; should be reported elsewhere
-      return;
-    }
-    type->name = (replacement->name == "literal") ? "number" : replacement->name;
-    type->value = get(Type_ordinal, type->name);
-  }
-  else {
-    *type = *replacement;
-  }
-}
-
-int type_ingredient_count_in_header(recipe_ordinal variant) {
-  const recipe& caller = get(Recipe, variant);
-  set<string> type_ingredients;
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
-    accumulate_type_ingredients(caller.ingredients.at(i).type, type_ingredients);
-  for (int i = 0;  i < SIZE(caller.products);  ++i)
-    accumulate_type_ingredients(caller.products.at(i).type, type_ingredients);
-  return SIZE(type_ingredients);
-}
-
-void accumulate_type_ingredients(const type_tree* type, set<string>& out) {
-  if (!type) return;
-  if (is_type_ingredient_name(type->name)) out.insert(type->name);
-  accumulate_type_ingredients(type->left, out);
-  accumulate_type_ingredients(type->right, out);
-}
-
-type_tree* parse_type_tree(const string& s) {
-  string_tree* s2 = parse_string_tree(s);
-  type_tree* result = new_type_tree(s2);
-  delete s2;
-  return result;
-}
-
-string inspect(const type_tree* x) {
-  ostringstream out;
-  dump_inspect(x, out);
-  return out.str();
-}
-
-void dump_inspect(const type_tree* x, ostream& out) {
-  if (!x->left && !x->right) {
-    out << x->name;
-    return;
-  }
-  out << '(';
-  for (const type_tree* curr = x;  curr;  curr = curr->right) {
-    if (curr != x) out << ' ';
-    if (curr->left)
-      dump_inspect(curr->left, out);
-    else
-      out << curr->name;
-  }
-  out << ')';
-}
-
-void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) {
-  trace(103, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end();
-  for (int i = 0;  i < SIZE(new_recipe.ingredients);  ++i)
-    ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar);
-  for (int i = 0;  i < SIZE(new_recipe.products);  ++i)
-    ensure_all_concrete_types(new_recipe.products.at(i), exemplar);
-  for (int i = 0;  i < SIZE(new_recipe.steps);  ++i) {
-    instruction& inst = new_recipe.steps.at(i);
-    for (int j = 0;  j < SIZE(inst.ingredients);  ++j)
-      ensure_all_concrete_types(inst.ingredients.at(j), exemplar);
-    for (int j = 0;  j < SIZE(inst.products);  ++j)
-      ensure_all_concrete_types(inst.products.at(j), exemplar);
-  }
-}
-
-void ensure_all_concrete_types(/*const*/ reagent& x, const recipe& exemplar) {
-  if (!x.type || contains_type_ingredient_name(x.type)) {
-    raise << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end();
-    if (!x.type) x.type = new type_tree("added_by_ensure_all_concrete_types", 0);  // just to prevent crashes later
-    return;
-  }
-  if (x.type->value == -1) {
-    raise << maybe(exemplar.name) << "failed to map a type to the unknown " << x.original_string << '\n' << end();
-    return;
-  }
-}
-
-void test_shape_shifting_recipe_2() {
-  run(
-      "def main [\n"
-      "  10:point <- merge 14, 15\n"
-      "  12:point <- foo 10:point\n"
-      "]\n"
-      // non-matching shape-shifting variant
-      "def foo a:_t, b:_t -> result:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy 34\n"
-      "]\n"
-      // matching shape-shifting variant
-      "def foo a:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy a\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 12\n"
-      "mem: storing 15 in location 13\n"
-  );
-}
-
-void test_shape_shifting_recipe_nonroot() {
-  run(
-      "def main [\n"
-      "  10:foo:point <- merge 14, 15, 16\n"
-      "  20:point <- bar 10:foo:point\n"
-      "]\n"
-      // shape-shifting recipe with type ingredient following some other type
-      "def bar a:foo:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- get a, x:offset\n"
-      "]\n"
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 20\n"
-      "mem: storing 15 in location 21\n"
-  );
-}
-
-void test_shape_shifting_recipe_nested() {
-  run(
-      "container c:_a:_b [\n"
-      "  a:_a\n"
-      "  b:_b\n"
-      "]\n"
-      "def main [\n"
-      "  s:text <- new [abc]\n"
-      "  {x: (c (address array character) number)} <- merge s, 34\n"
-      "  foo x\n"
-      "]\n"
-      "def foo x:c:_bar:_baz [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "]\n"
-  );
-  // no errors
-}
-
-void test_shape_shifting_recipe_type_deduction_ignores_offsets() {
-  run(
-      "def main [\n"
-      "  10:foo:point <- merge 14, 15, 16\n"
-      "  20:point <- bar 10:foo:point\n"
-      "]\n"
-      "def bar a:foo:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x:num <- copy 1\n"
-      "  result <- get a, x:offset  # shouldn't collide with other variable\n"
-      "]\n"
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 14 in location 20\n"
-      "mem: storing 15 in location 21\n"
-  );
-}
-
-void test_shape_shifting_recipe_empty() {
-  run(
-      "def main [\n"
-      "  foo 1\n"
-      "]\n"
-      // shape-shifting recipe with no body
-      "def foo a:_t [\n"
-      "]\n"
-  );
-  // shouldn't crash
-}
-
-void test_shape_shifting_recipe_handles_shape_shifting_new_ingredient() {
-  run(
-      "def main [\n"
-      "  1:&:foo:point <- bar 3\n"
-      "  11:foo:point <- copy *1:&:foo:point\n"
-      "]\n"
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-      "def bar x:num -> result:&:foo:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-         // new refers to _t in its ingredient *value*
-      "  result <- new {(foo _t) : type}\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 11\n"
-      "mem: storing 0 in location 12\n"
-      "mem: storing 0 in location 13\n"
-  );
-}
-
-void test_shape_shifting_recipe_handles_shape_shifting_new_ingredient_2() {
-  run(
-      "def main [\n"
-      "  1:&:foo:point <- bar 3\n"
-      "  11:foo:point <- copy *1:&:foo:point\n"
-      "]\n"
-      "def bar x:num -> result:&:foo:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-         // new refers to _t in its ingredient *value*
-      "  result <- new {(foo _t) : type}\n"
-      "]\n"
-      // container defined after use
-      "container foo:_t [\n"
-      "  x:_t\n"
-      "  y:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 11\n"
-      "mem: storing 0 in location 12\n"
-      "mem: storing 0 in location 13\n"
-  );
-}
-
-void test_shape_shifting_recipe_called_with_dummy() {
-  run(
-      "def main [\n"
-      "  _ <- bar 34\n"
-      "]\n"
-      "def bar x:_t -> result:&:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-// this one needs a little more fine-grained control
-void test_shape_shifting_new_ingredient_does_not_pollute_global_namespace() {
-  // if you specialize a shape-shifting recipe that allocates a type-ingredient..
-  transform("def barz x:_elem [\n"
-            "  local-scope\n"
-            "  load-ingredients\n"
-            "  y:&:num <- new _elem:type\n"
-            "]\n"
-            "def fooz [\n"
-            "  local-scope\n"
-            "  barz 34\n"
-            "]\n");
-  // ..and if you then try to load a new shape-shifting container with that
-  // type-ingredient
-  run("container foo:_elem [\n"
-      "  x:_elem\n"
-      "  y:num\n"
-      "]\n");
-  // then it should work as usual
-  reagent callsite("x:foo:point");
-  reagent element = element_type(callsite.type, 0);
-  CHECK_EQ(element.name, "x");
-  CHECK_EQ(element.type->name, "point");
-  CHECK(!element.type->right);
-}
-
-//: specializing a type ingredient with a compound type
-void test_shape_shifting_recipe_supports_compound_types() {
-  run(
-      "def main [\n"
-      "  1:&:point <- new point:type\n"
-      "  *1:&:point <- put *1:&:point, y:offset, 34\n"
-      "  3:&:point <- bar 1:&:point  # specialize _t to address:point\n"
-      "  5:point <- copy *3:&:point\n"
-      "]\n"
-      "def bar a:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy a\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 6\n"
-  );
-}
-
-//: specializing a type ingredient with a compound type -- while *inside* another compound type
-void test_shape_shifting_recipe_supports_compound_types_2() {
-  run(
-      "container foo:_t [\n"
-      "  value:_t\n"
-      "]\n"
-      "def bar x:&:foo:_t -> result:_t [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- get *x, value:offset\n"
-      "]\n"
-      "def main [\n"
-      "  1:&:foo:&:point <- new {(foo address point): type}\n"
-      "  2:&:point <- bar 1:&:foo:&:point\n"
-      "]\n"
-  );
-  // no errors; call to 'bar' successfully specialized
-}
-
-void test_shape_shifting_recipe_error() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  a:num <- copy 3\n"
-      "  b:&:num <- foo a\n"
-      "]\n"
-      "def foo a:_t -> b:_t [\n"
-      "  load-ingredients\n"
-      "  b <- copy a\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: no call found for 'b:&:num <- foo a'\n"
-  );
-}
-
-void test_specialize_inside_recipe_without_header() {
-  run(
-      "def main [\n"
-      "  foo 3\n"
-      "]\n"
-      "def foo [\n"
-      "  local-scope\n"
-      "  x:num <- next-ingredient  # ensure no header\n"
-      "  1:num/raw <- bar x  # call a shape-shifting recipe\n"
-      "]\n"
-      "def bar x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- add x, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-void test_specialize_with_literal() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-         // permit literal to map to number
-      "  1:num/raw <- foo 3\n"
-      "]\n"
-      "def foo x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- add x, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-void test_specialize_with_literal_2() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-         // permit literal to map to character
-      "  1:char/raw <- foo 3\n"
-      "]\n"
-      "def foo x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- add x, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 1\n"
-  );
-}
-
-void test_specialize_with_literal_3() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-         // permit '0' to map to address to shape-shifting type-ingredient
-      "  1:&:char/raw <- foo null\n"
-      "]\n"
-      "def foo x:&:_elem -> y:&:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 1\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_specialize_with_literal_4() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-         // ambiguous call: what's the type of its ingredient?!
-      "  foo 0\n"
-      "]\n"
-      "def foo x:&:_elem -> y:&:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: instruction 'foo' has no valid specialization\n"
-  );
-}
-
-void test_specialize_with_literal_5() {
-  run(
-      "def main [\n"
-      "  foo 3, 4\n"  // recipe mapping two variables to literals
-      "]\n"
-      "def foo x:_elem, y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  1:num/raw <- add x, y\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 7 in location 1\n"
-  );
-}
-
-void test_multiple_shape_shifting_variants() {
-  run(
-      // try to call two different shape-shifting recipes with the same name
-      "def main [\n"
-      "  e1:d1:num <- merge 3\n"
-      "  e2:d2:num <- merge 4, 5\n"
-      "  1:num/raw <- foo e1\n"
-      "  2:num/raw <- foo e2\n"
-      "]\n"
-      // the two shape-shifting definitions
-      "def foo a:d1:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo a:d2:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-      // the shape-shifting containers they use
-      "container d1:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-      "container d2:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      "mem: storing 35 in location 2\n"
-  );
-}
-
-void test_multiple_shape_shifting_variants_2() {
-  run(
-      // static dispatch between shape-shifting variants, _including pointer lookups_
-      "def main [\n"
-      "  e1:d1:num <- merge 3\n"
-      "  e2:&:d2:num <- new {(d2 number): type}\n"
-      "  1:num/raw <- foo e1\n"
-      "  2:num/raw <- foo *e2\n"  // different from previous scenario
-      "]\n"
-      "def foo a:d1:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo a:d2:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-      "container d1:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-      "container d2:_elem [\n"
-      "  x:num\n"
-      "  y:_elem\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      "mem: storing 35 in location 2\n"
-  );
-}
-
-void test_missing_type_in_shape_shifting_recipe() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  a:d1:num <- merge 3\n"
-      "  foo a\n"
-      "]\n"
-      "def foo a:d1:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  copy e\n"  // no such variable
-      "  return 34\n"
-      "]\n"
-      "container d1:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: unknown type for 'e' in 'copy e' (check the name for typos)\n"
-      "error: specializing foo: missing type for 'e'\n"
-  );
-  // and it doesn't crash
-}
-
-void test_missing_type_in_shape_shifting_recipe_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  a:d1:num <- merge 3\n"
-      "  foo a\n"
-      "]\n"
-      "def foo a:d1:_elem -> b:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  get e, x:offset\n"  // unknown variable in a 'get', which does some extra checking
-      "  return 34\n"
-      "]\n"
-      "container d1:_elem [\n"
-      "  x:_elem\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: unknown type for 'e' in 'get e, x:offset' (check the name for typos)\n"
-      "error: specializing foo: missing type for 'e'\n"
-  );
-  // and it doesn't crash
-}
-
-void test_specialize_recursive_shape_shifting_recipe() {
-  transform(
-      "def main [\n"
-      "  1:num <- copy 34\n"
-      "  2:num <- foo 1:num\n"
-      "]\n"
-      "def foo x:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  {\n"
-      "    break\n"
-      "    y:num <- foo x\n"
-      "  }\n"
-      "  return y\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: new specialization: foo_2\n"
-  );
-  // transform terminates
-}
-
-void test_specialize_most_similar_variant() {
-  run(
-      "def main [\n"
-      "  1:&:num <- new number:type\n"
-      "  10:num <- foo 1:&:num\n"
-      "]\n"
-      "def foo x:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo x:&:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 35 in location 10\n"
-  );
-}
-
-void test_specialize_most_similar_variant_2() {
-  run(
-      // version with headers padded with lots of unrelated concrete types
-      "def main [\n"
-      "  1:num <- copy 23\n"
-      "  2:&:@:num <- copy null\n"
-      "  4:num <- foo 2:&:@:num, 1:num\n"
-      "]\n"
-      // variant with concrete type
-      "def foo dummy:&:@:num, x:num -> y:num, dummy:&:@:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      // shape-shifting variant
-      "def foo dummy:&:@:num, x:_elem -> y:num, dummy:&:@:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  // prefer the concrete variant
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 4\n"
-  );
-}
-
-void test_specialize_most_similar_variant_3() {
-  run(
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  foo 1:text\n"
-      "]\n"
-      "def foo x:text [\n"
-      "  10:num <- copy 34\n"
-      "]\n"
-      "def foo x:&:_elem [\n"
-      "  10:num <- copy 35\n"
-      "]\n"
-  );
-  // make sure the more precise version was used
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 10\n"
-  );
-}
-
-void test_specialize_literal_as_number() {
-  run(
-      "def main [\n"
-      "  1:num <- foo 23\n"
-      "]\n"
-      "def foo x:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      "def foo x:char -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_specialize_literal_as_number_2() {
-  run(
-      // version calling with literal
-      "def main [\n"
-      "  1:num <- foo 0\n"
-      "]\n"
-      // variant with concrete type
-      "def foo x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      // shape-shifting variant
-      "def foo x:&:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  // prefer the concrete variant, ignore concrete types in scoring the shape-shifting variant
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_specialize_literal_as_address() {
-  run(
-      "def main [\n"
-      "  1:num <- foo null\n"
-      "]\n"
-      // variant with concrete address type
-      "def foo x:&:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 34\n"
-      "]\n"
-      // shape-shifting variant
-      "def foo x:&:_elem -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return 35\n"
-      "]\n"
-  );
-  // prefer the concrete variant, ignore concrete types in scoring the shape-shifting variant
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_missing_type_during_specialization() {
-  Hide_errors = true;
-  run(
-      // define a shape-shifting recipe
-      "def foo a:_elem [\n"
-      "]\n"
-      // define a container with field 'z'
-      "container foo2 [\n"
-      "  z:num\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  x:foo2 <- merge 34\n"
-      "  y:num <- get x, z:offse  # typo in 'offset'\n"
-         // define a variable with the same name 'z'
-      "  z:num <- copy 34\n"
-      "  foo z\n"
-      "]\n"
-  );
-  // shouldn't crash
-}
-
-void test_missing_type_during_specialization2() {
-  Hide_errors = true;
-  run(
-      // define a shape-shifting recipe
-      "def foo a:_elem [\n"
-      "]\n"
-      // define a container with field 'z'
-      "container foo2 [\n"
-      "  z:num\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  x:foo2 <- merge 34\n"
-      "  y:num <- get x, z:offse  # typo in 'offset'\n"
-         // define a variable with the same name 'z'
-      "  z:&:num <- copy 34\n"
-         // trigger specialization of the shape-shifting recipe
-      "  foo *z\n"
-      "]\n"
-  );
-  // shouldn't crash
-}
-
-void test_tangle_shape_shifting_recipe() {
-  run(
-      // shape-shifting recipe
-      "def foo a:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  <label1>\n"
-      "]\n"
-      // tangle some code that refers to the type ingredient
-      "after <label1> [\n"
-      "  b:_elem <- copy a\n"
-      "]\n"
-      // trigger specialization
-      "def main [\n"
-      "  local-scope\n"
-      "  foo 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_tangle_shape_shifting_recipe_with_type_abbreviation() {
-  run(
-      // shape-shifting recipe
-      "def foo a:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  <label1>\n"
-      "]\n"
-      // tangle some code that refers to the type ingredient
-      "after <label1> [\n"
-      "  b:bool <- copy false\n"  // type abbreviation
-      "]\n"
-      // trigger specialization
-      "def main [\n"
-      "  local-scope\n"
-      "  foo 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_shape_shifting_recipe_coexists_with_primitive() {
-  run(
-      // recipe overloading a primitive with a generic type
-      "def add a:&:foo:_elem [\n"
-      "  assert 0, [should not get here]\n"
-      "]\n"
-      "def main [\n"
-         // call primitive add with literal 0
-      "  add 0, 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_specialization_heuristic_test_1() {
-  run(
-      // modeled on the 'buffer' container in text.mu
-      "container foo_buffer:_elem [\n"
-      "  x:num\n"
-      "]\n"
-      "def main [\n"
-      "  append 1:&:foo_buffer:char/raw, 2:text/raw\n"
-      "]\n"
-      "def append buf:&:foo_buffer:_elem, x:_elem -> buf:&:foo_buffer:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  stash 34\n"
-      "]\n"
-      "def append buf:&:foo_buffer:char, x:_elem -> buf:&:foo_buffer:char [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  stash 35\n"
-      "]\n"
-      "def append buf:&:foo_buffer:_elem, x:&:@:_elem -> buf:&:foo_buffer:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  stash 36\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: 36\n"
-  );
-}
diff --git a/archive/2.vm/057immutable.cc b/archive/2.vm/057immutable.cc
deleted file mode 100644
index 16c2a6ab..00000000
--- a/archive/2.vm/057immutable.cc
+++ /dev/null
@@ -1,715 +0,0 @@
-//: Ingredients of a recipe are meant to be immutable unless they're also
-//: products. This layer will start enforcing this check.
-//:
-//: One hole for now: variables in surrounding spaces are implicitly mutable.
-//: [tag: todo]
-
-void test_can_modify_ingredients_that_are_also_products() {
-  run(
-      // mutable container
-      "def main [\n"
-      "  local-scope\n"
-      "  p:point <- merge 34, 35\n"
-      "  p <- foo p\n"
-      "]\n"
-      "def foo p:point -> p:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  p <- put p, x:offset, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_can_modify_ingredients_that_are_also_products_2() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:point <- new point:type\n"
-      "  p <- foo p\n"
-      "]\n"
-      // mutable address to container
-      "def foo p:&:point -> p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  *p <- put *p, x:offset, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_can_modify_ingredients_that_are_also_products_3() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:@:num <- new number:type, 3\n"
-      "  p <- foo p\n"
-      "]\n"
-      // mutable address
-      "def foo p:&:@:num -> p:&:@:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  *p <- put-index *p, 0, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_ignore_literal_ingredients_for_immutability_checks() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:d1 <- new d1:type\n"
-      "  q:num <- foo p\n"
-      "]\n"
-      "def foo p:&:d1 -> q:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x:&:d1 <- new d1:type\n"
-      "  *x <- put *x, p:offset, 34\n"  // ignore this 'p'
-      "  return 36\n"
-      "]\n"
-      "container d1 [\n"
-      "  p:num\n"
-      "  q:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_cannot_modify_immutable_ingredients() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:&:num <- new number:type\n"
-      "  foo x\n"
-      "]\n"
-      // immutable address to primitive
-      "def foo x:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  *x <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_cannot_modify_immutable_containers() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:point-number <- merge 34, 35, 36\n"
-      "  foo x\n"
-      "]\n"
-      // immutable container
-      "def foo x:point-number [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-         // copy an element: ok
-      "  y:point <- get x, xy:offset\n"
-         // modify the element: boom
-         // This could be ok if y contains no addresses, but we're not going to try to be that smart.
-         // It also makes the rules easier to reason about. If it's just an ingredient, just don't try to change it.
-      "  y <- put y, x:offset, 37\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'y' in instruction 'y <- put y, x:offset, 37' because that would modify 'x' which is an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_can_modify_immutable_pointers() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:&:num <- new number:type\n"
-      "  foo x\n"
-      "]\n"
-      "def foo x:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-         // modify the address, not the payload
-      "  x <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_can_modify_immutable_pointers_but_not_their_payloads() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:&:num <- new number:type\n"
-      "  foo x\n"
-      "]\n"
-      "def foo x:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      // modify address: ok
-      "  x <- new number:type\n"
-      // modify payload: boom
-      // this could be ok, but we're not going to try to be that smart
-      "  *x <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_cannot_call_mutating_recipes_on_immutable_ingredients() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:point <- new point:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  bar p\n"
-      "]\n"
-      "def bar p:&:point -> p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-         // p could be modified here, but it doesn't have to be; it's already
-         // marked mutable in the header
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'p' in instruction 'bar p' because it's an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_cannot_modify_copies_of_immutable_ingredients() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:point <- new point:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  q:&:point <- copy p\n"
-      "  *q <- put *q, x:offset, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'q' in instruction '*q <- put *q, x:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_can_modify_copies_of_mutable_ingredients() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:point <- new point:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:point -> p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  q:&:point <- copy p\n"
-      "  *q <- put *q, x:offset, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_cannot_modify_address_inside_immutable_ingredients() {
-  Hide_errors = true;
-  run(
-      "container foo [\n"
-      "  x:&:@:num\n"  // contains an address
-      "]\n"
-      "def main [\n"
-      "]\n"
-      "def foo a:&:foo [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x:&:@:num <- get *a, x:offset\n"  // just a regular get of the container
-      "  *x <- put-index *x, 0, 34\n"  // but then a put-index on the result
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'x' in instruction '*x <- put-index *x, 0, 34' because that would modify a which is an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_cannot_modify_address_inside_immutable_ingredients_2() {
-  run(
-      "container foo [\n"
-      "  x:&:@:num\n"  // contains an address
-      "]\n"
-      "def main [\n"
-         // don't run anything
-      "]\n"
-      "def foo a:&:foo [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  b:foo <- merge null\n"
-         // modify b, completely unrelated to immutable ingredient a
-      "  x:&:@:num <- get b, x:offset\n"
-      "  *x <- put-index *x, 0, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_cannot_modify_address_inside_immutable_ingredients_3() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-        // don't run anything
-      "]\n"
-      "def foo a:&:@:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x:&:num <- index *a, 0\n"  // just a regular index of the array
-      "  *x <- copy 34\n"  // but then modify the result
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'x' in instruction '*x <- copy 34' because that would modify a which is an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void test_cannot_modify_address_inside_immutable_ingredients_4() {
-  run(
-      "def main [\n"
-         // don't run anything
-      "]\n"
-      "def foo a:&:@:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  b:&:@:&:num <- new {(address number): type}, 3\n"
-         // modify b, completely unrelated to immutable ingredient a
-      "  x:&:num <- index *b, 0\n"
-      "  *x <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_latter_ingredient_of_index_is_immutable() {
-  run(
-      "def main [\n"
-         // don't run anything
-      "]\n"
-      "def foo a:&:@:&:@:num, b:num -> a:&:@:&:@:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x:&:@:num <- index *a, b\n"
-      "  *x <- put-index *x, 0, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_can_traverse_immutable_ingredients() {
-  run(
-      "container test-list [\n"
-      "  next:&:test-list\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:test-list <- new test-list:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  p2:&:test-list <- bar p\n"
-      "]\n"
-      "def bar x:&:test-list -> y:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- get *x, next:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_treat_optional_ingredients_as_mutable() {
-  run(
-      "def main [\n"
-      "  k:&:num <- new number:type\n"
-      "  test k\n"
-      "]\n"
-      // recipe taking an immutable address ingredient
-      "def test k:&:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  foo k\n"
-      "]\n"
-      // ..calling a recipe with an optional address ingredient
-      "def foo -> [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  k:&:num, found?:bool <- next-ingredient\n"
-         // we don't further check k for immutability, but assume it's mutable
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_treat_optional_ingredients_as_mutable_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:point <- new point:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  bar p\n"
-      "]\n"
-      "def bar [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  p:&:point <- next-ingredient\n"  // optional ingredient; assumed to be mutable
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'p' in instruction 'bar p' because it's an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-//: when checking for immutable ingredients, remember to take space into account
-void test_check_space_of_reagents_in_immutability_checks() {
-  run(
-      "def main [\n"
-      "  a:space/names:new-closure <- new-closure\n"
-      "  b:&:num <- new number:type\n"
-      "  run-closure b:&:num, a:space\n"
-      "]\n"
-      "def new-closure [\n"
-      "  local-scope\n"
-      "  x:&:num <- new number:type\n"
-      "  return default-space/names:new-closure\n"
-      "]\n"
-      "def run-closure x:&:num, s:space/names:new-closure [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  0:space/names:new-closure <- copy s\n"
-         // different space; always mutable
-      "  *x:&:num/space:1 <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End Transforms")
-Transform.push_back(check_immutable_ingredients);  // idempotent
-
-:(code)
-void check_immutable_ingredients(const recipe_ordinal r) {
-  // to ensure an address reagent isn't modified, it suffices to show that
-  //   a) we never write to its contents directly,
-  //   b) we never call 'put' or 'put-index' on it, and
-  //   c) any non-primitive recipe calls in the body aren't returning it as a product
-  const recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- check mutability of ingredients in recipe " << caller.name << end();
-  if (!caller.has_header) return;  // skip check for old-style recipes calling next-ingredient directly
-  for (int i = 0;  i < SIZE(caller.ingredients);  ++i) {
-    const reagent& current_ingredient = caller.ingredients.at(i);
-    if (is_present_in_products(caller, current_ingredient.name)) continue;  // not expected to be immutable
-    // End Immutable Ingredients Special-cases
-    set<reagent, name_and_space_lt> immutable_vars;
-    immutable_vars.insert(current_ingredient);
-    for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-      const instruction& inst = caller.steps.at(i);
-      check_immutable_ingredient_in_instruction(inst, immutable_vars, current_ingredient.name, caller);
-      if (inst.operation == INDEX && SIZE(inst.ingredients) > 1 && inst.ingredients.at(1).name == current_ingredient.name) continue;
-      update_aliases(inst, immutable_vars);
-    }
-  }
-}
-
-void update_aliases(const instruction& inst, set<reagent, name_and_space_lt>& current_ingredient_and_aliases) {
-  set<int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases);
-  if (!contains_key(Recipe, inst.operation)) {
-    // primitive recipe
-    switch (inst.operation) {
-      case COPY:
-        for (set<int>::iterator p = current_ingredient_indices.begin();  p != current_ingredient_indices.end();  ++p)
-          current_ingredient_and_aliases.insert(inst.products.at(*p).name);
-        break;
-      case GET:
-      case INDEX:
-      case MAYBE_CONVERT:
-        // current_ingredient_indices can only have 0 or one value
-        if (!current_ingredient_indices.empty() && !inst.products.empty()) {
-          if (is_mu_address(inst.products.at(0)) || is_mu_container(inst.products.at(0)) || is_mu_exclusive_container(inst.products.at(0)))
-            current_ingredient_and_aliases.insert(inst.products.at(0));
-        }
-        break;
-      default: break;
-    }
-  }
-  else {
-    // defined recipe
-    set<int> contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices);
-    for (set<int>::iterator p = contained_in_product_indices.begin();  p != contained_in_product_indices.end();  ++p) {
-      if (*p < SIZE(inst.products))
-        current_ingredient_and_aliases.insert(inst.products.at(*p));
-    }
-  }
-}
-
-set<int> scan_contained_in_product_indices(const instruction& inst, set<int>& ingredient_indices) {
-  set<reagent, name_and_space_lt> selected_ingredients;
-  const recipe& callee = get(Recipe, inst.operation);
-  for (set<int>::iterator p = ingredient_indices.begin();  p != ingredient_indices.end();  ++p) {
-    if (*p >= SIZE(callee.ingredients)) continue;  // optional immutable ingredient
-    selected_ingredients.insert(callee.ingredients.at(*p));
-  }
-  set<int> result;
-  for (int i = 0;  i < SIZE(callee.products);  ++i) {
-    const reagent& current_product = callee.products.at(i);
-    const string_tree* contained_in_name = property(current_product, "contained-in");
-    if (contained_in_name && selected_ingredients.find(contained_in_name->value) != selected_ingredients.end())
-      result.insert(i);
-  }
-  return result;
-}
-
-bool is_mu_container(const reagent& r) {
-  return is_mu_container(r.type);
-}
-bool is_mu_container(const type_tree* type) {
-  if (!type) return false;
-  if (!type->atom)
-    return is_mu_container(get_base_type(type));
-  if (type->value == 0) return false;
-  if (!contains_key(Type, type->value)) return false;  // error raised elsewhere
-  type_info& info = get(Type, type->value);
-  return info.kind == CONTAINER;
-}
-
-bool is_mu_exclusive_container(const reagent& r) {
-  return is_mu_exclusive_container(r.type);
-}
-bool is_mu_exclusive_container(const type_tree* type) {
-  if (!type) return false;
-  if (!type->atom)
-    return is_mu_exclusive_container(get_base_type(type));
-  if (type->value == 0) return false;
-  if (!contains_key(Type, type->value)) return false;  // error raised elsewhere
-  type_info& info = get(Type, type->value);
-  return info.kind == EXCLUSIVE_CONTAINER;
-}
-
-:(before "End Types")
-// reagent comparison -- only in the context of a single recipe
-struct name_and_space_lt {
-  bool operator()(const reagent& a, const reagent& b) const;
-};
-:(code)
-bool name_and_space_lt::operator()(const reagent& a, const reagent& b) const {
-  int aspace = 0, bspace = 0;
-  if (has_property(a, "space")) aspace = to_integer(property(a, "space")->value);
-  if (has_property(b, "space")) bspace = to_integer(property(b, "space")->value);
-  if (aspace != bspace) return aspace < bspace;
-  return a.name < b.name;
-}
-
-void test_immutability_infects_contained_in_variables() {
-  Hide_errors = true;
-  transform(
-      "container test-list [\n"
-      "  value:num\n"
-      "  next:&:test-list\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:test-list <- new test-list:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:test-list [\n"  // p is immutable
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  p2:&:test-list <- test-next p\n"  // p2 is immutable
-      "  *p2 <- put *p2, value:offset, 34\n"
-      "]\n"
-      "def test-next x:&:test-list -> y:&:test-list/contained-in:x [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- get *x, next:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: cannot modify 'p2' in instruction '*p2 <- put *p2, value:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product\n"
-  );
-}
-
-void check_immutable_ingredient_in_instruction(const instruction& inst, const set<reagent, name_and_space_lt>& current_ingredient_and_aliases, const string& original_ingredient_name, const recipe& caller) {
-  // first check if the instruction is directly modifying something it shouldn't
-  for (int i = 0;  i < SIZE(inst.products);  ++i) {
-    if (has_property(inst.products.at(i), "lookup")
-        && current_ingredient_and_aliases.find(inst.products.at(i)) != current_ingredient_and_aliases.end()) {
-      string current_product_name = inst.products.at(i).name;
-      if (current_product_name == original_ingredient_name)
-        raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << to_original_string(inst) << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-      else
-        raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << to_original_string(inst) << "' because that would modify " << original_ingredient_name << " which is an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-      return;
-    }
-  }
-  // check if there's any indirect modification going on
-  set<int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases);
-  if (current_ingredient_indices.empty()) return;  // ingredient not found in call
-  for (set<int>::iterator p = current_ingredient_indices.begin();  p != current_ingredient_indices.end();  ++p) {
-    const int current_ingredient_index = *p;
-    reagent current_ingredient = inst.ingredients.at(current_ingredient_index);
-    canonize_type(current_ingredient);
-    const string& current_ingredient_name = current_ingredient.name;
-    if (!contains_key(Recipe, inst.operation)) {
-      // primitive recipe
-      // we got here only because we got an instruction with an implicit product, and the instruction didn't explicitly spell it out
-      //    put x, y:offset, z
-      // instead of
-      //    x <- put x, y:offset, z
-      if (inst.operation == PUT || inst.operation == PUT_INDEX) {
-        if (current_ingredient_index == 0) {
-          if (current_ingredient_name == original_ingredient_name)
-            raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << to_original_string(inst) << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-          else
-            raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << to_original_string(inst) << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-        }
-      }
-    }
-    else {
-      // defined recipe
-      if (is_modified_in_recipe(inst.operation, current_ingredient_index, caller)) {
-        if (current_ingredient_name == original_ingredient_name)
-          raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << to_original_string(inst) << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-        else
-          raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << to_original_string(inst) << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end();
-      }
-    }
-  }
-}
-
-bool is_modified_in_recipe(const recipe_ordinal r, const int ingredient_index, const recipe& caller) {
-  const recipe& callee = get(Recipe, r);
-  if (!callee.has_header) {
-    raise << maybe(caller.name) << "can't check mutability of ingredients in recipe " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end();
-    return true;
-  }
-  if (ingredient_index >= SIZE(callee.ingredients)) return false;  // optional immutable ingredient
-  return is_present_in_products(callee, callee.ingredients.at(ingredient_index).name);
-}
-
-bool is_present_in_products(const recipe& callee, const string& ingredient_name) {
-  for (int i = 0;  i < SIZE(callee.products);  ++i) {
-    if (callee.products.at(i).name == ingredient_name)
-      return true;
-  }
-  return false;
-}
-
-set<int> ingredient_indices(const instruction& inst, const set<reagent, name_and_space_lt>& ingredient_names) {
-  set<int> result;
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (is_literal(inst.ingredients.at(i))) continue;
-    if (ingredient_names.find(inst.ingredients.at(i)) != ingredient_names.end())
-      result.insert(i);
-  }
-  return result;
-}
-
-//: Sometimes you want to pass in two addresses, one pointing inside the
-//: other. For example, you want to delete a node from a linked list. You
-//: can't pass both pointers back out, because if a caller tries to make both
-//: identical then you can't tell which value will be written on the way out.
-//:
-//: Experimental solution: just tell Mu that one points inside the other.
-//: This way we can return just one pointer as high up as necessary to capture
-//: all modifications performed by a recipe.
-//:
-//: We'll see if we end up wanting to abuse /contained-in for other reasons.
-
-void test_can_modify_contained_in_addresses() {
-  transform(
-      "container test-list [\n"
-      "  value:num\n"
-      "  next:&:test-list\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  p:&:test-list <- new test-list:type\n"
-      "  foo p\n"
-      "]\n"
-      "def foo p:&:test-list -> p:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  p2:&:test-list <- test-next p\n"
-      "  p <- test-remove p2, p\n"
-      "]\n"
-      "def test-next x:&:test-list -> y:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- get *x, next:offset\n"
-      "]\n"
-      "def test-remove x:&:test-list/contained-in:from, from:&:test-list -> from:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  *x <- put *x, value:offset, 34\n"  // can modify x
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(before "End Immutable Ingredients Special-cases")
-if (has_property(current_ingredient, "contained-in")) {
-  const string_tree* tmp = property(current_ingredient, "contained-in");
-  if (!tmp->atom
-      || (!is_present_in_ingredients(caller, tmp->value)
-          && !is_present_in_products(caller, tmp->value))) {
-    raise << maybe(caller.name) << "/contained-in can only point to another ingredient or product, but got '" << to_string(property(current_ingredient, "contained-in")) << "'\n" << end();
-  }
-  continue;
-}
-
-:(code)
-void test_contained_in_product() {
-  transform(
-      "container test-list [\n"
-      "  value:num\n"
-      "  next:&:test-list\n"
-      "]\n"
-      "def foo x:&:test-list/contained-in:result -> result:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy null\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_contained_in_is_mutable() {
-  transform(
-      "container test-list [\n"
-      "  value:num\n"
-      "  next:&:test-list\n"
-      "]\n"
-      "def foo x:&:test-list/contained-in:result -> result:&:test-list [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- copy x\n"
-      "  put *x, value:offset, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
diff --git a/archive/2.vm/058to_text.cc b/archive/2.vm/058to_text.cc
deleted file mode 100644
index 9cb14e14..00000000
--- a/archive/2.vm/058to_text.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-//: Primitive to convert any type to text (array of characters).
-//: Later layers will allow us to override this to do something smarter for
-//: specific types.
-
-:(before "End Primitive Recipe Declarations")
-TO_TEXT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "to-text", TO_TEXT);
-:(before "End Primitive Recipe Checks")
-case TO_TEXT: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'to-text' requires a single ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  // can handle any type
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case TO_TEXT: {
-  products.resize(1);
-  products.at(0).push_back(/*alloc id*/0);
-  products.at(0).push_back(new_mu_text(inspect(current_instruction().ingredients.at(0), ingredients.at(0))));
-  break;
-}
diff --git a/archive/2.vm/059to_text.mu b/archive/2.vm/059to_text.mu
deleted file mode 100644
index d45afb0a..00000000
--- a/archive/2.vm/059to_text.mu
+++ /dev/null
@@ -1,48 +0,0 @@
-# A couple of variants of 'to-text' that we'll use implicitly in stashes (see
-# later layers).
-#
-# Mu code might specialize them to be smarter, but I don't anticipate any need
-# beyond specializing 'to-text' itself.
-
-# 'shorter' variant of to-text, when you want to enable some sort of trimming
-# define it to be identical to 'to-text' by default
-def to-text-line x:_elem -> y:text [
-  local-scope
-  load-inputs
-  y <- to-text x
-]
-
-# variant for arrays (since we can't pass them around otherwise)
-def array-to-text-line x:&:@:_elem -> y:text [
-  local-scope
-  load-inputs
-  y <- to-text *x
-]
-
-scenario to-text-line-early-warning-for-static-dispatch [
-  x:text <- to-text-line 34
-  # just ensure there were no errors
-]
-
-scenario array-to-text-line-early-warning-for-static-dispatch [
-  n:&:@:num <- new number:type, 3
-  x:text <- array-to-text-line n
-  # just ensure there were no errors
-]
-
-# finally, a specialization for single characters
-def to-text c:char -> y:text [
-  local-scope
-  load-inputs
-  y <- new character:type, 1/capacity
-  *y <- put-index *y, 0, c
-]
-
-scenario character-to-text [
-  1:char <- copy 111/o
-  2:text <- to-text 1:char
-  3:@:char <- copy *2:text
-  memory-should-contain [
-    3:array:character <- [o]
-  ]
-]
diff --git a/archive/2.vm/060rewrite_literal_string.cc b/archive/2.vm/060rewrite_literal_string.cc
deleted file mode 100644
index 3e64fd7c..00000000
--- a/archive/2.vm/060rewrite_literal_string.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-//: allow using literal strings anywhere that will accept immutable strings
-
-void test_passing_literals_to_recipes() {
-  run(
-      "def main [\n"
-      "  1:num/raw <- foo [abc]\n"
-      "]\n"
-      "def foo x:text -> n:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  n <- length *x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 1\n"
-  );
-}
-
-:(before "End Instruction Inserting/Deleting Transforms")
-initialize_transform_rewrite_literal_string_to_text();
-Transform.push_back(rewrite_literal_string_to_text);  // idempotent
-
-:(before "End Globals")
-set<string> recipes_taking_literal_strings;
-:(code)
-void initialize_transform_rewrite_literal_string_to_text() {
-  recipes_taking_literal_strings.insert("assert");
-  recipes_taking_literal_strings.insert("$print");
-  recipes_taking_literal_strings.insert("$dump-trace");
-  recipes_taking_literal_strings.insert("$system");
-  recipes_taking_literal_strings.insert("trace");
-  recipes_taking_literal_strings.insert("stash");
-  recipes_taking_literal_strings.insert("new");
-  recipes_taking_literal_strings.insert("run");
-  recipes_taking_literal_strings.insert("memory-should-contain");
-  recipes_taking_literal_strings.insert("trace-should-contain");
-  recipes_taking_literal_strings.insert("trace-should-not-contain");
-  recipes_taking_literal_strings.insert("check-trace-count-for-label");
-  recipes_taking_literal_strings.insert("check-trace-count-for-label-greater-than");
-  recipes_taking_literal_strings.insert("check-trace-count-for-label-lesser-than");
-  // End initialize_transform_rewrite_literal_string_to_text()
-}
-
-void rewrite_literal_string_to_text(const recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- rewrite literal strings in recipe " << caller.name << end();
-  if (contains_numeric_locations(caller)) return;
-  vector<instruction> new_instructions;
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    instruction& inst = caller.steps.at(i);
-    if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) {
-      for (int j = 0;  j < SIZE(inst.ingredients);  ++j) {
-        if (!is_literal_text(inst.ingredients.at(j))) continue;
-        instruction def;
-        ostringstream ingredient_name;
-        ingredient_name << inst.name << '_' << i << '_' << j << ":text";
-        def.name = "new";
-        def.ingredients.push_back(inst.ingredients.at(j));
-        def.products.push_back(reagent(ingredient_name.str()));
-        new_instructions.push_back(def);
-        inst.ingredients.at(j).clear();  // reclaim old memory
-        inst.ingredients.at(j) = reagent(ingredient_name.str());
-      }
-    }
-    new_instructions.push_back(inst);
-  }
-  caller.steps.swap(new_instructions);
-}
-
-bool contains_numeric_locations(const recipe& caller) {
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    for (int in = 0;  in < SIZE(inst.ingredients);  ++in)
-      if (is_numeric_location(inst.ingredients.at(in)))
-        return true;
-    for (int out = 0;  out < SIZE(inst.products);  ++out)
-      if (is_numeric_location(inst.products.at(out)))
-        return true;
-  }
-  return false;
-}
diff --git a/archive/2.vm/061text.mu b/archive/2.vm/061text.mu
deleted file mode 100644
index 4d46319b..00000000
--- a/archive/2.vm/061text.mu
+++ /dev/null
@@ -1,1427 +0,0 @@
-# Some useful helpers for dealing with text (arrays of characters)
-
-def equal a:text, b:text -> result:bool [
-  local-scope
-  load-inputs
-  an:num, bn:num <- deaddress a, b
-  address-equal?:boolean <- equal an, bn
-  return-if address-equal?, true
-  return-unless a, false
-  return-unless b, false
-  a-len:num <- length *a
-  b-len:num <- length *b
-  # compare lengths
-  trace 99, [text-equal], [comparing lengths]
-  length-equal?:bool <- equal a-len, b-len
-  return-unless length-equal?, false
-  # compare each corresponding character
-  trace 99, [text-equal], [comparing characters]
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, a-len
-    break-if done?
-    a2:char <- index *a, i
-    b2:char <- index *b, i
-    chars-match?:bool <- equal a2, b2
-    return-unless chars-match?, false
-    i <- add i, 1
-    loop
-  }
-  return true
-]
-
-scenario text-equal-reflexive [
-  local-scope
-  x:text <- new [abc]
-  run [
-    10:bool/raw <- equal x, x
-  ]
-  memory-should-contain [
-    10 <- 1  # x == x for all x
-  ]
-]
-
-scenario text-equal-identical [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [abc]
-  run [
-    10:bool/raw <- equal x, y
-  ]
-  memory-should-contain [
-    10 <- 1  # abc == abc
-  ]
-]
-
-scenario text-equal-distinct-lengths [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [abcd]
-  run [
-    10:bool/raw <- equal x, y
-  ]
-  memory-should-contain [
-    10 <- 0  # abc != abcd
-  ]
-  trace-should-contain [
-    text-equal: comparing lengths
-  ]
-  trace-should-not-contain [
-    text-equal: comparing characters
-  ]
-]
-
-scenario text-equal-with-empty [
-  local-scope
-  x:text <- new []
-  y:text <- new [abcd]
-  run [
-    10:bool/raw <- equal x, y
-  ]
-  memory-should-contain [
-    10 <- 0  # "" != abcd
-  ]
-]
-
-scenario text-equal-with-null [
-  local-scope
-  x:text <- new [abcd]
-  y:text <- copy null
-  run [
-    10:bool/raw <- equal x, null
-    11:bool/raw <- equal null, x
-    12:bool/raw <- equal x, y
-    13:bool/raw <- equal y, x
-    14:bool/raw <- equal y, y
-  ]
-  memory-should-contain [
-    10 <- 0
-    11 <- 0
-    12 <- 0
-    13 <- 0
-    14 <- 1
-  ]
-  check-trace-count-for-label 0, [error]
-]
-
-scenario text-equal-common-lengths-but-distinct [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [abd]
-  run [
-    10:bool/raw <- equal x, y
-  ]
-  memory-should-contain [
-    10 <- 0  # abc != abd
-  ]
-]
-
-# A new type to help incrementally construct texts.
-container buffer:_elem [
-  length:num
-  data:&:@:_elem
-]
-
-def new-buffer capacity:num -> result:&:buffer:_elem [
-  local-scope
-  load-inputs
-  result <- new {(buffer _elem): type}
-  *result <- put *result, length:offset, 0
-  {
-    break-if capacity
-    # capacity not provided
-    capacity <- copy 10
-  }
-  data:&:@:_elem <- new _elem:type, capacity
-  *result <- put *result, data:offset, data
-  return result
-]
-
-def grow-buffer buf:&:buffer:_elem -> buf:&:buffer:_elem [
-  local-scope
-  load-inputs
-  # double buffer size
-  olddata:&:@:_elem <- get *buf, data:offset
-  oldlen:num <- length *olddata
-  newlen:num <- multiply oldlen, 2
-  newdata:&:@:_elem <- new _elem:type, newlen
-  *buf <- put *buf, data:offset, newdata
-  # copy old contents
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, oldlen
-    break-if done?
-    src:_elem <- index *olddata, i
-    *newdata <- put-index *newdata, i, src
-    i <- add i, 1
-    loop
-  }
-]
-
-def buffer-full? in:&:buffer:_elem -> result:bool [
-  local-scope
-  load-inputs
-  len:num <- get *in, length:offset
-  s:&:@:_elem <- get *in, data:offset
-  capacity:num <- length *s
-  result <- greater-or-equal len, capacity
-]
-
-# most broadly applicable definition of append to a buffer
-def append buf:&:buffer:_elem, x:_elem -> buf:&:buffer:_elem [
-  local-scope
-  load-inputs
-  len:num <- get *buf, length:offset
-  {
-    # grow buffer if necessary
-    full?:bool <- buffer-full? buf
-    break-unless full?
-    buf <- grow-buffer buf
-  }
-  s:&:@:_elem <- get *buf, data:offset
-  *s <- put-index *s, len, x
-  len <- add len, 1
-  *buf <- put *buf, length:offset, len
-]
-
-# most broadly applicable definition of append to a buffer of characters: just
-# call to-text
-def append buf:&:buffer:char, x:_elem -> buf:&:buffer:char [
-  local-scope
-  load-inputs
-  text:text <- to-text x
-  buf <- append buf, text
-]
-
-# specialization for characters that is backspace-aware
-def append buf:&:buffer:char, c:char -> buf:&:buffer:char [
-  local-scope
-  load-inputs
-  len:num <- get *buf, length:offset
-  {
-    # backspace? just drop last character if it exists and return
-    backspace?:bool <- equal c, 8/backspace
-    break-unless backspace?
-    empty?:bool <- lesser-or-equal len, 0
-    return-if empty?
-    len <- subtract len, 1
-    *buf <- put *buf, length:offset, len
-    return
-  }
-  {
-    # grow buffer if necessary
-    full?:bool <- buffer-full? buf
-    break-unless full?
-    buf <- grow-buffer buf
-  }
-  s:text <- get *buf, data:offset
-  *s <- put-index *s, len, c
-  len <- add len, 1
-  *buf <- put *buf, length:offset, len
-]
-
-def append buf:&:buffer:_elem, t:&:@:_elem -> buf:&:buffer:_elem [
-  local-scope
-  load-inputs
-  len:num <- length *t
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    x:_elem <- index *t, i
-    buf <- append buf, x
-    i <- add i, 1
-    loop
-  }
-]
-
-scenario append-to-empty-buffer [
-  local-scope
-  x:&:buffer:char <- new-buffer
-  run [
-    c:char <- copy 97/a
-    x <- append x, c
-    10:num/raw <- get *x, length:offset
-    s:text <- get *x, data:offset
-    11:char/raw <- index *s, 0
-    12:char/raw <- index *s, 1
-  ]
-  memory-should-contain [
-    10 <- 1  # buffer length
-    11 <- 97  # a
-    12 <- 0  # rest of buffer is empty
-  ]
-]
-
-scenario append-to-buffer [
-  local-scope
-  x:&:buffer:char <- new-buffer
-  c:char <- copy 97/a
-  x <- append x, c
-  run [
-    c <- copy 98/b
-    x <- append x, c
-    10:num/raw <- get *x, length:offset
-    s:text <- get *x, data:offset
-    11:char/raw <- index *s, 0
-    12:char/raw <- index *s, 1
-    13:char/raw <- index *s, 2
-  ]
-  memory-should-contain [
-    10 <- 2  # buffer length
-    11 <- 97  # a
-    12 <- 98  # b
-    13 <- 0  # rest of buffer is empty
-  ]
-]
-
-scenario append-grows-buffer [
-  local-scope
-  x:&:buffer:char <- new-buffer 3
-  s1:text <- get *x, data:offset
-  x <- append x, [abc]  # buffer is now full
-  s2:text <- get *x, data:offset
-  run [
-    10:bool/raw <- equal s1, s2
-    11:@:char/raw <- copy *s2
-    +buffer-filled
-    c:char <- copy 100/d
-    x <- append x, c
-    s3:text <- get *x, data:offset
-    20:bool/raw <- equal s1, s3
-    21:num/raw <- get *x, length:offset
-    30:@:char/raw <- copy *s3
-  ]
-  memory-should-contain [
-    # before +buffer-filled
-    10 <- 1   # no change in data pointer after original append
-    11 <- 3   # size of data
-    12 <- 97  # data
-    13 <- 98
-    14 <- 99
-    # in the end
-    20 <- 0   # data pointer has grown after second append
-    21 <- 4   # final length
-    30 <- 6   # but data's capacity has doubled
-    31 <- 97  # data
-    32 <- 98
-    33 <- 99
-    34 <- 100
-    35 <- 0
-    36 <- 0
-  ]
-]
-
-scenario buffer-append-handles-backspace [
-  local-scope
-  x:&:buffer:char <- new-buffer
-  x <- append x, [ab]
-  run [
-    c:char <- copy 8/backspace
-    x <- append x, c
-    s:text <- buffer-to-array x
-    10:@:char/raw <- copy *s
-  ]
-  memory-should-contain [
-    10 <- 1   # length
-    11 <- 97  # contents
-    12 <- 0
-  ]
-]
-
-scenario append-to-buffer-of-non-characters [
-  local-scope
-  x:&:buffer:text <- new-buffer 1/capacity
-  # no errors
-]
-
-def buffer-to-array in:&:buffer:_elem -> result:&:@:_elem [
-  local-scope
-  load-inputs
-  # propagate null buffer
-  return-unless in, null
-  len:num <- get *in, length:offset
-  s:&:@:_elem <- get *in, data:offset
-  # we can't just return s because it is usually the wrong length
-  result <- new _elem:type, len
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    src:_elem <- index *s, i
-    *result <- put-index *result, i, src
-    i <- add i, 1
-    loop
-  }
-]
-
-def blank? x:&:@:_elem -> result:bool [
-  local-scope
-  load-inputs
-  return-unless x, true
-  len:num <- length *x
-  result <- equal len, 0
-]
-
-# Append any number of texts together.
-# A later layer also translates calls to this to implicitly call to-text, so
-# append to string becomes effectively dynamically typed.
-#
-# Beware though: this hack restricts how much 'append' can be overridden. Any
-# new variants that match:
-#   append _:text, ___
-# will never ever get used.
-def append first:text -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 30
-  # append first input
-  {
-    break-unless first
-    buf <- append buf, first
-  }
-  # append remaining inputs
-  {
-    arg:text, arg-found?:bool <- next-input
-    break-unless arg-found?
-    loop-unless arg
-    buf <- append buf, arg
-    loop
-  }
-  result <- buffer-to-array buf
-]
-
-scenario text-append-1 [
-  local-scope
-  x:text <- new [hello,]
-  y:text <- new [ world!]
-  run [
-    z:text <- append x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [hello, world!]
-  ]
-]
-
-scenario text-append-null [
-  local-scope
-  x:text <- copy null
-  y:text <- new [ world!]
-  run [
-    z:text <- append x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [ world!]
-  ]
-]
-
-scenario text-append-null-2 [
-  local-scope
-  x:text <- new [hello,]
-  y:text <- copy null
-  run [
-    z:text <- append x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [hello,]
-  ]
-]
-
-scenario text-append-multiary [
-  local-scope
-  x:text <- new [hello, ]
-  y:text <- new [world]
-  z:text <- new [!]
-  run [
-    z:text <- append x, y, z
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [hello, world!]
-  ]
-]
-
-scenario replace-character-in-text [
-  local-scope
-  x:text <- new [abc]
-  run [
-    x <- replace x, 98/b, 122/z
-    10:@:char/raw <- copy *x
-  ]
-  memory-should-contain [
-    10:array:character <- [azc]
-  ]
-]
-
-def replace s:text, oldc:char, newc:char, from:num/optional -> s:text [
-  local-scope
-  load-inputs
-  len:num <- length *s
-  i:num <- find-next s, oldc, from
-  done?:bool <- greater-or-equal i, len
-  return-if done?
-  *s <- put-index *s, i, newc
-  i <- add i, 1
-  s <- replace s, oldc, newc, i
-]
-
-scenario replace-character-at-start [
-  local-scope
-  x:text <- new [abc]
-  run [
-    x <- replace x, 97/a, 122/z
-    10:@:char/raw <- copy *x
-  ]
-  memory-should-contain [
-    10:array:character <- [zbc]
-  ]
-]
-
-scenario replace-character-at-end [
-  local-scope
-  x:text <- new [abc]
-  run [
-    x <- replace x, 99/c, 122/z
-    10:@:char/raw <- copy *x
-  ]
-  memory-should-contain [
-    10:array:character <- [abz]
-  ]
-]
-
-scenario replace-character-missing [
-  local-scope
-  x:text <- new [abc]
-  run [
-    x <- replace x, 100/d, 122/z
-    10:@:char/raw <- copy *x
-  ]
-  memory-should-contain [
-    10:array:character <- [abc]
-  ]
-]
-
-scenario replace-all-characters [
-  local-scope
-  x:text <- new [banana]
-  run [
-    x <- replace x, 97/a, 122/z
-    10:@:char/raw <- copy *x
-  ]
-  memory-should-contain [
-    10:array:character <- [bznznz]
-  ]
-]
-
-# replace underscores in first with remaining args
-def interpolate template:text -> result:text [
-  local-scope
-  load-inputs  # consume just the template
-  # compute result-len, space to allocate for result
-  tem-len:num <- length *template
-  result-len:num <- copy tem-len
-  {
-    # while inputs remain
-    a:text, arg-received?:bool <- next-input
-    break-unless arg-received?
-    # result-len = result-len + arg.length - 1 (for the 'underscore' being replaced)
-    a-len:num <- length *a
-    result-len <- add result-len, a-len
-    result-len <- subtract result-len, 1
-    loop
-  }
-  rewind-inputs
-  _ <- next-input  # skip template
-  result <- new character:type, result-len
-  # repeatedly copy sections of template and 'holes' into result
-  result-idx:num <- copy 0
-  i:num <- copy 0
-  {
-    # while arg received
-    a:text, arg-received?:bool <- next-input
-    break-unless arg-received?
-    # copy template into result until '_'
-    {
-      # while i < template.length
-      tem-done?:bool <- greater-or-equal i, tem-len
-      break-if tem-done?, +done
-      # while template[i] != '_'
-      in:char <- index *template, i
-      underscore?:bool <- equal in, 95/_
-      break-if underscore?
-      # result[result-idx] = template[i]
-      *result <- put-index *result, result-idx, in
-      i <- add i, 1
-      result-idx <- add result-idx, 1
-      loop
-    }
-    # copy 'a' into result
-    j:num <- copy 0
-    {
-      # while j < a.length
-      arg-done?:bool <- greater-or-equal j, a-len
-      break-if arg-done?
-      # result[result-idx] = a[j]
-      in:char <- index *a, j
-      *result <- put-index *result, result-idx, in
-      j <- add j, 1
-      result-idx <- add result-idx, 1
-      loop
-    }
-    # skip '_' in template
-    i <- add i, 1
-    loop  # interpolate next arg
-  }
-  +done
-  # done with holes; copy rest of template directly into result
-  {
-    # while i < template.length
-    tem-done?:bool <- greater-or-equal i, tem-len
-    break-if tem-done?
-    # result[result-idx] = template[i]
-    in:char <- index *template, i
-    *result <- put-index *result, result-idx, in
-    i <- add i, 1
-    result-idx <- add result-idx, 1
-    loop
-  }
-]
-
-scenario interpolate-works [
-  local-scope
-  x:text <- new [abc_ghi]
-  y:text <- new [def]
-  run [
-    z:text <- interpolate x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [abcdefghi]
-  ]
-]
-
-scenario interpolate-at-start [
-  local-scope
-  x:text <- new [_, hello!]
-  y:text <- new [abc]
-  run [
-    z:text <- interpolate x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [abc, hello!]
-    22 <- 0  # out of bounds
-  ]
-]
-
-scenario interpolate-at-end [
-  local-scope
-  x:text <- new [hello, _]
-  y:text <- new [abc]
-  run [
-    z:text <- interpolate x, y
-    10:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [hello, abc]
-  ]
-]
-
-# result:bool <- space? c:char
-def space? c:char -> result:bool [
-  local-scope
-  load-inputs
-  # most common case first
-  result <- equal c, 32/space
-  return-if result
-  result <- equal c, 10/newline
-  return-if result
-  result <- equal c, 9/tab
-  return-if result
-  result <- equal c, 13/carriage-return
-  return-if result
-  # remaining uncommon cases in sorted order
-  # http://unicode.org code-points in unicode-set Z and Pattern_White_Space
-  result <- equal c, 11/ctrl-k
-  return-if result
-  result <- equal c, 12/ctrl-l
-  return-if result
-  result <- equal c, 133/ctrl-0085
-  return-if result
-  result <- equal c, 160/no-break-space
-  return-if result
-  result <- equal c, 5760/ogham-space-mark
-  return-if result
-  result <- equal c, 8192/en-quad
-  return-if result
-  result <- equal c, 8193/em-quad
-  return-if result
-  result <- equal c, 8194/en-space
-  return-if result
-  result <- equal c, 8195/em-space
-  return-if result
-  result <- equal c, 8196/three-per-em-space
-  return-if result
-  result <- equal c, 8197/four-per-em-space
-  return-if result
-  result <- equal c, 8198/six-per-em-space
-  return-if result
-  result <- equal c, 8199/figure-space
-  return-if result
-  result <- equal c, 8200/punctuation-space
-  return-if result
-  result <- equal c, 8201/thin-space
-  return-if result
-  result <- equal c, 8202/hair-space
-  return-if result
-  result <- equal c, 8206/left-to-right
-  return-if result
-  result <- equal c, 8207/right-to-left
-  return-if result
-  result <- equal c, 8232/line-separator
-  return-if result
-  result <- equal c, 8233/paragraph-separator
-  return-if result
-  result <- equal c, 8239/narrow-no-break-space
-  return-if result
-  result <- equal c, 8287/medium-mathematical-space
-  return-if result
-  result <- equal c, 12288/ideographic-space
-]
-
-def trim s:text -> result:text [
-  local-scope
-  load-inputs
-  len:num <- length *s
-  # left trim: compute start
-  start:num <- copy 0
-  {
-    {
-      at-end?:bool <- greater-or-equal start, len
-      break-unless at-end?
-      result <- new character:type, 0
-      return
-    }
-    curr:char <- index *s, start
-    whitespace?:bool <- space? curr
-    break-unless whitespace?
-    start <- add start, 1
-    loop
-  }
-  # right trim: compute end
-  end:num <- subtract len, 1
-  {
-    not-at-start?:bool <- greater-than end, start
-    assert not-at-start?, [end ran up against start]
-    curr:char <- index *s, end
-    whitespace?:bool <- space? curr
-    break-unless whitespace?
-    end <- subtract end, 1
-    loop
-  }
-  # result = new character[end+1 - start]
-  new-len:num <- subtract end, start, -1
-  result:text <- new character:type, new-len
-  # copy the untrimmed parts between start and end
-  i:num <- copy start
-  j:num <- copy 0
-  {
-    # while i <= end
-    done?:bool <- greater-than i, end
-    break-if done?
-    # result[j] = s[i]
-    src:char <- index *s, i
-    *result <- put-index *result, j, src
-    i <- add i, 1
-    j <- add j, 1
-    loop
-  }
-]
-
-scenario trim-unmodified [
-  local-scope
-  x:text <- new [abc]
-  run [
-    y:text <- trim x
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [abc]
-  ]
-]
-
-scenario trim-left [
-  local-scope
-  x:text <- new [  abc]
-  run [
-    y:text <- trim x
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [abc]
-  ]
-]
-
-scenario trim-right [
-  local-scope
-  x:text <- new [abc  ]
-  run [
-    y:text <- trim x
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [abc]
-  ]
-]
-
-scenario trim-left-right [
-  local-scope
-  x:text <- new [  abc   ]
-  run [
-    y:text <- trim x
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [abc]
-  ]
-]
-
-scenario trim-newline-tab [
-  local-scope
-  x:text <- new [	abc
-]
-  run [
-    y:text <- trim x
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [abc]
-  ]
-]
-
-def find-next text:text, pattern:char, idx:num -> next-index:num [
-  local-scope
-  load-inputs
-  len:num <- length *text
-  {
-    eof?:bool <- greater-or-equal idx, len
-    break-if eof?
-    curr:char <- index *text, idx
-    found?:bool <- equal curr, pattern
-    break-if found?
-    idx <- add idx, 1
-    loop
-  }
-  return idx
-]
-
-scenario text-find-next [
-  local-scope
-  x:text <- new [a/b]
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 1
-  ]
-]
-
-scenario text-find-next-empty [
-  local-scope
-  x:text <- new []
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 0
-  ]
-]
-
-scenario text-find-next-initial [
-  local-scope
-  x:text <- new [/abc]
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 0  # prefix match
-  ]
-]
-
-scenario text-find-next-final [
-  local-scope
-  x:text <- new [abc/]
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 3  # suffix match
-  ]
-]
-
-scenario text-find-next-missing [
-  local-scope
-  x:text <- new [abcd]
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 4  # no match
-  ]
-]
-
-scenario text-find-next-invalid-index [
-  local-scope
-  x:text <- new [abc]
-  run [
-    10:num/raw <- find-next x, 47/slash, 4/start-index
-  ]
-  memory-should-contain [
-    10 <- 4  # no change
-  ]
-]
-
-scenario text-find-next-first [
-  local-scope
-  x:text <- new [ab/c/]
-  run [
-    10:num/raw <- find-next x, 47/slash, 0/start-index
-  ]
-  memory-should-contain [
-    10 <- 2  # first '/' of multiple
-  ]
-]
-
-scenario text-find-next-second [
-  local-scope
-  x:text <- new [ab/c/]
-  run [
-    10:num/raw <- find-next x, 47/slash, 3/start-index
-  ]
-  memory-should-contain [
-    10 <- 4  # second '/' of multiple
-  ]
-]
-
-# search for a pattern of multiple characters
-# fairly dumb algorithm
-def find-next text:text, pattern:text, idx:num -> next-index:num [
-  local-scope
-  load-inputs
-  first:char <- index *pattern, 0
-  # repeatedly check for match at current idx
-  len:num <- length *text
-  {
-    # does some unnecessary work checking even when there isn't enough of text left
-    done?:bool <- greater-or-equal idx, len
-    break-if done?
-    found?:bool <- match-at text, pattern, idx
-    break-if found?
-    idx <- add idx, 1
-    # optimization: skip past indices that definitely won't match
-    idx <- find-next text, first, idx
-    loop
-  }
-  return idx
-]
-
-scenario find-next-text-1 [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [bc]
-  run [
-    10:num/raw <- find-next x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 1
-  ]
-]
-
-scenario find-next-text-2 [
-  local-scope
-  x:text <- new [abcd]
-  y:text <- new [bc]
-  run [
-    10:num/raw <- find-next x, y, 1
-  ]
-  memory-should-contain [
-    10 <- 1
-  ]
-]
-
-scenario find-next-no-match [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [bd]
-  run [
-    10:num/raw <- find-next x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 3  # not found
-  ]
-]
-
-scenario find-next-suffix-match [
-  local-scope
-  x:text <- new [abcd]
-  y:text <- new [cd]
-  run [
-    10:num/raw <- find-next x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 2
-  ]
-]
-
-scenario find-next-suffix-match-2 [
-  local-scope
-  x:text <- new [abcd]
-  y:text <- new [cde]
-  run [
-    10:num/raw <- find-next x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 4  # not found
-  ]
-]
-
-# checks if pattern matches at index 'idx'
-def match-at text:text, pattern:text, idx:num -> result:bool [
-  local-scope
-  load-inputs
-  pattern-len:num <- length *pattern
-  # check that there's space left for the pattern
-  x:num <- length *text
-  x <- subtract x, pattern-len
-  enough-room?:bool <- lesser-or-equal idx, x
-  return-unless enough-room?, false/not-found
-  # check each character of pattern
-  pattern-idx:num <- copy 0
-  {
-    done?:bool <- greater-or-equal pattern-idx, pattern-len
-    break-if done?
-    c:char <- index *text, idx
-    exp:char <- index *pattern, pattern-idx
-    match?:bool <- equal c, exp
-    return-unless match?, false/not-found
-    idx <- add idx, 1
-    pattern-idx <- add pattern-idx, 1
-    loop
-  }
-  return true/found
-]
-
-scenario match-at-checks-pattern-at-index [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [ab]
-  run [
-    10:bool/raw <- match-at x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 1  # match found
-  ]
-]
-
-scenario match-at-reflexive [
-  local-scope
-  x:text <- new [abc]
-  run [
-    10:bool/raw <- match-at x, x, 0
-  ]
-  memory-should-contain [
-    10 <- 1  # match found
-  ]
-]
-
-scenario match-at-outside-bounds [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [a]
-  run [
-    10:bool/raw <- match-at x, y, 4
-  ]
-  memory-should-contain [
-    10 <- 0  # never matches
-  ]
-]
-
-scenario match-at-empty-pattern [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new []
-  run [
-    10:bool/raw <- match-at x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 1  # always matches empty pattern given a valid index
-  ]
-]
-
-scenario match-at-empty-pattern-outside-bound [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new []
-  run [
-    10:bool/raw <- match-at x, y, 4
-  ]
-  memory-should-contain [
-    10 <- 0  # no match
-  ]
-]
-
-scenario match-at-empty-text [
-  local-scope
-  x:text <- new []
-  y:text <- new [abc]
-  run [
-    10:bool/raw <- match-at x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 0  # no match
-  ]
-]
-
-scenario match-at-empty-against-empty [
-  local-scope
-  x:text <- new []
-  run [
-    10:bool/raw <- match-at x, x, 0
-  ]
-  memory-should-contain [
-    10 <- 1  # matches because pattern is also empty
-  ]
-]
-
-scenario match-at-inside-bounds [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [bc]
-  run [
-    10:bool/raw <- match-at x, y, 1
-  ]
-  memory-should-contain [
-    10 <- 1  # match
-  ]
-]
-
-scenario match-at-inside-bounds-2 [
-  local-scope
-  x:text <- new [abc]
-  y:text <- new [bc]
-  run [
-    10:bool/raw <- match-at x, y, 0
-  ]
-  memory-should-contain [
-    10 <- 0  # no match
-  ]
-]
-
-def split s:text, delim:char -> result:&:@:text [
-  local-scope
-  load-inputs
-  # empty text? return empty array
-  len:num <- length *s
-  {
-    empty?:bool <- equal len, 0
-    break-unless empty?
-    result <- new {(address array character): type}, 0
-    return
-  }
-  # count #pieces we need room for
-  count:num <- copy 1  # n delimiters = n+1 pieces
-  idx:num <- copy 0
-  {
-    idx <- find-next s, delim, idx
-    done?:bool <- greater-or-equal idx, len
-    break-if done?
-    idx <- add idx, 1
-    count <- add count, 1
-    loop
-  }
-  # allocate space
-  result <- new {(address array character): type}, count
-  # repeatedly copy slices start..end until delimiter into result[curr-result]
-  curr-result:num <- copy 0
-  start:num <- copy 0
-  {
-    # while next delim exists
-    done?:bool <- greater-or-equal start, len
-    break-if done?
-    end:num <- find-next s, delim, start
-    # copy start..end into result[curr-result]
-    dest:text <- copy-range s, start, end
-    *result <- put-index *result, curr-result, dest
-    # slide over to next slice
-    start <- add end, 1
-    curr-result <- add curr-result, 1
-    loop
-  }
-]
-
-scenario text-split-1 [
-  local-scope
-  x:text <- new [a/b]
-  run [
-    y:&:@:text <- split x, 47/slash
-    10:num/raw <- length *y
-    a:text <- index *y, 0
-    b:text <- index *y, 1
-    20:@:char/raw <- copy *a
-    30:@:char/raw <- copy *b
-  ]
-  memory-should-contain [
-    10 <- 2  # length of result
-    20:array:character <- [a]
-    30:array:character <- [b]
-  ]
-]
-
-scenario text-split-2 [
-  local-scope
-  x:text <- new [a/b/c]
-  run [
-    y:&:@:text <- split x, 47/slash
-    10:num/raw <- length *y
-    a:text <- index *y, 0
-    b:text <- index *y, 1
-    c:text <- index *y, 2
-    20:@:char/raw <- copy *a
-    30:@:char/raw <- copy *b
-    40:@:char/raw <- copy *c
-  ]
-  memory-should-contain [
-    10 <- 3  # length of result
-    20:array:character <- [a]
-    30:array:character <- [b]
-    40:array:character <- [c]
-  ]
-]
-
-scenario text-split-missing [
-  local-scope
-  x:text <- new [abc]
-  run [
-    y:&:@:text <- split x, 47/slash
-    10:num/raw <- length *y
-    a:text <- index *y, 0
-    20:@:char/raw <- copy *a
-  ]
-  memory-should-contain [
-    10 <- 1  # length of result
-    20:array:character <- [abc]
-  ]
-]
-
-scenario text-split-empty [
-  local-scope
-  x:text <- new []
-  run [
-    y:&:@:text <- split x, 47/slash
-    10:num/raw <- length *y
-  ]
-  memory-should-contain [
-    10 <- 0  # empty result
-  ]
-]
-
-scenario text-split-empty-piece [
-  local-scope
-  x:text <- new [a/b//c]
-  run [
-    y:&:@:text <- split x:text, 47/slash
-    10:num/raw <- length *y
-    a:text <- index *y, 0
-    b:text <- index *y, 1
-    c:text <- index *y, 2
-    d:text <- index *y, 3
-    20:@:char/raw <- copy *a
-    30:@:char/raw <- copy *b
-    40:@:char/raw <- copy *c
-    50:@:char/raw <- copy *d
-  ]
-  memory-should-contain [
-    10 <- 4  # length of result
-    20:array:character <- [a]
-    30:array:character <- [b]
-    40:array:character <- []
-    50:array:character <- [c]
-  ]
-]
-
-def split-first text:text, delim:char -> x:text, y:text [
-  local-scope
-  load-inputs
-  # empty text? return empty texts
-  len:num <- length *text
-  {
-    empty?:bool <- equal len, 0
-    break-unless empty?
-    x:text <- new []
-    y:text <- new []
-    return
-  }
-  idx:num <- find-next text, delim, 0
-  x:text <- copy-range text, 0, idx
-  idx <- add idx, 1
-  y:text <- copy-range text, idx, len
-]
-
-scenario text-split-first [
-  local-scope
-  x:text <- new [a/b]
-  run [
-    y:text, z:text <- split-first x, 47/slash
-    10:@:char/raw <- copy *y
-    20:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [a]
-    20:array:character <- [b]
-  ]
-]
-
-def copy-range buf:text, start:num, end:num -> result:text [
-  local-scope
-  load-inputs
-  # if end is out of bounds, trim it
-  len:num <- length *buf
-  end:num <- min len, end
-  # allocate space for result
-  len <- subtract end, start
-  result:text <- new character:type, len
-  # copy start..end into result[curr-result]
-  src-idx:num <- copy start
-  dest-idx:num <- copy 0
-  {
-    done?:bool <- greater-or-equal src-idx, end
-    break-if done?
-    src:char <- index *buf, src-idx
-    *result <- put-index *result, dest-idx, src
-    src-idx <- add src-idx, 1
-    dest-idx <- add dest-idx, 1
-    loop
-  }
-]
-
-scenario copy-range-works [
-  local-scope
-  x:text <- new [abc]
-  run [
-    y:text <- copy-range x, 1, 3
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [bc]
-  ]
-]
-
-scenario copy-range-out-of-bounds [
-  local-scope
-  x:text <- new [abc]
-  run [
-    y:text <- copy-range x, 2, 4
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- [c]
-  ]
-]
-
-scenario copy-range-out-of-bounds-2 [
-  local-scope
-  x:text <- new [abc]
-  run [
-    y:text <- copy-range x, 3, 3
-    1:@:char/raw <- copy *y
-  ]
-  memory-should-contain [
-    1:array:character <- []
-  ]
-]
-
-def parse-whole-number in:text -> out:num, error?:bool [
-  local-scope
-  load-inputs
-  out <- copy 0
-  result:num <- copy 0  # temporary location
-  i:num <- copy 0
-  len:num <- length *in
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    c:char <- index *in, i
-    x:num <- character-to-code c
-    digit:num, error?:bool <- character-code-to-digit x
-    return-if error?
-    result <- multiply result, 10
-    result <- add result, digit
-    i <- add i, 1
-    loop
-  }
-  # no error; all digits were valid
-  out <- copy result
-]
-
-# (contributed by Ella Couch)
-recipe character-code-to-digit character-code:number -> result:number, error?:boolean [
-  local-scope
-  load-inputs
-  result <- copy 0
-  error? <- lesser-than character-code, 48  # '0'
-  return-if error?
-  error? <- greater-than character-code, 57  # '9'
-  return-if error?
-  result <- subtract character-code, 48
-]
-
-scenario character-code-to-digit-contain-only-digit [
-  local-scope
-  a:number <- copy 48  # character code for '0'
-  run [
-    10:number/raw, 11:boolean/raw <- character-code-to-digit a
-  ]
-  memory-should-contain [
-    10 <- 0
-    11 <- 0  # no error
-  ]
-]
-
-scenario character-code-to-digit-contain-only-digit-2 [
-  local-scope
-  a:number <- copy 57  # character code for '9'
-  run [
-    1:number/raw, 2:boolean/raw <- character-code-to-digit a
-  ]
-  memory-should-contain [
-    1 <- 9
-    2 <- 0  # no error
-  ]
-]
-
-scenario character-code-to-digit-handles-codes-lower-than-zero [
-  local-scope
-  a:number <- copy 47
-  run [
-    10:number/raw, 11:boolean/raw <- character-code-to-digit a
-  ]
-  memory-should-contain [
-    10 <- 0
-    11 <- 1  # error
-  ]
-]
-
-scenario character-code-to-digit-handles-codes-larger-than-nine [
-  local-scope
-  a:number <- copy 58
-  run [
-    10:number/raw, 11:boolean/raw <- character-code-to-digit a
-  ]
-  memory-should-contain [
-    10 <- 0
-    11 <- 1  # error
-  ]
-]
diff --git a/archive/2.vm/062convert_ingredients_to_text.cc b/archive/2.vm/062convert_ingredients_to_text.cc
deleted file mode 100644
index a0a74bd4..00000000
--- a/archive/2.vm/062convert_ingredients_to_text.cc
+++ /dev/null
@@ -1,212 +0,0 @@
-//: make some recipes more friendly by trying to auto-convert their ingredients to text
-
-void test_rewrite_stashes_to_text() {
-  transform(
-      "def main [\n"
-      "  local-scope\n"
-      "  n:num <- copy 34\n"
-      "  stash n\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: {stash_2_0: (\"address\" \"array\" \"character\")} <- to-text-line {n: \"number\"}\n"
-      "transform: stash {stash_2_0: (\"address\" \"array\" \"character\")}\n"
-  );
-}
-
-void test_rewrite_traces_to_text() {
-  transform(
-      "def main [\n"
-      "  local-scope\n"
-      "  n:num <- copy 34\n"
-      "  trace 2, [app], n\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: {trace_2_2: (\"address\" \"array\" \"character\")} <- to-text-line {n: \"number\"}\n"
-      "transform: trace {2: \"literal\"}, {\"app\": \"literal-string\"}, {trace_2_2: (\"address\" \"array\" \"character\")}\n"
-  );
-}
-
-//: special case: rewrite attempts to stash contents of most arrays to avoid
-//: passing addresses around
-
-void test_rewrite_stashes_of_arrays() {
-  transform(
-      "def main [\n"
-      "  local-scope\n"
-      "  n:&:@:num <- new number:type, 3\n"
-      "  stash *n\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: {stash_2_0: (\"address\" \"array\" \"character\")} <- array-to-text-line {n: (\"address\" \"array\" \"number\")}\n"
-      "transform: stash {stash_2_0: (\"address\" \"array\" \"character\")}\n"
-  );
-}
-
-void test_ignore_stashes_of_static_arrays() {
-  transform(
-      "def main [\n"
-      "  local-scope\n"
-      "  n:@:num:3 <- create-array\n"
-      "  stash n\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: stash {n: (\"array\" \"number\" \"3\")}\n"
-  );
-}
-
-void test_rewrite_stashes_of_recipe_header_products() {
-  transform(
-      "container foo [\n"
-      "  x:num\n"
-      "]\n"
-      "def bar -> x:foo [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  x <- merge 34\n"
-      "  stash x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "transform: stash {stash_2_0: (\"address\" \"array\" \"character\")}\n"
-  );
-}
-
-//: misplaced; should be in instruction inserting/deleting transforms, but has
-//: prerequisites: deduce_types_from_header and check_or_set_types_by_name
-:(after "Transform.push_back(deduce_types_from_header)")
-Transform.push_back(convert_ingredients_to_text);  // idempotent
-
-:(code)
-void convert_ingredients_to_text(const recipe_ordinal r) {
-  recipe& caller = get(Recipe, r);
-  trace(101, "transform") << "--- convert some ingredients to text in recipe " << caller.name << end();
-  // in recipes without named locations, 'stash' is still not extensible
-  if (contains_numeric_locations(caller)) return;
-  convert_ingredients_to_text(caller);
-}
-
-void convert_ingredients_to_text(recipe& caller) {
-  vector<instruction> new_instructions;
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    instruction& inst = caller.steps.at(i);
-    // all these cases are getting hairy. how can we make this extensible?
-    if (inst.name == "stash") {
-      for (int j = 0;  j < SIZE(inst.ingredients);  ++j) {
-        if (is_literal_text(inst.ingredients.at(j))) continue;
-        ostringstream ingredient_name;
-        ingredient_name << "stash_" << i << '_' << j << ":address:array:character";
-        convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
-      }
-    }
-    else if (inst.name == "trace") {
-      for (int j = /*skip*/2;  j < SIZE(inst.ingredients);  ++j) {
-        if (is_literal_text(inst.ingredients.at(j))) continue;
-        ostringstream ingredient_name;
-        ingredient_name << "trace_" << i << '_' << j << ":address:array:character";
-        convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
-      }
-    }
-    else if (inst.name_before_rewrite == "append") {
-      // override only variants that try to append to a string
-      // Beware: this hack restricts how much 'append' can be overridden. Any
-      // new variants that match:
-      //   append _:text, ___
-      // will never ever get used.
-      if (is_literal_text(inst.ingredients.at(0)) || is_mu_text(inst.ingredients.at(0))) {
-        for (int j = /*skip base*/1;  j < SIZE(inst.ingredients);  ++j) {
-          ostringstream ingredient_name;
-          ingredient_name << "append_" << i << '_' << j << ":address:array:character";
-          convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str());
-        }
-      }
-    }
-    trace(103, "transform") << to_string(inst) << end();
-    new_instructions.push_back(inst);
-  }
-  caller.steps.swap(new_instructions);
-}
-
-// add an instruction to convert reagent 'r' to text in list 'out', then
-// replace r with converted text
-void convert_ingredient_to_text(reagent& r, vector<instruction>& out, const string& tmp_var) {
-  if (!r.type) return;  // error; will be handled elsewhere
-  if (is_mu_text(r)) return;
-  // don't try to extend static arrays
-  if (is_static_array(r)) return;
-  instruction def;
-  if (is_lookup_of_address_of_array(r)) {
-    def.name = "array-to-text-line";
-    reagent/*copy*/ tmp = r;
-    drop_one_lookup(tmp);
-    def.ingredients.push_back(tmp);
-  }
-  else {
-    def.name = "to-text-line";
-    def.ingredients.push_back(r);
-  }
-  def.products.push_back(reagent(tmp_var));
-  trace(103, "transform") << to_string(def) << end();
-  out.push_back(def);
-  r.clear();  // reclaim old memory
-  r = reagent(tmp_var);
-}
-
-bool is_lookup_of_address_of_array(reagent/*copy*/ x) {
-  if (x.type->atom) return false;
-  if (x.type->left->name != "address") return false;
-  if (!canonize_type(x)) return false;
-  return is_mu_array(x);
-}
-
-bool is_static_array(const reagent& x) {
-  // no canonize_type()
-  return !x.type->atom && x.type->left->atom && x.type->left->name == "array";
-}
-
-//: Supporting 'append' above requires remembering what name an instruction
-//: had before any rewrites or transforms.
-:(before "End instruction Fields")
-string name_before_rewrite;
-:(before "End instruction Clear")
-name_before_rewrite.clear();
-:(before "End next_instruction(curr)")
-curr->name_before_rewrite = curr->name;
-
-:(code)
-void test_append_other_types_to_text() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  n:num <- copy 11\n"
-      "  c:char <- copy 111/o\n"
-      "  a:text <- append [abc], 10, n, c\n"
-      "  expected:text <- new [abc1011o]\n"
-      "  10:bool/raw <- equal a, expected\n"
-      "]\n"
-  );
-}
-
-//: Make sure that the new system is strictly better than just the 'stash'
-//: primitive by itself.
-
-void test_rewrite_stash_continues_to_fall_back_to_default_implementation() {
-  run(
-      // type without a to-text implementation
-      "container foo [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  x:foo <- merge 34, 35\n"
-      "  stash x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "app: 34 35\n"
-  );
-}
diff --git a/archive/2.vm/063array.mu b/archive/2.vm/063array.mu
deleted file mode 100644
index a56e87f0..00000000
--- a/archive/2.vm/063array.mu
+++ /dev/null
@@ -1,181 +0,0 @@
-scenario array-from-args [
-  run [
-    local-scope
-    x:&:@:num <- new-array 0, 1, 2
-    10:@:num/raw <- copy *x
-  ]
-  memory-should-contain [
-    10 <- 3  # array length
-    11 <- 0
-    12 <- 1
-    13 <- 2
-  ]
-]
-
-# create an array out of a list of args
-def new-array -> result:&:@:_elem [
-  local-scope
-  capacity:num <- copy 0
-  {
-    # while read curr-value
-    curr-value:_elem, exists?:bool <- next-input
-    break-unless exists?
-    capacity <- add capacity, 1
-    loop
-  }
-  result <- new _elem:type, capacity
-  rewind-inputs
-  i:num <- copy 0
-  {
-    # while read curr-value
-    done?:bool <- greater-or-equal i, capacity
-    break-if done?
-    curr-value:_elem, exists?:bool <- next-input
-    assert exists?, [error in rewinding inputs to new-array]
-    *result <- put-index *result, i, curr-value
-    i <- add i, 1
-    loop
-  }
-  return result
-]
-
-# fill an existing array with a set of numbers
-# (contributed by Caleb Couch)
-def fill array:&:@:num -> array:&:@:num [
-  local-scope
-  load-inputs
-  loopn:num <- copy 0
-  length:num <- length *array
-  {
-    length?:bool <- equal loopn, length
-    break-if length?
-    object:num, arg-received?:bool <- next-input
-    break-unless arg-received?
-    *array <- put-index *array, loopn, object
-    loopn <- add loopn, 1
-    loop
-  }
-]
-
-scenario fill-on-an-empty-array [
-  local-scope
-  array:&:@:num <- new number:type, 3
-  run [
-    array <- fill array, 1 2 3
-    10:@:num/raw <- copy *array
-  ]
-  memory-should-contain [
-    10 <- 3
-    11 <- 1
-    12 <- 2
-    13 <- 3
-  ]
-]
-
-scenario fill-overwrites-existing-values [
-  local-scope
-  array:&:@:num <- new number:type, 3
-  *array <- put-index *array, 0, 4
-  run [
-    array <- fill array, 1 2 3
-    10:@:num/raw <- copy *array
-  ]
-  memory-should-contain [
-    10 <- 3
-    11 <- 1
-    12 <- 2
-    13 <- 3
-  ]
-]
-
-scenario fill-exits-gracefully-when-given-no-inputs [
-  local-scope
-  array:&:@:num <- new number:type, 3
-  run [
-    array <- fill array
-    10:@:num/raw <- copy *array
-  ]
-  memory-should-contain [
-    10 <- 3
-    11 <- 0
-    12 <- 0
-    13 <- 0
-  ]
-]
-
-# swap two elements of an array
-# (contributed by Caleb Couch)
-def swap array:&:@:num, index1:num, index2:num -> array:&:@:num [
-  local-scope
-  load-inputs
-  object1:num <- index *array, index1
-  object2:num <- index *array, index2
-  *array <- put-index *array, index1, object2
-  *array <- put-index *array, index2, object1
-]
-
-scenario swap-works [
-  local-scope
-  array:&:@:num <- new number:type, 4
-  array <- fill array, 4 3 2 1
-  run [
-    array <- swap array, 0, 2
-    10:num/raw <- index *array, 0
-    11:num/raw <- index *array, 2
-  ]
-  memory-should-contain [
-    10 <- 2
-    11 <- 4
-  ]
-]
-
-# reverse the elements of an array
-# (contributed by Caleb Couch)
-def reverse array:&:@:_elem -> array:&:@:_elem [
-  local-scope
-  load-inputs
-  start:num <- copy 0
-  length:num <- length *array
-  end:num <- subtract length, 1
-  {
-    done?:bool <- greater-or-equal start, end
-    break-if done?
-    array <- swap array, start, end
-    start <- add start, 1
-    end <- subtract end, 1
-    loop
-  }
-]
-
-scenario reverse-array-odd-length [
-  local-scope
-  array:&:@:num <- new number:type, 3
-  array <- fill array, 3 2 1
-  run [
-    array <- reverse array
-    10:@:num/raw <- copy *array
-  ]
-  memory-should-contain [
-    10 <- 3
-    11 <- 1
-    12 <- 2
-    13 <- 3
-  ]
-]
-
-scenario reverse-array-even-length [
-  local-scope
-  array:&:@:num <- new number:type, 4
-  array <- fill array, 4 3 2 1
-  run [
-    array <- reverse array
-    10:@:num/raw <- copy *array
-  ]
-  memory-should-contain [
-    10 <- 4
-    11 <- 1
-    12 <- 2
-    13 <- 3
-    14 <- 4
-  ]
-]
diff --git a/archive/2.vm/064list.mu b/archive/2.vm/064list.mu
deleted file mode 100644
index d669ec2c..00000000
--- a/archive/2.vm/064list.mu
+++ /dev/null
@@ -1,366 +0,0 @@
-# A list links up multiple objects together to make them easier to manage.
-#
-# The objects must be of the same type. If you want to store multiple types in
-# a single list, use an exclusive-container.
-
-container list:_elem [
-  value:_elem
-  next:&:list:_elem
-]
-
-def push x:_elem, l:&:list:_elem -> result:&:list:_elem/contained-in:l [
-  local-scope
-  load-inputs
-  result <- new {(list _elem): type}
-  *result <- merge x, l
-]
-
-def first in:&:list:_elem -> result:_elem [
-  local-scope
-  load-inputs
-  result <- get *in, value:offset
-]
-
-def rest in:&:list:_elem -> result:&:list:_elem/contained-in:in [
-  local-scope
-  load-inputs
-  result <- get *in, next:offset
-]
-
-scenario list-handling [
-  run [
-    local-scope
-    x:&:list:num <- push 3, null
-    x <- push 4, x
-    x <- push 5, x
-    10:num/raw <- first x
-    x <- rest x
-    11:num/raw <- first x
-    x <- rest x
-    12:num/raw <- first x
-    20:&:list:num/raw <- rest x
-  ]
-  memory-should-contain [
-    10 <- 5
-    11 <- 4
-    12 <- 3
-    20 <- 0  # nothing left
-  ]
-]
-
-def length l:&:list:_elem -> result:num [
-  local-scope
-  load-inputs
-  result <- copy 0
-  {
-    break-unless l
-    result <- add result, 1
-    l <- rest l
-    loop
-  }
-]
-
-# insert 'x' after 'in'
-def insert x:_elem, in:&:list:_elem -> in:&:list:_elem [
-  local-scope
-  load-inputs
-  new-node:&:list:_elem <- new {(list _elem): type}
-  *new-node <- put *new-node, value:offset, x
-  next-node:&:list:_elem <- get *in, next:offset
-  *in <- put *in, next:offset, new-node
-  *new-node <- put *new-node, next:offset, next-node
-]
-
-scenario inserting-into-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:list:num <- rest list  # inside list
-    list2 <- insert 6, list2
-    # check structure
-    list2 <- copy list
-    10:num/raw <- first list2
-    list2 <- rest list2
-    11:num/raw <- first list2
-    list2 <- rest list2
-    12:num/raw <- first list2
-    list2 <- rest list2
-    13:num/raw <- first list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 4
-    12 <- 6  # inserted element
-    13 <- 3
-  ]
-]
-
-scenario inserting-at-end-of-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:list:num <- rest list  # inside list
-    list2 <- rest list2  # now at end of list
-    list2 <- insert 6, list2
-    # check structure like before
-    list2 <- copy list
-    10:num/raw <- first list2
-    list2 <- rest list2
-    11:num/raw <- first list2
-    list2 <- rest list2
-    12:num/raw <- first list2
-    list2 <- rest list2
-    13:num/raw <- first list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 4
-    12 <- 3
-    13 <- 6  # inserted element
-  ]
-]
-
-scenario inserting-after-start-of-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list <- insert 6, list
-    # check structure like before
-    list2:&:list:num <- copy list
-    10:num/raw <- first list2
-    list2 <- rest list2
-    11:num/raw <- first list2
-    list2 <- rest list2
-    12:num/raw <- first list2
-    list2 <- rest list2
-    13:num/raw <- first list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 6  # inserted element
-    12 <- 4
-    13 <- 3
-  ]
-]
-
-# remove 'x' from its surrounding list 'in'
-#
-# Returns null if and only if list is empty. Beware: in that case any other
-# pointers to the head are now invalid.
-def remove x:&:list:_elem/contained-in:in, in:&:list:_elem -> in:&:list:_elem [
-  local-scope
-  load-inputs
-  # if 'x' is null, return
-  return-unless x
-  next-node:&:list:_elem <- rest x
-  # clear next pointer of 'x'
-  *x <- put *x, next:offset, null
-  # if 'x' is at the head of 'in', return the new head
-  at-head?:bool <- equal x, in
-  return-if at-head?, next-node
-  # compute prev-node
-  prev-node:&:list:_elem <- copy in
-  curr:&:list:_elem <- rest prev-node
-  {
-    return-unless curr
-    found?:bool <- equal curr, x
-    break-if found?
-    prev-node <- copy curr
-    curr <- rest curr
-  }
-  # set its next pointer to skip 'x'
-  *prev-node <- put *prev-node, next:offset, next-node
-]
-
-scenario removing-from-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:list:num <- rest list  # second element
-    list <- remove list2, list
-    10:bool/raw <- equal list2, null
-    # check structure like before
-    list2 <- copy list
-    11:num/raw <- first list2
-    list2 <- rest list2
-    12:num/raw <- first list2
-    20:&:list:num/raw <- rest list2
-  ]
-  memory-should-contain [
-    10 <- 0  # remove returned non-null
-    11 <- 5  # scanning next, skipping deleted element
-    12 <- 3
-    20 <- 0  # no more elements
-  ]
-]
-
-scenario removing-from-start-of-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list <- remove list, list
-    # check structure like before
-    list2:&:list:num <- copy list
-    10:num/raw <- first list2
-    list2 <- rest list2
-    11:num/raw <- first list2
-    20:&:list:num/raw <- rest list2
-  ]
-  memory-should-contain [
-    10 <- 4  # scanning next, skipping deleted element
-    11 <- 3
-    20 <- 0  # no more elements
-  ]
-]
-
-scenario removing-from-end-of-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    # delete last element
-    list2:&:list:num <- rest list
-    list2 <- rest list2
-    list <- remove list2, list
-    10:bool/raw <- equal list2, null
-    # check structure like before
-    list2 <- copy list
-    11:num/raw <- first list2
-    list2 <- rest list2
-    12:num/raw <- first list2
-    20:&:list:num/raw <- rest list2
-  ]
-  memory-should-contain [
-    10 <- 0  # remove returned non-null
-    11 <- 5  # scanning next, skipping deleted element
-    12 <- 4
-    20 <- 0  # no more elements
-  ]
-]
-
-scenario removing-from-singleton-list [
-  local-scope
-  list:&:list:num <- push 3, null
-  run [
-    list <- remove list, list
-    1:num/raw <- deaddress list
-  ]
-  memory-should-contain [
-    1 <- 0  # back to an empty list
-  ]
-]
-
-# reverse the elements of a list
-# (contributed by Caleb Couch)
-def reverse list:&:list:_elem temp:&:list:_elem/contained-in:result -> result:&:list:_elem [
-  local-scope
-  load-inputs
-  return-unless list, temp
-  object:_elem <- first, list
-  list <- rest list
-  temp <- push object, temp
-  result <- reverse list, temp
-]
-
-scenario reverse-list [
-  local-scope
-  list:&:list:num <- push 1, null
-  list <- push 2, list
-  list <- push 3, list
-  run [
-    stash [list:], list
-    list <- reverse list
-    stash [reversed:], list
-  ]
-  trace-should-contain [
-    app: list: 3 -> 2 -> 1
-    app: reversed: 1 -> 2 -> 3
-  ]
-]
-
-scenario stash-list [
-  local-scope
-  list:&:list:num <- push 1, null
-  list <- push 2, list
-  list <- push 3, list
-  run [
-    stash [list:], list
-  ]
-  trace-should-contain [
-    app: list: 3 -> 2 -> 1
-  ]
-]
-
-def to-text in:&:list:_elem -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  buf <- to-buffer in, buf
-  result <- buffer-to-array buf
-]
-
-# variant of 'to-text' which stops printing after a few elements (and so is robust to cycles)
-def to-text-line in:&:list:_elem -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  buf <- to-buffer in, buf, 6  # max elements to display
-  result <- buffer-to-array buf
-]
-
-def to-buffer in:&:list:_elem, buf:&:buffer:char -> buf:&:buffer:char [
-  local-scope
-  load-inputs
-  {
-    break-if in
-    buf <- append buf, [[]]
-    return
-  }
-  # append in.value to buf
-  val:_elem <- get *in, value:offset
-  buf <- append buf, val
-  # now prepare next
-  next:&:list:_elem <- rest in
-  nextn:num <- deaddress next
-  return-unless next
-  buf <- append buf, [ -> ]
-  # and recurse
-  remaining:num, optional-input-found?:bool <- next-input
-  {
-    break-if optional-input-found?
-    # unlimited recursion
-    buf <- to-buffer next, buf
-    return
-  }
-  {
-    break-unless remaining
-    # limited recursion
-    remaining <- subtract remaining, 1
-    buf <- to-buffer next, buf, remaining
-    return
-  }
-  # past recursion depth; insert ellipses and stop
-  append buf, [...]
-]
-
-scenario stash-empty-list [
-  local-scope
-  x:&:list:num <- copy null
-  run [
-    stash x
-  ]
-  trace-should-contain [
-    app: []
-  ]
-]
diff --git a/archive/2.vm/065duplex_list.mu b/archive/2.vm/065duplex_list.mu
deleted file mode 100644
index 3a7de8f6..00000000
--- a/archive/2.vm/065duplex_list.mu
+++ /dev/null
@@ -1,781 +0,0 @@
-# A doubly linked list permits bidirectional traversal.
-
-container duplex-list:_elem [
-  value:_elem
-  next:&:duplex-list:_elem
-  prev:&:duplex-list:_elem
-]
-
-def push x:_elem, in:&:duplex-list:_elem/contained-in:result -> result:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  result:&:duplex-list:_elem <- new {(duplex-list _elem): type}
-  *result <- merge x, in, null
-  return-unless in
-  put *in, prev:offset, result
-]
-
-def first in:&:duplex-list:_elem -> result:_elem [
-  local-scope
-  load-inputs
-  {
-    break-if in
-    zero:&:_elem <- new _elem:type
-    zero-result:_elem <- copy *zero
-    abandon zero
-    return zero-result
-  }
-  result <- get *in, value:offset
-]
-
-def next in:&:duplex-list:_elem -> result:&:duplex-list:_elem/contained-in:in [
-  local-scope
-  load-inputs
-  return-unless in, null
-  result <- get *in, next:offset
-]
-
-def prev in:&:duplex-list:_elem -> result:&:duplex-list:_elem/contained-in:in [
-  local-scope
-  load-inputs
-  return-unless in, null
-  result <- get *in, prev:offset
-  return result
-]
-
-scenario duplex-list-handling [
-  run [
-    local-scope
-    # reserve locations 0-9 to check for missing null check
-    10:num/raw <- copy 34
-    11:num/raw <- copy 35
-    list:&:duplex-list:num <- push 3, null
-    list <- push 4, list
-    list <- push 5, list
-    list2:&:duplex-list:num <- copy list
-    20:num/raw <- first list2
-    list2 <- next list2
-    21:num/raw <- first list2
-    list2 <- next list2
-    22:num/raw <- first list2
-    30:&:duplex-list:num/raw <- next list2
-    31:num/raw <- first 30:&:duplex-list:num/raw
-    32:&:duplex-list:num/raw <- next 30:&:duplex-list:num/raw
-    33:&:duplex-list:num/raw <- prev 30:&:duplex-list:num/raw
-    list2 <- prev list2
-    40:num/raw <- first list2
-    list2 <- prev list2
-    41:num/raw <- first list2
-    50:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    0 <- 0  # no modifications to null pointers
-    10 <- 34
-    11 <- 35
-    20 <- 5  # scanning next
-    21 <- 4
-    22 <- 3
-    30 <- 0  # null
-    31 <- 0  # first of null
-    32 <- 0  # next of null
-    33 <- 0  # prev of null
-    40 <- 4  # then start scanning prev
-    41 <- 5
-    50 <- 1  # list back at start
-  ]
-]
-
-def length l:&:duplex-list:_elem -> result:num [
-  local-scope
-  load-inputs
-  result <- copy 0
-  {
-    break-unless l
-    result <- add result, 1
-    l <- next l
-    loop
-  }
-]
-
-# insert 'x' after 'in'
-def insert x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  new-node:&:duplex-list:_elem <- new {(duplex-list _elem): type}
-  *new-node <- put *new-node, value:offset, x
-  # save old next before changing it
-  next-node:&:duplex-list:_elem <- get *in, next:offset
-  *in <- put *in, next:offset, new-node
-  *new-node <- put *new-node, prev:offset, in
-  *new-node <- put *new-node, next:offset, next-node
-  return-unless next-node
-  *next-node <- put *next-node, prev:offset, new-node
-]
-
-scenario inserting-into-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:duplex-list:num <- next list  # inside list
-    list2 <- insert 6, list2
-    # check structure like before
-    list2 <- copy list
-    10:num/raw <- first list2
-    list2 <- next list2
-    11:num/raw <- first list2
-    list2 <- next list2
-    12:num/raw <- first list2
-    list2 <- next list2
-    13:num/raw <- first list2
-    list2 <- prev list2
-    20:num/raw <- first list2
-    list2 <- prev list2
-    21:num/raw <- first list2
-    list2 <- prev list2
-    22:num/raw <- first list2
-    30:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 4
-    12 <- 6  # inserted element
-    13 <- 3
-    20 <- 6  # then prev
-    21 <- 4
-    22 <- 5
-    30 <- 1  # list back at start
-  ]
-]
-
-scenario inserting-at-end-of-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:duplex-list:num <- next list  # inside list
-    list2 <- next list2  # now at end of list
-    list2 <- insert 6, list2
-    # check structure like before
-    list2 <- copy list
-    10:num/raw <- first list2
-    list2 <- next list2
-    11:num/raw <- first list2
-    list2 <- next list2
-    12:num/raw <- first list2
-    list2 <- next list2
-    13:num/raw <- first list2
-    list2 <- prev list2
-    20:num/raw <- first list2
-    list2 <- prev list2
-    21:num/raw <- first list2
-    list2 <- prev list2
-    22:num/raw <- first list2
-    30:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 4
-    12 <- 3
-    13 <- 6  # inserted element
-    20 <- 3  # then prev
-    21 <- 4
-    22 <- 5
-    30 <- 1  # list back at start
-  ]
-]
-
-scenario inserting-after-start-of-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list <- insert 6, list
-    # check structure like before
-    list2:&:duplex-list:num <- copy list
-    10:num/raw <- first list2
-    list2 <- next list2
-    11:num/raw <- first list2
-    list2 <- next list2
-    12:num/raw <- first list2
-    list2 <- next list2
-    13:num/raw <- first list2
-    list2 <- prev list2
-    20:num/raw <- first list2
-    list2 <- prev list2
-    21:num/raw <- first list2
-    list2 <- prev list2
-    22:num/raw <- first list2
-    30:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 5  # scanning next
-    11 <- 6  # inserted element
-    12 <- 4
-    13 <- 3
-    20 <- 4  # then prev
-    21 <- 6
-    22 <- 5
-    30 <- 1  # list back at start
-  ]
-]
-
-# remove 'x' from its surrounding list 'in'
-#
-# Returns null if and only if list is empty. Beware: in that case any other
-# pointers to the head are now invalid.
-def remove x:&:duplex-list:_elem/contained-in:in, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  # if 'x' is null, return
-  return-unless x
-  next-node:&:duplex-list:_elem <- get *x, next:offset
-  prev-node:&:duplex-list:_elem <- get *x, prev:offset
-  # null x's pointers
-  *x <- put *x, next:offset, null
-  *x <- put *x, prev:offset, null
-  # if next-node is not null, set its prev pointer
-  {
-    break-unless next-node
-    *next-node <- put *next-node, prev:offset, prev-node
-  }
-  # if prev-node is not null, set its next pointer and return
-  {
-    break-unless prev-node
-    *prev-node <- put *prev-node, next:offset, next-node
-    return
-  }
-  # if prev-node is null, then we removed the head node at 'in'
-  # return the new head rather than the old 'in'
-  return next-node
-]
-
-scenario removing-from-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:duplex-list:num <- next list  # second element
-    list <- remove list2, list
-    10:bool/raw <- equal list2, null
-    # check structure like before
-    list2 <- copy list
-    11:num/raw <- first list2
-    list2 <- next list2
-    12:num/raw <- first list2
-    20:&:duplex-list:num/raw <- next list2
-    list2 <- prev list2
-    30:num/raw <- first list2
-    40:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 0  # remove returned non-null
-    11 <- 5  # scanning next, skipping deleted element
-    12 <- 3
-    20 <- 0  # no more elements
-    30 <- 5  # prev of final element
-    40 <- 1  # list back at start
-  ]
-]
-
-scenario removing-from-start-of-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list <- remove list, list
-    # check structure like before
-    list2:&:duplex-list:num <- copy list
-    10:num/raw <- first list2
-    list2 <- next list2
-    11:num/raw <- first list2
-    20:&:duplex-list:num/raw <- next list2
-    list2 <- prev list2
-    30:num/raw <- first list2
-    40:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 4  # scanning next, skipping deleted element
-    11 <- 3
-    20 <- 0  # no more elements
-    30 <- 4  # prev of final element
-    40 <- 1  # list back at start
-  ]
-]
-
-scenario removing-from-end-of-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    # delete last element
-    list2:&:duplex-list:num <- next list
-    list2 <- next list2
-    list <- remove list2, list
-    10:bool/raw <- equal list2, null
-    # check structure like before
-    list2 <- copy list
-    11:num/raw <- first list2
-    list2 <- next list2
-    12:num/raw <- first list2
-    20:&:duplex-list:num/raw <- next list2
-    list2 <- prev list2
-    30:num/raw <- first list2
-    40:bool/raw <- equal list, list2
-  ]
-  memory-should-contain [
-    10 <- 0  # remove returned non-null
-    11 <- 5  # scanning next, skipping deleted element
-    12 <- 4
-    20 <- 0  # no more elements
-    30 <- 5  # prev of final element
-    40 <- 1  # list back at start
-  ]
-]
-
-scenario removing-from-singleton-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  run [
-    list <- remove list, list
-    1:num/raw <- deaddress list
-  ]
-  memory-should-contain [
-    1 <- 0  # back to an empty list
-  ]
-]
-
-def remove x:&:duplex-list:_elem/contained-in:in, n:num, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  i:num <- copy 0
-  curr:&:duplex-list:_elem <- copy x
-  {
-    done?:bool <- greater-or-equal i, n
-    break-if done?
-    break-unless curr
-    next:&:duplex-list:_elem <- next curr
-    in <- remove curr, in
-    curr <- copy next
-    i <- add i, 1
-    loop
-  }
-]
-
-scenario removing-multiple-from-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 3, null
-  list <- push 4, list
-  list <- push 5, list
-  run [
-    list2:&:duplex-list:num <- next list  # second element
-    list <- remove list2, 2, list
-    stash list
-  ]
-  trace-should-contain [
-    app: 5
-  ]
-]
-
-# remove values between 'start' and 'end' (both exclusive).
-# also clear pointers back out from start/end for hygiene.
-# set end to 0 to delete everything past start.
-# can't set start to 0 to delete everything before end, because there's no
-# clean way to return the new head pointer.
-def remove-between start:&:duplex-list:_elem, end:&:duplex-list:_elem/contained-in:start -> start:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  next:&:duplex-list:_elem <- get *start, next:offset
-  nothing-to-delete?:bool <- equal next, end
-  return-if nothing-to-delete?
-  assert next, [malformed duplex list]
-  # start->next->prev = 0
-  # start->next = end
-  *next <- put *next, prev:offset, null
-  *start <- put *start, next:offset, end
-  {
-    break-if end
-    stash [spliced:] next
-    return
-  }
-  # end->prev->next = 0
-  # end->prev = start
-  prev:&:duplex-list:_elem <- get *end, prev:offset
-  assert prev, [malformed duplex list - 2]
-  *prev <- put *prev, next:offset, null
-  stash [spliced:] next
-  *end <- put *end, prev:offset, start
-]
-
-scenario remove-range [
-  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
-  local-scope
-  list:&:duplex-list:num <- push 18, null
-  list <- push 17, list
-  list <- push 16, list
-  list <- push 15, list
-  list <- push 14, list
-  list <- push 13, list
-  run [
-    # delete 16 onwards
-    # first pointer: to the third element
-    list2:&:duplex-list:num <- next list
-    list2 <- next list2
-    list2 <- remove-between list2, null
-    # now check the list
-    10:num/raw <- get *list, value:offset
-    list <- next list
-    11:num/raw <- get *list, value:offset
-    list <- next list
-    12:num/raw <- get *list, value:offset
-    20:&:duplex-list:num/raw <- next list
-  ]
-  memory-should-contain [
-    10 <- 13
-    11 <- 14
-    12 <- 15
-    20 <- 0
-  ]
-  trace-should-contain [
-    app: spliced: 16 <-> 17 <-> 18
-  ]
-]
-
-scenario remove-range-to-final [
-  local-scope
-  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
-  list:&:duplex-list:num <- push 18, null
-  list <- push 17, list
-  list <- push 16, list
-  list <- push 15, list
-  list <- push 14, list
-  list <- push 13, list
-  run [
-    # delete 15, 16 and 17
-    # start pointer: to the second element
-    list2:&:duplex-list:num <- next list
-    # end pointer: to the last (sixth) element
-    end:&:duplex-list:num <- next list2
-    end <- next end
-    end <- next end
-    end <- next end
-    remove-between list2, end
-    # now check the list
-    10:num/raw <- get *list, value:offset
-    list <- next list
-    11:num/raw <- get *list, value:offset
-    list <- next list
-    12:num/raw <- get *list, value:offset
-    20:&:duplex-list:num/raw <- next list
-  ]
-  memory-should-contain [
-    10 <- 13
-    11 <- 14
-    12 <- 18
-    20 <- 0  # no more elements
-  ]
-  trace-should-contain [
-    app: spliced: 15 <-> 16 <-> 17
-  ]
-]
-
-scenario remove-range-to-penultimate [
-  local-scope
-  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
-  list:&:duplex-list:num <- push 18, null
-  list <- push 17, list
-  list <- push 16, list
-  list <- push 15, list
-  list <- push 14, list
-  list <- push 13, list
-  run [
-    # delete 15 and 16
-    # start pointer: to the second element
-    list2:&:duplex-list:num <- next list
-    # end pointer: to the last (sixth) element
-    end:&:duplex-list:num <- next list2
-    end <- next end
-    end <- next end
-    remove-between list2, end
-    # now check the list
-    10:num/raw <- get *list, value:offset
-    list <- next list
-    11:num/raw <- get *list, value:offset
-    list <- next list
-    12:num/raw <- get *list, value:offset
-    list <- next list
-    13:num/raw <- get *list, value:offset
-    20:&:duplex-list:num/raw <- next list
-  ]
-  memory-should-contain [
-    10 <- 13
-    11 <- 14
-    12 <- 17
-    13 <- 18
-    20 <- 0  # no more elements
-  ]
-  trace-should-contain [
-    app: spliced: 15 <-> 16
-  ]
-]
-
-scenario remove-range-empty [
-  local-scope
-  # construct a duplex list with three elements [13, 14, 15]
-  list:&:duplex-list:num <- push 15, null
-  list <- push 14, list
-  list <- push 13, list
-  run [
-    # delete between first and second element (i.e. nothing)
-    list2:&:duplex-list:num <- next list
-    remove-between list, list2
-    # now check the list
-    10:num/raw <- get *list, value:offset
-    list <- next list
-    11:num/raw <- get *list, value:offset
-    list <- next list
-    12:num/raw <- get *list, value:offset
-    20:&:duplex-list:num/raw <- next list
-  ]
-  # no change
-  memory-should-contain [
-    10 <- 13
-    11 <- 14
-    12 <- 15
-    20 <- 0
-  ]
-]
-
-scenario remove-range-to-end [
-  local-scope
-  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
-  list:&:duplex-list:num <- push 18, null
-  list <- push 17, list
-  list <- push 16, list
-  list <- push 15, list
-  list <- push 14, list
-  list <- push 13, list
-  run [
-    # remove the third element and beyond
-    list2:&:duplex-list:num <- next list
-    remove-between list2, null
-    # now check the list
-    10:num/raw <- get *list, value:offset
-    list <- next list
-    11:num/raw <- get *list, value:offset
-    20:&:duplex-list:num/raw <- next list
-  ]
-  memory-should-contain [
-    10 <- 13
-    11 <- 14
-    20 <- 0
-  ]
-]
-
-# insert list beginning at 'start' after 'in'
-def splice in:&:duplex-list:_elem, start:&:duplex-list:_elem/contained-in:in -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  return-unless in
-  return-unless start
-  end:&:duplex-list:_elem <- last start
-  next:&:duplex-list:_elem <- next in
-  {
-    break-unless next
-    *end <- put *end, next:offset, next
-    *next <- put *next, prev:offset, end
-  }
-  *in <- put *in, next:offset, start
-  *start <- put *start, prev:offset, in
-]
-
-# insert contents of 'new' after 'in'
-def insert in:&:duplex-list:_elem, new:&:@:_elem -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  return-unless in
-  return-unless new
-  len:num <- length *new
-  return-unless len
-  curr:&:duplex-list:_elem <- copy in
-  idx:num <- copy 0
-  {
-    done?:bool <- greater-or-equal idx, len
-    break-if done?
-    c:_elem <- index *new, idx
-    insert c, curr
-    # next iter
-    curr <- next curr
-    idx <- add idx, 1
-    loop
-  }
-]
-
-def append in:&:duplex-list:_elem, new:&:duplex-list:_elem/contained-in:in -> in:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  last:&:duplex-list:_elem <- last in
-  *last <- put *last, next:offset, new
-  return-unless new
-  *new <- put *new, prev:offset, last
-]
-
-def last in:&:duplex-list:_elem -> result:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  result <- copy in
-  {
-    next:&:duplex-list:_elem <- next result
-    break-unless next
-    result <- copy next
-    loop
-  }
-]
-
-# does a duplex list start with a certain sequence of elements?
-def match x:&:duplex-list:_elem, y:&:@:_elem -> result:bool [
-  local-scope
-  load-inputs
-  i:num <- copy 0
-  max:num <- length *y
-  {
-    done?:bool <- greater-or-equal i, max
-    break-if done?
-    expected:_elem <- index *y, i
-    return-unless x, false/no-match
-    curr:_elem <- first x
-    curr-matches?:bool <- equal curr, expected
-    return-unless curr-matches?, false/no-match
-    x <- next x
-    i <- add i, 1
-    loop
-  }
-  return true/successful-match
-]
-
-scenario duplex-list-match [
-  local-scope
-  list:&:duplex-list:char <- push 97/a, null
-  list <- push 98/b, list
-  list <- push 99/c, list
-  list <- push 100/d, list
-  run [
-    10:bool/raw <- match list, []
-    11:bool/raw <- match list, [d]
-    12:bool/raw <- match list, [dc]
-    13:bool/raw <- match list, [dcba]
-    14:bool/raw <- match list, [dd]
-    15:bool/raw <- match list, [dcbax]
-  ]
-  memory-should-contain [
-    10 <- 1  # matches []
-    11 <- 1  # matches [d]
-    12 <- 1  # matches [dc]
-    13 <- 1  # matches [dcba]
-    14 <- 0  # does not match [dd]
-    15 <- 0  # does not match [dcbax]
-  ]
-]
-
-# helper for debugging
-def dump-from x:&:duplex-list:_elem [
-  local-scope
-  load-inputs
-  $print x, [: ]
-  {
-    break-unless x
-    c:_elem <- get *x, value:offset
-    $print c, [ ]
-    x <- next x
-    {
-      is-newline?:bool <- equal c, 10/newline
-      break-unless is-newline?
-      $print 10/newline
-      $print x, [: ]
-    }
-    loop
-  }
-  $print 10/newline, [---], 10/newline
-]
-
-scenario stash-duplex-list [
-  local-scope
-  list:&:duplex-list:num <- push 1, null
-  list <- push 2, list
-  list <- push 3, list
-  run [
-    stash [list:], list
-  ]
-  trace-should-contain [
-    app: list: 3 <-> 2 <-> 1
-  ]
-]
-
-def to-text in:&:duplex-list:_elem -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  buf <- to-buffer in, buf
-  result <- buffer-to-array buf
-]
-
-# variant of 'to-text' which stops printing after a few elements (and so is robust to cycles)
-def to-text-line in:&:duplex-list:_elem -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  buf <- to-buffer in, buf, 6  # max elements to display
-  result <- buffer-to-array buf
-]
-
-def to-buffer in:&:duplex-list:_elem, buf:&:buffer:char -> buf:&:buffer:char [
-  local-scope
-  load-inputs
-  {
-    break-if in
-    buf <- append buf, [[]]
-    return
-  }
-  # append in.value to buf
-  val:_elem <- get *in, value:offset
-  buf <- append buf, val
-  # now prepare next
-  next:&:duplex-list:_elem <- next in
-  nextn:num <- deaddress next
-  return-unless next
-  buf <- append buf, [ <-> ]
-  # and recurse
-  remaining:num, optional-input-found?:bool <- next-input
-  {
-    break-if optional-input-found?
-    # unlimited recursion
-    buf <- to-buffer next, buf
-    return
-  }
-  {
-    break-unless remaining
-    # limited recursion
-    remaining <- subtract remaining, 1
-    buf <- to-buffer next, buf, remaining
-    return
-  }
-  # past recursion depth; insert ellipses and stop
-  append buf, [...]
-]
-
-scenario stash-empty-duplex-list [
-  local-scope
-  x:&:duplex-list:num <- copy null
-  run [
-    stash x
-  ]
-  trace-should-contain [
-    app: []
-  ]
-]
diff --git a/archive/2.vm/066stream.mu b/archive/2.vm/066stream.mu
deleted file mode 100644
index b3202f65..00000000
--- a/archive/2.vm/066stream.mu
+++ /dev/null
@@ -1,80 +0,0 @@
-# new type to help incrementally scan arrays
-container stream:_elem [
-  index:num
-  data:&:@:_elem
-]
-
-def new-stream s:&:@:_elem -> result:&:stream:_elem [
-  local-scope
-  load-inputs
-  return-unless s, null
-  result <- new {(stream _elem): type}
-  *result <- put *result, index:offset, 0
-  *result <- put *result, data:offset, s
-]
-
-def rewind in:&:stream:_elem -> in:&:stream:_elem [
-  local-scope
-  load-inputs
-  return-unless in
-  *in <- put *in, index:offset, 0
-]
-
-def read in:&:stream:_elem -> result:_elem, empty?:bool, in:&:stream:_elem [
-  local-scope
-  load-inputs
-  assert in, [cannot read; stream has no data]
-  empty? <- copy false
-  idx:num <- get *in, index:offset
-  s:&:@:_elem <- get *in, data:offset
-  len:num <- length *s
-  at-end?:bool <- greater-or-equal idx len
-  {
-    break-unless at-end?
-    empty-result:&:_elem <- new _elem:type
-    return *empty-result, true
-  }
-  result <- index *s, idx
-  idx <- add idx, 1
-  *in <- put *in, index:offset, idx
-]
-
-def peek in:&:stream:_elem -> result:_elem, empty?:bool [
-  local-scope
-  load-inputs
-  assert in, [cannot peek; stream has no data]
-  empty?:bool <- copy false
-  idx:num <- get *in, index:offset
-  s:&:@:_elem <- get *in, data:offset
-  len:num <- length *s
-  at-end?:bool <- greater-or-equal idx len
-  {
-    break-unless at-end?
-    empty-result:&:_elem <- new _elem:type
-    return *empty-result, true
-  }
-  result <- index *s, idx
-]
-
-def read-line in:&:stream:char -> result:text, in:&:stream:char [
-  local-scope
-  load-inputs
-  assert in, [cannot read-line; stream has no data]
-  idx:num <- get *in, index:offset
-  s:text <- get *in, data:offset
-  next-idx:num <- find-next s, 10/newline, idx
-  result <- copy-range s, idx, next-idx
-  idx <- add next-idx, 1  # skip newline
-  # write back
-  *in <- put *in, index:offset, idx
-]
-
-def end-of-stream? in:&:stream:_elem -> result:bool [
-  local-scope
-  load-inputs
-  assert in, [cannot check end-of-stream?; stream has no data]
-  idx:num <- get *in, index:offset
-  s:&:@:_elem <- get *in, data:offset
-  len:num <- length *s
-  result <- greater-or-equal idx, len
-]
diff --git a/archive/2.vm/067random.cc b/archive/2.vm/067random.cc
deleted file mode 100644
index d80adb4d..00000000
--- a/archive/2.vm/067random.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-:(before "End Primitive Recipe Declarations")
-REAL_RANDOM,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "real-random", REAL_RANDOM);
-:(before "End Primitive Recipe Checks")
-case REAL_RANDOM: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case REAL_RANDOM: {
-  // todo: limited range of numbers, might be imperfectly random
-  // todo: thread state in extra ingredients and products
-  products.resize(1);
-  products.at(0).push_back(rand());
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MAKE_RANDOM_NONDETERMINISTIC,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "make-random-nondeterministic", MAKE_RANDOM_NONDETERMINISTIC);
-:(before "End Primitive Recipe Checks")
-case MAKE_RANDOM_NONDETERMINISTIC: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MAKE_RANDOM_NONDETERMINISTIC: {
-  srand(time(NULL));
-  break;
-}
-
-// undo non-determinism in later tests
-:(before "End Reset")
-srand(0);
diff --git a/archive/2.vm/068random.mu b/archive/2.vm/068random.mu
deleted file mode 100644
index 3d73356c..00000000
--- a/archive/2.vm/068random.mu
+++ /dev/null
@@ -1,75 +0,0 @@
-def random generator:&:stream:num -> result:num, fail?:bool, generator:&:stream:num [
-  local-scope
-  load-inputs
-  {
-    break-if generator
-    # generator is 0? use real random-number generator
-    result <- real-random
-    return result, false
-  }
-  result, fail?, generator <- read generator
-]
-
-# helper for tests
-def assume-random-numbers -> result:&:stream:num [
-  local-scope
-  load-inputs
-  # compute result-len, space to allocate in result
-  result-len:num <- copy 0
-  {
-    _, arg-received?:bool <- next-input
-    break-unless arg-received?
-    result-len <- add result-len, 1
-    loop
-  }
-  rewind-inputs
-  result-data:&:@:num <- new number:type, result-len
-  idx:num <- copy 0
-  {
-    curr:num, arg-received?:bool <- next-input
-    break-unless arg-received?
-    *result-data <- put-index *result-data, idx, curr
-    idx <- add idx, 1
-    loop
-  }
-  result <- new-stream result-data
-]
-
-scenario random-numbers-in-scenario [
-  local-scope
-  source:&:stream:num <- assume-random-numbers 34, 35, 37
-  1:num/raw, 2:bool/raw <- random source
-  3:num/raw, 4:bool/raw <- random source
-  5:num/raw, 6:bool/raw <- random source
-  7:num/raw, 8:bool/raw <- random source
-  memory-should-contain [
-    1 <- 34
-    2 <- 0  # everything went well
-    3 <- 35
-    4 <- 0  # everything went well
-    5 <- 37
-    6 <- 0  # everything went well
-    7 <- 0  # empty result
-    8 <- 1  # end of stream
-  ]
-]
-
-# generate a random integer in the semi-open interval [start, end)
-def random-in-range generator:&:stream:num, start:num, end:num -> result:num, fail?:bool, generator:&:stream:num [
-  local-scope
-  load-inputs
-  result, fail?, generator <- random generator
-  return-if fail?
-  delta:num <- subtract end, start
-  _, result <- divide-with-remainder result, delta
-  result <- add result, start
-]
-
-scenario random-in-range [
-  local-scope
-  source:&:stream:num <- assume-random-numbers 91
-  1:num/raw <- random-in-range source, 40, 50
-  memory-should-contain [
-    1 <- 41
-  ]
-]
diff --git a/archive/2.vm/069hash.cc b/archive/2.vm/069hash.cc
deleted file mode 100644
index 67897d00..00000000
--- a/archive/2.vm/069hash.cc
+++ /dev/null
@@ -1,422 +0,0 @@
-// Compute a hash for objects of any type.
-//
-// The way it's currently implemented, two objects will have the same hash if
-// all their non-address fields (all the way down) expand to the same sequence
-// of scalar values. In particular, a container with all zero addresses hashes
-// to 0. Hopefully this won't be an issue because we are usually hashing
-// objects of a single type in any given hash table.
-//
-// Based on http://burtleburtle.net/bob/hash/hashfaq.html
-
-:(before "End Primitive Recipe Declarations")
-HASH,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "hash", HASH);
-:(before "End Primitive Recipe Checks")
-case HASH: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'hash' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case HASH: {
-  const reagent& input = current_instruction().ingredients.at(0);
-  products.resize(1);
-  products.at(0).push_back(hash(0, input));
-  break;
-}
-
-//: in all the code below, the intermediate results of hashing are threaded through 'h'
-
-:(code)
-size_t hash(size_t h, reagent/*copy*/ r) {
-  canonize(r);
-  if (is_mu_text(r))  // optimization
-    return hash_mu_text(h, r);
-  else if (is_mu_address(r))
-    return hash_mu_address(h, r);
-  else if (is_mu_scalar(r))
-    return hash_mu_scalar(h, r);
-  else if (is_mu_array(r))
-    return hash_mu_array(h, r);
-  else if (is_mu_container(r))
-    return hash_mu_container(h, r);
-  else if (is_mu_exclusive_container(r))
-    return hash_mu_exclusive_container(h, r);
-  assert(false);
-}
-
-size_t hash_mu_scalar(size_t h, const reagent& r) {
-  double input = is_literal(r) ? r.value : get_or_insert(Memory, r.value);
-  return hash_iter(h, static_cast<size_t>(input));
-}
-
-size_t hash_mu_address(size_t h, reagent& r) {
-  if (r.value == 0) return 0;
-  trace(Callstack_depth+1, "mem") << "location " << r.value << " is " << no_scientific(get_or_insert(Memory, r.value)) << end();
-  r.set_value(get_or_insert(Memory, r.value));
-  drop_from_type(r, "address");
-  return hash(h, r);
-}
-
-size_t hash_mu_text(size_t h, const reagent& r) {
-  string input = read_mu_text(get_or_insert(Memory, r.value+/*skip alloc id*/1));
-  for (int i = 0;  i < SIZE(input);  ++i) {
-    h = hash_iter(h, static_cast<size_t>(input.at(i)));
-//?     cerr << i << ": " << h << '\n';
-  }
-  return h;
-}
-
-size_t hash_mu_array(size_t h, const reagent& r) {
-  int size = get_or_insert(Memory, r.value);
-  reagent/*copy*/ elem = r;
-  delete elem.type;
-  elem.type = copy_array_element(r.type);
-  for (int i=0, address = r.value+1;  i < size;  ++i, address += size_of(elem)) {
-    reagent/*copy*/ tmp = elem;
-    tmp.set_value(address);
-    h = hash(h, tmp);
-//?     cerr << i << " (" << address << "): " << h << '\n';
-  }
-  return h;
-}
-
-size_t hash_mu_container(size_t h, const reagent& r) {
-  type_info& info = get(Type, get_base_type(r.type)->value);
-  int address = r.value;
-  int offset = 0;
-  for (int i = 0;  i < SIZE(info.elements);  ++i) {
-    reagent/*copy*/ element = element_type(r.type, i);
-    if (has_property(element, "ignore-for-hash")) continue;
-    element.set_value(address+offset);
-    h = hash(h, element);
-//?     cerr << i << ": " << h << '\n';
-    offset += size_of(info.elements.at(i).type);
-  }
-  return h;
-}
-
-size_t hash_mu_exclusive_container(size_t h, const reagent& r) {
-  const type_tree* type = get_base_type(r.type);
-  assert(type->value);
-  int tag = get(Memory, r.value);
-  reagent/*copy*/ variant = variant_type(r, tag);
-  // todo: move this error to container definition time
-  if (has_property(variant, "ignore-for-hash"))
-    raise << get(Type, type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end();
-  variant.set_value(r.value + /*skip tag*/1);
-  h = hash(h, variant);
-  return h;
-}
-
-size_t hash_iter(size_t h, size_t input) {
-  h += input;
-  h += (h<<10);
-  h ^= (h>>6);
-
-  h += (h<<3);
-  h ^= (h>>11);
-  h += (h<<15);
-  return h;
-}
-
-void test_hash_container_checks_all_elements() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:char\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 34, 97/a\n"
-      "  3:num <- hash 1:foo\n"
-      "  return-unless 3:num\n"
-      "  4:foo <- merge 34, 98/a\n"
-      "  6:num <- hash 4:foo\n"
-      "  return-unless 6:num\n"
-      "  7:bool <- equal 3:num, 6:num\n"
-      "]\n"
-  );
-  // hash on containers includes all elements
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 7\n"
-  );
-}
-
-void test_hash_exclusive_container_checks_all_elements() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:bar\n"
-      "  y:num\n"
-      "]\n"
-      "container bar [\n"
-      "  a:num\n"
-      "  b:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 0/x, 34, 35\n"
-      "  4:num <- hash 1:foo\n"
-      "  return-unless 4:num\n"
-      "  5:foo <- merge 0/x, 34, 36\n"
-      "  8:num <- hash 5:foo\n"
-      "  return-unless 8:num\n"
-      "  9:bool <- equal 4:num, 8:num\n"
-      "]\n"
-  );
-  // hash on containers includes all elements
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 9\n"
-  );
-}
-
-void test_hash_can_ignore_container_elements() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:char/ignore-for-hash\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 34, 97/a\n"
-      "  3:num <- hash 1:foo\n"
-      "  return-unless 3:num\n"
-      "  4:foo <- merge 34, 98/a\n"
-      "  6:num <- hash 4:foo\n"
-      "  return-unless 6:num\n"
-      "  7:bool <- equal 3:num, 6:num\n"
-      "]\n"
-  );
-  // hashes match even though y is different
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 7\n"
-  );
-}
-
-//: These properties aren't necessary for hash, they just test that the
-//: current implementation works like we think it does.
-
-void test_hash_of_zero_address() {
-  run(
-      "def main [\n"
-      "  1:&:num <- copy null\n"
-      "  2:num <- hash 1:&:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 2\n"
-  );
-}
-
-//: This is probably too aggressive, but we need some way to avoid depending
-//: on the precise bit pattern of a floating-point number.
-void test_hash_of_numbers_ignores_fractional_part() {
-  run(
-      "def main [\n"
-      "  1:num <- hash 1.5\n"
-      "  2:num <- hash 1\n"
-      "  3:bool <- equal 1:num, 2:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 3\n"
-  );
-}
-
-void test_hash_of_array_same_as_string() {
-  run(
-      "def main [\n"
-      "  10:num <- copy 3\n"
-      "  11:num <- copy 97\n"
-      "  12:num <- copy 98\n"
-      "  13:num <- copy 99\n"
-      "  2:num <- hash 10:@:num/unsafe\n"
-      "  return-unless 2:num\n"
-      "  3:text <- new [abc]\n"
-      "  4:num <- hash 3:text\n"
-      "  return-unless 4:num\n"
-      "  5:bool <- equal 2:num, 4:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 5\n"
-  );
-}
-
-void test_hash_ignores_address_value() {
-  run(
-      "def main [\n"
-      "  1:&:num <- new number:type\n"
-      "  *1:&:num <- copy 34\n"
-      "  2:num <- hash 1:&:num\n"
-      "  3:&:num <- new number:type\n"
-      "  *3:&:num <- copy 34\n"
-      "  4:num <- hash 3:&:num\n"
-      "  5:bool <- equal 2:num, 4:num\n"
-      "]\n"
-  );
-  // different addresses hash to the same result as long as the values the point to do so
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 5\n"
-  );
-}
-
-void test_hash_container_depends_only_on_elements() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:char\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:char\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 34, 97/a\n"
-      "  3:num <- hash 1:foo\n"
-      "  return-unless 3:num\n"
-      "  4:bar <- merge 34, 97/a\n"
-      "  6:num <- hash 4:bar\n"
-      "  return-unless 6:num\n"
-      "  7:bool <- equal 3:num, 6:num\n"
-      "]\n"
-  );
-  // containers with identical elements return identical hashes
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 7\n"
-  );
-}
-
-void test_hash_container_depends_only_on_elements_2() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:char\n"
-      "  z:&:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:&:num <- new number:type\n"
-      "  *1:&:num <- copy 34\n"
-      "  2:foo <- merge 34, 97/a, 1:&:num\n"
-      "  5:num <- hash 2:foo\n"
-      "  return-unless 5:num\n"
-      "  6:&:num <- new number:type\n"
-      "  *6:&:num <- copy 34\n"
-      "  7:foo <- merge 34, 97/a, 6:&:num\n"
-      "  10:num <- hash 7:foo\n"
-      "  return-unless 10:num\n"
-      "  11:bool <- equal 5:num, 10:num\n"
-      "]\n"
-  );
-  // containers with identical 'leaf' elements return identical hashes
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 11\n"
-  );
-}
-
-void test_hash_container_depends_only_on_elements_3() {
-  run(
-      "container foo [\n"
-      "  x:num\n"
-      "  y:char\n"
-      "  z:bar\n"
-      "]\n"
-      "container bar [\n"
-      "  x:num\n"
-      "  y:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 34, 97/a, 47, 48\n"
-      "  6:num <- hash 1:foo\n"
-      "  return-unless 6:num\n"
-      "  7:foo <- merge 34, 97/a, 47, 48\n"
-      "  12:num <- hash 7:foo\n"
-      "  return-unless 12:num\n"
-      "  13:bool <- equal 6:num, 12:num\n"
-      "]\n"
-  );
-  // containers with identical 'leaf' elements return identical hashes
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 13\n"
-  );
-}
-
-void test_hash_exclusive_container_ignores_tag() {
-  run(
-      "exclusive-container foo [\n"
-      "  x:bar\n"
-      "  y:num\n"
-      "]\n"
-      "container bar [\n"
-      "  a:num\n"
-      "  b:num\n"
-      "]\n"
-      "def main [\n"
-      "  1:foo <- merge 0/x, 34, 35\n"
-      "  4:num <- hash 1:foo\n"
-      "  return-unless 4:num\n"
-      "  5:bar <- merge 34, 35\n"
-      "  7:num <- hash 5:bar\n"
-      "  return-unless 7:num\n"
-      "  8:bool <- equal 4:num, 7:num\n"
-      "]\n"
-  );
-  // hash on containers includes all elements
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 8\n"
-  );
-}
-
-//: An older version that supported only strings.
-//: Hash functions are subtle and easy to get wrong, so we keep the old
-//: version around and check that the new one is consistent with it.
-
-void test_hash_matches_old_version() {
-  run(
-      "def main [\n"
-      "  1:text <- new [abc]\n"
-      "  3:num <- hash 1:text\n"
-      "  4:num <- hash_old 1:text\n"
-      "  5:bool <- equal 3:num, 4:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 5\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-HASH_OLD,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "hash_old", HASH_OLD);
-:(before "End Primitive Recipe Checks")
-case HASH_OLD: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'hash_old' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports texts (address array character), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case HASH_OLD: {
-  string input = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
-  size_t h = 0 ;
-
-  for (int i = 0;  i < SIZE(input);  ++i) {
-    h += static_cast<size_t>(input.at(i));
-    h += (h<<10);
-    h ^= (h>>6);
-
-    h += (h<<3);
-    h ^= (h>>11);
-    h += (h<<15);
-  }
-
-  products.resize(1);
-  products.at(0).push_back(h);
-  break;
-}
diff --git a/archive/2.vm/070table.mu b/archive/2.vm/070table.mu
deleted file mode 100644
index 21184084..00000000
--- a/archive/2.vm/070table.mu
+++ /dev/null
@@ -1,109 +0,0 @@
-# A table is like an array, except that you can index it with arbitrary types
-# and not just non-negative whole numbers.
-
-# incomplete; doesn't handle hash conflicts
-
-scenario table-read-write [
-  local-scope
-  tab:&:table:num:num <- new-table 30
-  run [
-    put-index tab, 12, 34
-    60:num/raw, 61:bool/raw <- index tab, 12
-  ]
-  memory-should-contain [
-    60 <- 34
-    61 <- 1  # found
-  ]
-]
-
-scenario table-read-write-non-integer [
-  local-scope
-  tab:&:table:text:num <- new-table 30
-  run [
-    put-index tab, [abc def], 34
-    1:num/raw, 2:bool/raw <- index tab, [abc def]
-  ]
-  memory-should-contain [
-    1 <- 34
-    2 <- 1  # found
-  ]
-]
-
-scenario table-read-not-found [
-  local-scope
-  tab:&:table:text:num <- new-table 30
-  run [
-    1:num/raw, 2:bool/raw <- index tab, [abc def]
-  ]
-  memory-should-contain [
-    1 <- 0
-    2 <- 0  # not found
-  ]
-]
-
-container table:_key:_value [
-  length:num
-  capacity:num
-  data:&:@:table-row:_key:_value
-]
-
-container table-row:_key:_value [
-  occupied?:bool
-  key:_key
-  value:_value
-]
-
-def new-table capacity:num -> result:&:table:_key:_value [
-  local-scope
-  load-inputs
-  result <- new {(table _key _value): type}
-  data:&:@:table-row:_key:_value <- new {(table-row _key _value): type}, capacity
-  *result <- merge 0/length, capacity, data
-]
-
-# todo: tag results as /required so that call-sites are forbidden from ignoring them
-# then we could handle conflicts simply by resizing the table
-def put-index table:&:table:_key:_value, key:_key, value:_value -> table:&:table:_key:_value [
-  local-scope
-  load-inputs
-  hash:num <- hash key
-  hash <- abs hash
-  capacity:num <- get *table, capacity:offset
-  _, hash-key:num <- divide-with-remainder hash, capacity
-  hash-key <- abs hash-key  # in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above
-  table-data:&:@:table-row:_key:_value <- get *table, data:offset
-  x:table-row:_key:_value <- index *table-data, hash-key
-  occupied?:bool <- get x, occupied?:offset
-  not-occupied?:bool <- not occupied?:bool
-  assert not-occupied?, [can't handle collisions yet]
-  new-row:table-row:_key:_value <- merge true, key, value
-  *table-data <- put-index *table-data, hash-key, new-row
-]
-
-def index table:&:table:_key:_value, key:_key -> result:_value, found?:bool [
-  local-scope
-  load-inputs
-  hash:num <- hash key
-  hash <- abs hash
-  capacity:num <- get *table, capacity:offset
-  _, hash-key:num <- divide-with-remainder hash, capacity
-  hash-key <- abs hash-key  # in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above
-  table-data:&:@:table-row:_key:_value <- get *table, data:offset
-  x:table-row:_key:_value <- index *table-data, hash-key
-  empty:&:_value <- new _value:type
-  result <- copy *empty
-  found?:bool <- get x, occupied?:offset
-  return-unless found?
-  key2:_key <- get x, key:offset
-  found?:bool <- equal key, key2
-  return-unless found?
-  result <- get x, value:offset
-]
-
-def abs n:num -> result:num [
-  local-scope
-  load-inputs
-  positive?:bool <- greater-or-equal n, 0
-  return-if positive?, n
-  result <- multiply n, -1
-]
diff --git a/archive/2.vm/072recipe.cc b/archive/2.vm/072recipe.cc
deleted file mode 100644
index a3bb00bf..00000000
--- a/archive/2.vm/072recipe.cc
+++ /dev/null
@@ -1,711 +0,0 @@
-//: So far we've been calling a fixed recipe in each instruction, but we'd
-//: also like to make the recipe a variable, pass recipes to "higher-order"
-//: recipes, return recipes from recipes and so on.
-
-void test_call_literal_recipe() {
-  run(
-      "def main [\n"
-      "  1:num <- call f, 34\n"
-      "]\n"
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(before "End Mu Types Initialization")
-put(Type_ordinal, "recipe-literal", 0);
-// 'recipe' variables can store recipe-literal
-type_ordinal recipe = put(Type_ordinal, "recipe", Next_type_ordinal++);
-get_or_insert(Type, recipe).name = "recipe";
-
-:(after "Deduce Missing Type(x, caller)")
-if (!x.type)
-  try_initialize_recipe_literal(x, caller);
-:(before "Type Check in Type-ingredient-aware check_or_set_types_by_name")
-if (!x.type)
-  try_initialize_recipe_literal(x, variant);
-:(code)
-void try_initialize_recipe_literal(reagent& x, const recipe& caller) {
-  if (x.type) return;
-  if (!contains_key(Recipe_ordinal, x.name)) return;
-  if (contains_reagent_with_non_recipe_literal_type(caller, x.name)) return;
-  x.type = new type_tree("recipe-literal");
-  x.set_value(get(Recipe_ordinal, x.name));
-}
-bool contains_reagent_with_non_recipe_literal_type(const recipe& caller, const string& name) {
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    for (int i = 0;  i < SIZE(inst.ingredients);  ++i)
-      if (is_matching_non_recipe_literal(inst.ingredients.at(i), name)) return true;
-    for (int i = 0;  i < SIZE(inst.products);  ++i)
-      if (is_matching_non_recipe_literal(inst.products.at(i), name)) return true;
-  }
-  return false;
-}
-bool is_matching_non_recipe_literal(const reagent& x, const string& name) {
-  if (x.name != name) return false;
-  if (!x.type) return false;
-  return !x.type->atom || x.type->name != "recipe-literal";
-}
-
-//: It's confusing to use variable names that are also recipe names. Always
-//: assume variable types override recipe literals.
-void test_error_on_recipe_literal_used_as_a_variable() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  a:bool <- equal break 0\n"
-      "  break:bool <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'break' in 'a:bool <- equal break, 0'\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-CALL,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "call", CALL);
-:(before "End Primitive Recipe Checks")
-case CALL: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'call' requires at least one ingredient (the recipe to call)\n" << end();
-    break;
-  }
-  if (!is_mu_recipe(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'call' should be a recipe, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CALL: {
-  // Begin Call
-  trace(Callstack_depth+1, "trace") << "indirect 'call': incrementing callstack depth to " << Callstack_depth << end();
-  ++Callstack_depth;
-  assert(Callstack_depth < Max_depth);
-  if (!ingredients.at(0).at(0)) {
-    raise << maybe(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end();
-    break;
-  }
-  const call& caller_frame = current_call();
-  instruction/*copy*/ call_instruction = to_instruction(caller_frame);
-  call_instruction.operation = ingredients.at(0).at(0);
-  call_instruction.ingredients.erase(call_instruction.ingredients.begin());
-  Current_routine->calls.push_front(call(ingredients.at(0).at(0)));
-  ingredients.erase(ingredients.begin());  // drop the callee
-  finish_call_housekeeping(call_instruction, ingredients);
-  // not done with caller
-  write_products = false;
-  fall_through_to_next_instruction = false;
-  break;
-}
-
-:(code)
-void test_call_variable() {
-  run(
-      "def main [\n"
-      "  {1: (recipe number -> number)} <- copy f\n"
-      "  2:num <- call {1: (recipe number -> number)}, 34\n"
-      "]\n"
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 2\n"
-  );
-}
-
-void test_call_literal_recipe_repeatedly() {
-  run(
-      "def main [\n"
-      "  1:num <- call f, 34\n"
-      "  1:num <- call f, 35\n"
-      "]\n"
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      "mem: storing 35 in location 1\n"
-  );
-}
-
-void test_call_shape_shifting_recipe() {
-  run(
-      "def main [\n"
-      "  1:num <- call f, 34\n"
-      "]\n"
-      "def f x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_call_shape_shifting_recipe_inside_shape_shifting_recipe() {
-  run(
-      "def main [\n"
-      "  1:num <- f 34\n"
-      "]\n"
-      "def f x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- call g x\n"
-      "]\n"
-      "def g x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_call_shape_shifting_recipe_repeatedly_inside_shape_shifting_recipe() {
-  run(
-      "def main [\n"
-      "  1:num <- f 34\n"
-      "]\n"
-      "def f x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- call g x\n"
-      "  y <- call g x\n"
-      "]\n"
-      "def g x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-//:: check types for 'call' instructions
-
-void test_call_check_literal_recipe() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  1:num <- call f, 34\n"
-      "]\n"
-      "def f x:point -> y:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: ingredient 0 has the wrong type at '1:num <- call f, 34'\n"
-      "error: main: product 0 has the wrong type at '1:num <- call f, 34'\n"
-  );
-}
-
-void test_call_check_variable_recipe() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  {1: (recipe point -> point)} <- copy f\n"
-      "  2:num <- call {1: (recipe point -> point)}, 34\n"
-      "]\n"
-      "def f x:point -> y:point [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: ingredient 0 has the wrong type at '2:num <- call {1: (recipe point -> point)}, 34'\n"
-      "error: main: product 0 has the wrong type at '2:num <- call {1: (recipe point -> point)}, 34'\n"
-  );
-}
-
-:(before "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
-if (inst.name == "call" && !inst.ingredients.empty() && is_recipe_literal(inst.ingredients.at(0))) {
-  resolve_indirect_ambiguous_call(r, index, inst, caller_recipe);
-  return;
-}
-:(code)
-bool is_recipe_literal(const reagent& x) {
-  return x.type && x.type->atom && x.type->name == "recipe-literal";
-}
-void resolve_indirect_ambiguous_call(const recipe_ordinal r, int index, instruction& inst, const recipe& caller_recipe) {
-  instruction inst2;
-  inst2.name = inst.ingredients.at(0).name;
-  for (int i = /*skip recipe*/1;  i < SIZE(inst.ingredients);  ++i)
-    inst2.ingredients.push_back(inst.ingredients.at(i));
-  for (int i = 0;  i < SIZE(inst.products);  ++i)
-    inst2.products.push_back(inst.products.at(i));
-  resolve_ambiguous_call(r, index, inst2, caller_recipe);
-  inst.ingredients.at(0).name = inst2.name;
-  inst.ingredients.at(0).set_value(get(Recipe_ordinal, inst2.name));
-}
-
-:(after "Transform.push_back(check_instruction)")
-Transform.push_back(check_indirect_calls_against_header);  // idempotent
-:(code)
-void check_indirect_calls_against_header(const recipe_ordinal r) {
-  trace(101, "transform") << "--- type-check 'call' instructions inside recipe " << get(Recipe, r).name << end();
-  const recipe& caller = get(Recipe, r);
-  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
-    const instruction& inst = caller.steps.at(i);
-    if (!is_indirect_call(inst.operation)) continue;
-    if (inst.ingredients.empty()) continue;  // error raised above
-    const reagent& callee = inst.ingredients.at(0);
-    if (!is_mu_recipe(callee)) continue;  // error raised above
-    const recipe callee_header = is_literal(callee) ? get(Recipe, callee.value) : from_reagent(inst.ingredients.at(0));
-    if (!callee_header.has_header) continue;
-    if (is_indirect_call_with_ingredients(inst.operation)) {
-      for (long int i = /*skip callee*/1;  i < min(SIZE(inst.ingredients), SIZE(callee_header.ingredients)+/*skip callee*/1);  ++i) {
-        if (!types_coercible(callee_header.ingredients.at(i-/*skip callee*/1), inst.ingredients.at(i)))
-          raise << maybe(caller.name) << "ingredient " << i-/*skip callee*/1 << " has the wrong type at '" << to_original_string(inst) << "'\n" << end();
-      }
-    }
-    if (is_indirect_call_with_products(inst.operation)) {
-      for (long int i = 0;  i < min(SIZE(inst.products), SIZE(callee_header.products));  ++i) {
-        if (is_dummy(inst.products.at(i))) continue;
-        if (!types_coercible(callee_header.products.at(i), inst.products.at(i)))
-          raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << to_original_string(inst) << "'\n" << end();
-      }
-    }
-  }
-}
-
-bool is_indirect_call(const recipe_ordinal r) {
-  return is_indirect_call_with_ingredients(r) || is_indirect_call_with_products(r);
-}
-
-bool is_indirect_call_with_ingredients(const recipe_ordinal r) {
-  if (r == CALL) return true;
-  // End is_indirect_call_with_ingredients Special-cases
-  return false;
-}
-bool is_indirect_call_with_products(const recipe_ordinal r) {
-  if (r == CALL) return true;
-  // End is_indirect_call_with_products Special-cases
-  return false;
-}
-
-recipe from_reagent(const reagent& r) {
-  assert(r.type);
-  recipe result_header;  // will contain only ingredients and products, nothing else
-  result_header.has_header = true;
-  // Begin Reagent->Recipe(r, recipe_header)
-  if (r.type->atom) {
-    assert(r.type->name == "recipe");
-    return result_header;
-  }
-  const type_tree* root_type = r.type->atom ? r.type : r.type->left;
-  assert(root_type->atom);
-  assert(root_type->name == "recipe");
-  const type_tree* curr = r.type->right;
-  for (/*nada*/;  curr && !curr->atom;  curr = curr->right) {
-    if (curr->left->atom && curr->left->name == "->") {
-      curr = curr->right;  // skip delimiter
-      goto read_products;
-    }
-    result_header.ingredients.push_back(next_recipe_reagent(curr->left));
-  }
-  if (curr) {
-    assert(curr->atom);
-    result_header.ingredients.push_back(next_recipe_reagent(curr));
-    return result_header;  // no products
-  }
-  read_products:
-  for (/*nada*/;  curr && !curr->atom;  curr = curr->right)
-    result_header.products.push_back(next_recipe_reagent(curr->left));
-  if (curr) {
-    assert(curr->atom);
-    result_header.products.push_back(next_recipe_reagent(curr));
-  }
-  return result_header;
-}
-
-:(before "End Unit Tests")
-void test_from_reagent_atomic() {
-  reagent a("{f: recipe}");
-  recipe r_header = from_reagent(a);
-  CHECK(r_header.ingredients.empty());
-  CHECK(r_header.products.empty());
-}
-void test_from_reagent_non_atomic() {
-  reagent a("{f: (recipe number -> number)}");
-  recipe r_header = from_reagent(a);
-  CHECK_EQ(SIZE(r_header.ingredients), 1);
-  CHECK_EQ(SIZE(r_header.products), 1);
-}
-void test_from_reagent_reads_ingredient_at_end() {
-  reagent a("{f: (recipe number number)}");
-  recipe r_header = from_reagent(a);
-  CHECK_EQ(SIZE(r_header.ingredients), 2);
-  CHECK(r_header.products.empty());
-}
-void test_from_reagent_reads_sole_ingredient_at_end() {
-  reagent a("{f: (recipe number)}");
-  recipe r_header = from_reagent(a);
-  CHECK_EQ(SIZE(r_header.ingredients), 1);
-  CHECK(r_header.products.empty());
-}
-
-:(code)
-reagent next_recipe_reagent(const type_tree* curr) {
-  if (!curr->left) return reagent("recipe:"+curr->name);
-  return reagent(new type_tree(*curr));
-}
-
-bool is_mu_recipe(const reagent& r) {
-  if (!r.type) return false;
-  if (r.type->atom) {
-    // End is_mu_recipe Atom Cases(r)
-    return r.type->name == "recipe-literal";
-  }
-  return r.type->left->atom && r.type->left->name == "recipe";
-}
-
-void test_copy_typecheck_recipe_variable() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  3:num <- copy 34\n"
-      "  {1: (recipe number -> number)} <- copy f\n"  // store literal in a matching variable
-      "  {2: (recipe boolean -> boolean)} <- copy {1: (recipe number -> number)}\n"  // mismatch between recipe variables
-      "]\n"
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy '{1: (recipe number -> number)}' to '{2: (recipe boolean -> boolean)}'; types don't match\n"
-  );
-}
-
-void test_copy_typecheck_recipe_variable_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  {1: (recipe number -> number)} <- copy f\n"  // mismatch with a recipe literal
-      "]\n"
-      "def f x:bool -> y:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: can't copy 'f' to '{1: (recipe number -> number)}'; types don't match\n"
-  );
-}
-
-:(before "End Matching Types For Literal(to)")
-if (is_mu_recipe(to)) {
-  if (!contains_key(Recipe, from.value)) {
-    raise << "trying to store recipe " << from.name << " into " << to_string(to) << " but there's no such recipe\n" << end();
-    return false;
-  }
-  const recipe& rrhs = get(Recipe, from.value);
-  const recipe& rlhs = from_reagent(to);
-  for (long int i = 0;  i < min(SIZE(rlhs.ingredients), SIZE(rrhs.ingredients));  ++i) {
-    if (!types_match(rlhs.ingredients.at(i), rrhs.ingredients.at(i)))
-      return false;
-  }
-  for (long int i = 0;  i < min(SIZE(rlhs.products), SIZE(rrhs.products));  ++i) {
-    if (!types_match(rlhs.products.at(i), rrhs.products.at(i)))
-      return false;
-  }
-  return true;
-}
-
-:(code)
-void test_call_variable_compound_ingredient() {
-  run(
-      "def main [\n"
-      "  {1: (recipe (address number) -> number)} <- copy f\n"
-      "  2:&:num <- copy null\n"
-      "  3:num <- call {1: (recipe (address number) -> number)}, 2:&:num\n"
-      "]\n"
-      "def f x:&:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- deaddress x\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: make sure we don't accidentally break on a recipe literal
-void test_jump_forbidden_on_recipe_literals() {
-  Hide_errors = true;
-  run(
-      "def foo [\n"
-      "  local-scope\n"
-      "]\n"
-      "def main [\n"
-      "  local-scope\n"
-      "  {\n"
-      "    break-if foo\n"
-      "  }\n"
-      "]\n"
-  );
-  // error should be as if foo is not a recipe
-  CHECK_TRACE_CONTENTS(
-      "error: main: missing type for 'foo' in 'break-if foo'\n"
-  );
-}
-
-:(before "End JUMP_IF Checks")
-check_for_recipe_literals(inst, get(Recipe, r));
-:(before "End JUMP_UNLESS Checks")
-check_for_recipe_literals(inst, get(Recipe, r));
-:(code)
-void check_for_recipe_literals(const instruction& inst, const recipe& caller) {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (is_mu_recipe(inst.ingredients.at(i))) {
-      raise << maybe(caller.name) << "missing type for '" << inst.ingredients.at(i).original_string << "' in '" << to_original_string(inst) << "'\n" << end();
-      if (is_present_in_ingredients(caller, inst.ingredients.at(i).name))
-        raise << "  did you forget 'load-ingredients'?\n" << end();
-    }
-  }
-}
-
-void test_load_ingredients_missing_error_3() {
-  Hide_errors = true;
-  run(
-      "def foo {f: (recipe num -> num)} [\n"
-      "  local-scope\n"
-      "  b:num <- call f, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: missing type for 'f' in 'b:num <- call f, 1'\n"
-      "error:   did you forget 'load-ingredients'?\n"
-  );
-}
-
-:(before "End Mu Types Initialization")
-put(Type_abbreviations, "function", new_type_tree("recipe"));
-put(Type_abbreviations, "fn", new_type_tree("recipe"));
-
-//: copying functions to variables
-
-:(code)
-void test_copy_recipe_to_variable() {
-  run(
-      "def main [\n"
-      "  {1: (fn number -> number)} <- copy f\n"
-      "  2:num <- call {1: (function number -> number)}, 34\n"
-      "]\n"
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 2\n"
-  );
-}
-
-void test_copy_overloaded_recipe_to_variable() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  {x: (fn num -> num)} <- copy f\n"
-      "  1:num/raw <- call x, 34\n"
-      "]\n"
-      // variant f
-      "def f x:bool -> y:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-      // variant f_2
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  // x contains f_2
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(before "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
-if (inst.name == "copy") {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_recipe_literal(inst.ingredients.at(i))) continue;
-    if (non_ghost_size(get_or_insert(Recipe_variants, inst.ingredients.at(i).name)) < 1) continue;
-    // potentially overloaded recipe
-    string new_name = resolve_ambiguous_call(inst.ingredients.at(i).name, inst.products.at(i), r, index, caller_recipe);
-    if (new_name == "") continue;
-    inst.ingredients.at(i).name = new_name;
-    inst.ingredients.at(i).value = get(Recipe_ordinal, new_name);
-  }
-  return;
-}
-:(code)
-string resolve_ambiguous_call(const string& recipe_name, const reagent& call_types, const recipe_ordinal r, int index, const recipe& caller_recipe) {
-  instruction inst;
-  inst.name = recipe_name;
-  if (!is_mu_recipe(call_types)) return "";  // error raised elsewhere
-  if (is_recipe_literal(call_types)) return "";  // error raised elsewhere
-  construct_fake_call(call_types, inst);
-  resolve_ambiguous_call(r, index, inst, caller_recipe);
-  return inst.name;
-}
-void construct_fake_call(const reagent& recipe_var, instruction& out) {
-  assert(recipe_var.type->left->name == "recipe");
-  type_tree* stem = NULL;
-  for (stem = recipe_var.type->right;  stem && stem->left->name != "->";  stem = stem->right)
-    out.ingredients.push_back(copy(stem->left));
-  if (stem == NULL) return;
-  for (/*skip '->'*/stem = stem->right;  stem;  stem = stem->right)
-    out.products.push_back(copy(stem->left));
-}
-
-void test_copy_shape_shifting_recipe_to_variable() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  {x: (fn num -> num)} <- copy f\n"
-      "  1:num/raw <- call x, 34\n"
-      "]\n"
-      "def f x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-inputs\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-//: passing function literals to (higher-order) functions
-
-void test_pass_overloaded_recipe_literal_to_ingredient() {
-  run(
-      // like test_copy_overloaded_recipe_to_variable, except we bind 'x' in
-      // the course of a 'call' rather than 'copy'
-      "def main [\n"
-      "  1:num <- g f\n"
-      "]\n"
-      "def g {x: (fn num -> num)} -> result:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  result <- call x, 34\n"
-      "]\n"
-      // variant f
-      "def f x:bool -> y:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-      // variant f_2
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  // x contains f_2
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(after "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
-for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-  if (!is_mu_recipe(inst.ingredients.at(i))) continue;
-  if (non_ghost_size(get_or_insert(Recipe_variants, inst.ingredients.at(i).name)) < 1) continue;
-  if (get(Recipe_ordinal, inst.name) < MAX_PRIMITIVE_RECIPES) continue;
-  if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) > 1) {
-    raise << maybe(caller_recipe.name) << "sorry, we're not yet smart enough to simultaneously guess which overloads you want for '" << inst.name << "' and '" << inst.ingredients.at(i).name << "'\n" << end();
-    return;
-  }
-  const recipe& callee = get(Recipe, get(Recipe_ordinal, inst.name));
-  if (!callee.has_header) {
-    raise << maybe(caller_recipe.name) << "sorry, we're not yet smart enough to guess which variant of '" << inst.ingredients.at(i).name << "' you want, when the caller '" << inst.name << "' doesn't have a header\n" << end();
-    return;
-  }
-  string new_name = resolve_ambiguous_call(inst.ingredients.at(i).name, callee.ingredients.at(i), r, index, caller_recipe);
-  if (new_name != "") {
-    inst.ingredients.at(i).name = new_name;
-    inst.ingredients.at(i).value = get(Recipe_ordinal, new_name);
-  }
-}
-
-:(code)
-void test_return_overloaded_recipe_literal_to_caller() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  {x: (fn num -> num)} <- g\n"
-      "  1:num/raw <- call x, 34\n"
-      "]\n"
-      "def g -> {x: (fn num -> num)} [\n"
-      "  local-scope\n"
-      "  return f\n"
-      "]\n"
-      // variant f
-      "def f x:bool -> y:bool [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-      // variant f_2
-      "def f x:num -> y:num [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  // x contains f_2
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(before "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
-if (inst.name == "return" || inst.name == "reply") {
-  for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-    if (!is_recipe_literal(inst.ingredients.at(i))) continue;
-    if (non_ghost_size(get_or_insert(Recipe_variants, inst.ingredients.at(i).name)) < 1) continue;
-    // potentially overloaded recipe
-    if (!caller_recipe.has_header) {
-      raise << maybe(caller_recipe.name) << "sorry, we're not yet smart enough to guess which variant of '" << inst.ingredients.at(i).name << "' you want, without a recipe header\n" << end();
-      return;
-    }
-    string new_name = resolve_ambiguous_call(inst.ingredients.at(i).name, caller_recipe.products.at(i), r, index, caller_recipe);
-    if (new_name == "") continue;
-    inst.ingredients.at(i).name = new_name;
-    inst.ingredients.at(i).value = get(Recipe_ordinal, new_name);
-  }
-  return;
-}
diff --git a/archive/2.vm/073scheduler.cc b/archive/2.vm/073scheduler.cc
deleted file mode 100644
index 5f97220b..00000000
--- a/archive/2.vm/073scheduler.cc
+++ /dev/null
@@ -1,709 +0,0 @@
-//: Run a second routine concurrently using 'start-running', without any
-//: guarantees on how the operations in each are interleaved with each other.
-
-void test_scheduler() {
-  run(
-      "def f1 [\n"
-      "  start-running f2\n"
-         // wait for f2 to run
-      "  {\n"
-      "    jump-unless 1:num, -1\n"
-      "  }\n"
-      "]\n"
-      "def f2 [\n"
-      "  1:num <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "schedule: f2\n"
-  );
-}
-
-//: first, add a deadline to run(routine)
-:(before "End Globals")
-int Scheduling_interval = 500;
-:(before "End routine Fields")
-int instructions_run_this_scheduling_slice;
-:(before "End routine Constructor")
-instructions_run_this_scheduling_slice = 0;
-:(after "Running One Instruction")
- ++Current_routine->instructions_run_this_scheduling_slice;
-:(replace{} "bool should_continue_running(const routine* current_routine)")
-bool should_continue_running(const routine* current_routine) {
-  assert(current_routine == Current_routine);  // argument passed in just to make caller readable above
-  return Current_routine->state == RUNNING
-      && Current_routine->instructions_run_this_scheduling_slice < Scheduling_interval;
-}
-:(after "stop_running_current_routine:")
-// Reset instructions_run_this_scheduling_slice
-Current_routine->instructions_run_this_scheduling_slice = 0;
-
-//: now the rest of the scheduler is clean
-
-:(before "struct routine")
-enum routine_state {
-  RUNNING,
-  COMPLETED,
-  // End routine States
-};
-:(before "End routine Fields")
-enum routine_state state;
-:(before "End routine Constructor")
-state = RUNNING;
-
-:(before "End Globals")
-vector<routine*> Routines;
-int Current_routine_index = 0;
-:(before "End Reset")
-Scheduling_interval = 500;
-for (int i = 0;  i < SIZE(Routines);  ++i)
-  delete Routines.at(i);
-Routines.clear();
-Current_routine = NULL;
-:(replace{} "void run(const recipe_ordinal r)")
-void run(const recipe_ordinal r) {
-  run(new routine(r));
-}
-
-:(code)
-void run(routine* rr) {
-  Routines.push_back(rr);
-  Current_routine_index = 0, Current_routine = Routines.at(0);
-  while (!all_routines_done()) {
-    skip_to_next_routine();
-    assert(Current_routine);
-    assert(Current_routine->state == RUNNING);
-    trace(100, "schedule") << current_routine_label() << end();
-    run_current_routine();
-    // Scheduler State Transitions
-    if (Current_routine->completed())
-      Current_routine->state = COMPLETED;
-    // End Scheduler State Transitions
-
-    // Scheduler Cleanup
-    // End Scheduler Cleanup
-  }
-  // End Run Routine
-}
-
-bool all_routines_done() {
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->state == RUNNING)
-      return false;
-  }
-  return true;
-}
-
-// skip Current_routine_index past non-RUNNING routines
-void skip_to_next_routine() {
-  assert(!Routines.empty());
-  assert(Current_routine_index < SIZE(Routines));
-  for (int i = (Current_routine_index+1)%SIZE(Routines);  i != Current_routine_index;  i = (i+1)%SIZE(Routines)) {
-    if (Routines.at(i)->state == RUNNING) {
-      Current_routine_index = i;
-      Current_routine = Routines.at(i);
-      return;
-    }
-  }
-}
-
-string current_routine_label() {
-  return routine_label(Current_routine);
-}
-
-string routine_label(routine* r) {
-  ostringstream result;
-  const call_stack& calls = r->calls;
-  for (call_stack::const_iterator p = calls.begin();  p != calls.end();  ++p) {
-    if (p != calls.begin()) result << '/';
-    result << get(Recipe, p->running_recipe).name;
-  }
-  return result.str();
-}
-
-//: special case for the very first routine
-:(replace{} "void run_main(int argc, char* argv[])")
-void run_main(int argc, char* argv[]) {
-  recipe_ordinal r = get(Recipe_ordinal, "main");
-  assert(r);
-  routine* main_routine = new routine(r);
-  // pass in commandline args as ingredients to main
-  // todo: test this
-  Current_routine = main_routine;
-  for (int i = 1;  i < argc;  ++i) {
-    vector<double> arg;
-    arg.push_back(/*alloc id*/0);
-    arg.push_back(new_mu_text(argv[i]));
-    assert(get(Memory, arg.back()) == 0);
-    current_call().ingredient_atoms.push_back(arg);
-  }
-  run(main_routine);
-}
-
-//:: To schedule new routines to run, call 'start-running'.
-
-//: 'start-running' will return a unique id for the routine that was created.
-//: routine id is a number, but don't do any arithmetic on it
-:(before "End routine Fields")
-int id;
-:(before "End Globals")
-int Next_routine_id = 1;
-:(before "End Reset")
-Next_routine_id = 1;
-:(before "End routine Constructor")
-id = Next_routine_id;
-++Next_routine_id;
-
-//: routines save the routine that spawned them
-:(before "End routine Fields")
-// todo: really should be routine_id, but that's less efficient.
-int parent_index;  // only < 0 if there's no parent_index
-:(before "End routine Constructor")
-parent_index = -1;
-
-:(before "End Primitive Recipe Declarations")
-START_RUNNING,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "start-running", START_RUNNING);
-:(before "End Primitive Recipe Checks")
-case START_RUNNING: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end();
-    break;
-  }
-  if (!is_mu_recipe(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case START_RUNNING: {
-  routine* new_routine = new routine(ingredients.at(0).at(0));
-  new_routine->parent_index = Current_routine_index;
-  // populate ingredients
-  for (int i = /*skip callee*/1;  i < SIZE(current_instruction().ingredients);  ++i) {
-    new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i));
-    reagent/*copy*/ ingredient = current_instruction().ingredients.at(i);
-    new_routine->calls.front().ingredients.push_back(ingredient);
-    // End Populate start-running Ingredient
-  }
-  Routines.push_back(new_routine);
-  products.resize(1);
-  products.at(0).push_back(new_routine->id);
-  break;
-}
-
-:(code)
-void test_scheduler_runs_single_routine() {
-  Scheduling_interval = 1;
-  run(
-      "def f1 [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "run: {1: \"number\"} <- copy {0: \"literal\"}\n"
-      "schedule: f1\n"
-      "run: {2: \"number\"} <- copy {0: \"literal\"}\n"
-  );
-}
-
-void test_scheduler_interleaves_routines() {
-  Scheduling_interval = 1;
-  run(
-      "def f1 [\n"
-      "  start-running f2\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-      "def f2 [\n"
-      "  3:num <- copy 0\n"
-      "  4:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "run: start-running {f2: \"recipe-literal\"}\n"
-      "schedule: f2\n"
-      "run: {3: \"number\"} <- copy {0: \"literal\"}\n"
-      "schedule: f1\n"
-      "run: {1: \"number\"} <- copy {0: \"literal\"}\n"
-      "schedule: f2\n"
-      "run: {4: \"number\"} <- copy {0: \"literal\"}\n"
-      "schedule: f1\n"
-      "run: {2: \"number\"} <- copy {0: \"literal\"}\n"
-  );
-}
-
-void test_start_running_takes_ingredients() {
-  run(
-      "def f1 [\n"
-      "  start-running f2, 3\n"
-         // wait for f2 to run
-      "  {\n"
-      "    jump-unless 1:num, -1\n"
-      "  }\n"
-      "]\n"
-      "def f2 [\n"
-      "  1:num <- next-ingredient\n"
-      "  2:num <- add 1:num, 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 4 in location 2\n"
-  );
-}
-
-//: type-checking for 'start-running'
-
-void test_start_running_checks_types() {
-  Hide_errors = true;
-  run(
-      "def f1 [\n"
-      "  start-running f2, 3\n"
-      "]\n"
-      "def f2 n:&:num [\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: f1: ingredient 0 has the wrong type at 'start-running f2, 3'\n"
-  );
-}
-
-// 'start-running' only uses the ingredients of the callee, not its products
-:(before "End is_indirect_call_with_ingredients Special-cases")
-if (r == START_RUNNING) return true;
-
-//: back to testing 'start-running'
-
-:(code)
-void test_start_running_returns_routine_id() {
-  run(
-      "def f1 [\n"
-      "  1:num <- start-running f2\n"
-      "]\n"
-      "def f2 [\n"
-      "  12:num <- copy 44\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 2 in location 1\n"
-  );
-}
-
-//: this scenario requires some careful setup
-void test_scheduler_skips_completed_routines() {
-  recipe_ordinal f1 = load(
-      "recipe f1 [\n"
-      "  1:num <- copy 0\n"
-      "]\n").front();
-  recipe_ordinal f2 = load(
-      "recipe f2 [\n"
-      "  2:num <- copy 0\n"
-      "]\n").front();
-  Routines.push_back(new routine(f1));  // f1 meant to run
-  Routines.push_back(new routine(f2));
-  Routines.back()->state = COMPLETED;  // f2 not meant to run
-  run(
-      "def f3 [\n"
-      "  3:num <- copy 0\n"
-      "]\n"
-  );
-  // f1 and f3 can run in any order
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "mem: storing 0 in location 1\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("schedule: f2");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 0 in location 2");
-  CHECK_TRACE_CONTENTS(
-      "schedule: f3\n"
-      "mem: storing 0 in location 3\n"
-  );
-}
-
-void test_scheduler_starts_at_middle_of_routines() {
-  Routines.push_back(new routine(COPY));
-  Routines.back()->state = COMPLETED;
-  run(
-      "def f1 [\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: idle");
-}
-
-//:: Errors in a routine cause it to terminate.
-
-void test_scheduler_terminates_routines_after_errors() {
-  Hide_errors = true;
-  Scheduling_interval = 2;
-  run(
-      "def f1 [\n"
-      "  start-running f2\n"
-      "  1:num <- copy 0\n"
-      "  2:num <- copy 0\n"
-      "]\n"
-      "def f2 [\n"
-         // divide by 0 twice
-      "  3:num <- divide-with-remainder 4, 0\n"
-      "  4:num <- divide-with-remainder 4, 0\n"
-      "]\n"
-  );
-  // f2 should stop after first divide by 0
-  CHECK_TRACE_CONTENTS(
-      "error: f2: divide by zero in '3:num <- divide-with-remainder 4, 0'\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: f2: divide by zero in '4:num <- divide-with-remainder 4, 0'");
-}
-
-:(after "operator<<(ostream& os, end /*unused*/)")
-  if (Trace_stream && Trace_stream->curr_label == "error" && Current_routine) {
-    Current_routine->state = COMPLETED;
-  }
-
-//:: Routines are marked completed when their parent completes.
-
-:(code)
-void test_scheduler_kills_orphans() {
-  run(
-      "def main [\n"
-      "  start-running f1\n"
-         // f1 never actually runs because its parent completes without
-         // waiting for it
-      "]\n"
-      "def f1 [\n"
-      "  1:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("schedule: f1");
-}
-
-:(before "End Scheduler Cleanup")
-for (int i = 0;  i < SIZE(Routines);  ++i) {
-  if (Routines.at(i)->state == COMPLETED) continue;
-  if (Routines.at(i)->parent_index < 0) continue;  // root thread
-  // structured concurrency: http://250bpm.com/blog:71
-  if (has_completed_parent(i)) {
-    Routines.at(i)->state = COMPLETED;
-  }
-}
-
-:(code)
-bool has_completed_parent(int routine_index) {
-  for (int j = routine_index;  j >= 0;  j = Routines.at(j)->parent_index) {
-    if (Routines.at(j)->state == COMPLETED)
-      return true;
-  }
-  return false;
-}
-
-//:: 'routine-state' can tell if a given routine id is running
-
-void test_routine_state_test() {
-  Scheduling_interval = 2;
-  run(
-      "def f1 [\n"
-      "  1:num/child-id <- start-running f2\n"
-      "  12:num <- copy 0\n"  // race condition since we don't care about location 12
-         // thanks to Scheduling_interval, f2's one instruction runs in
-         // between here and completes
-      "  2:num/state <- routine-state 1:num/child-id\n"
-      "]\n"
-      "def f2 [\n"
-      "  12:num <- copy 0\n"
-         // trying to run a second instruction marks routine as completed
-      "]\n"
-  );
-  // routine f2 should be in state COMPLETED
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 2\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-ROUTINE_STATE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "routine-state", ROUTINE_STATE);
-:(before "End Primitive Recipe Checks")
-case ROUTINE_STATE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ROUTINE_STATE: {
-  int id = ingredients.at(0).at(0);
-  int result = -1;
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->id == id) {
-      result = Routines.at(i)->state;
-      break;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-//:: miscellaneous helpers
-
-:(before "End Primitive Recipe Declarations")
-STOP,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "stop", STOP);
-:(before "End Primitive Recipe Checks")
-case STOP: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case STOP: {
-  int id = ingredients.at(0).at(0);
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->id == id) {
-      Routines.at(i)->state = COMPLETED;
-      break;
-    }
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_ROUTINES,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump-routines", _DUMP_ROUTINES);
-:(before "End Primitive Recipe Checks")
-case _DUMP_ROUTINES: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _DUMP_ROUTINES: {
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    cerr << i << ": " << Routines.at(i)->id << ' ' << Routines.at(i)->state << ' ' << Routines.at(i)->parent_index << '\n';
-  }
-  break;
-}
-
-//: support for stopping routines after some number of cycles
-
-:(code)
-void test_routine_discontinues_past_limit() {
-  Scheduling_interval = 2;
-  run(
-      "def f1 [\n"
-      "  1:num/child-id <- start-running f2\n"
-      "  limit-time 1:num/child-id, 10\n"
-         // padding loop just to make sure f2 has time to complete
-      "  2:num <- copy 20\n"
-      "  2:num <- subtract 2:num, 1\n"
-      "  jump-if 2:num, -2:offset\n"
-      "]\n"
-      "def f2 [\n"
-      "  jump -1:offset\n"  // run forever
-      "  $print [should never get here], 10/newline\n"
-      "]\n"
-  );
-  // f2 terminates
-  CHECK_TRACE_CONTENTS(
-      "schedule: discontinuing routine 2\n"
-  );
-}
-
-:(before "End routine States")
-DISCONTINUED,
-:(before "End Scheduler State Transitions")
-if (Current_routine->limit >= 0) {
-  if (Current_routine->limit <= Scheduling_interval) {
-    trace(100, "schedule") << "discontinuing routine " << Current_routine->id << end();
-    Current_routine->state = DISCONTINUED;
-    Current_routine->limit = 0;
-  }
-  else {
-    Current_routine->limit -= Scheduling_interval;
-  }
-}
-
-:(before "End Test Teardown")
-if (Passed && any_routines_with_error())
-  raise << "some routines died with errors\n" << end();
-:(before "End Mu Test Teardown")
-if (Passed && any_routines_with_error())
-  raise << Current_scenario->name << ": some routines died with errors\n" << end();
-
-:(code)
-bool any_routines_with_error() {
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->state == DISCONTINUED)
-      return true;
-  }
-  return false;
-}
-
-:(before "End routine Fields")
-int limit;
-:(before "End routine Constructor")
-limit = -1;  /* no limit */
-
-:(before "End Primitive Recipe Declarations")
-LIMIT_TIME,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "limit-time", LIMIT_TIME);
-:(before "End Primitive Recipe Checks")
-case LIMIT_TIME: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case LIMIT_TIME: {
-  int id = ingredients.at(0).at(0);
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->id == id) {
-      Routines.at(i)->limit = ingredients.at(1).at(0);
-      break;
-    }
-  }
-  break;
-}
-
-:(before "End routine Fields")
-int instructions_run;
-:(before "End routine Constructor")
-instructions_run = 0;
-:(before "Reset instructions_run_this_scheduling_slice")
-Current_routine->instructions_run += Current_routine->instructions_run_this_scheduling_slice;
-:(before "End Primitive Recipe Declarations")
-NUMBER_OF_INSTRUCTIONS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "number-of-instructions", NUMBER_OF_INSTRUCTIONS);
-:(before "End Primitive Recipe Checks")
-case NUMBER_OF_INSTRUCTIONS: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'number-of-instructions' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'number-of-instructions' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case NUMBER_OF_INSTRUCTIONS: {
-  int id = ingredients.at(0).at(0);
-  int result = -1;
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->id == id) {
-      result = Routines.at(i)->instructions_run;
-      break;
-    }
-  }
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-void test_number_of_instructions() {
-  run(
-      "def f1 [\n"
-      "  10:num/child-id <- start-running f2\n"
-      "  {\n"
-      "    loop-unless 20:num\n"
-      "  }\n"
-      "  11:num <- number-of-instructions 10:num\n"
-      "]\n"
-      "def f2 [\n"
-         // 2 instructions worth of work
-      "  1:num <- copy 34\n"
-      "  20:num <- copy 1\n"
-      "]\n"
-  );
-  // f2 runs an extra instruction for the implicit 'return' added by the
-  // fill_in_return_ingredients transform
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 3 in location 11\n"
-  );
-}
-
-void test_number_of_instructions_across_multiple_scheduling_intervals() {
-  Scheduling_interval = 1;
-  run(
-      "def f1 [\n"
-      "  10:num/child-id <- start-running f2\n"
-      "  {\n"
-      "    loop-unless 20:num\n"
-      "  }\n"
-      "  11:num <- number-of-instructions 10:num\n"
-      "]\n"
-      "def f2 [\n"
-         // 4 instructions worth of work
-      "  1:num <- copy 34\n"
-      "  2:num <- copy 1\n"
-      "  2:num <- copy 3\n"
-      "  20:num <- copy 1\n"
-      "]\n"
-  );
-  // f2 runs an extra instruction for the implicit 'return' added by the
-  // fill_in_return_ingredients transform
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 5 in location 11\n"
-  );
-}
-
-//:: make sure that each routine gets a different alloc to start
-
-void test_new_concurrent() {
-  run(
-      "def f1 [\n"
-      "  start-running f2\n"
-      "  1:&:num/raw <- new number:type\n"
-         // wait for f2 to complete
-      "  {\n"
-      "    loop-unless 4:num/raw\n"
-      "  }\n"
-      "]\n"
-      "def f2 [\n"
-      "  2:&:num/raw <- new number:type\n"
-         // hack: assumes scheduler implementation
-      "  3:bool/raw <- equal 1:&:num/raw, 2:&:num/raw\n"
-         // signal f2 complete
-      "  4:num/raw <- copy 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 3\n"
-  );
-}
diff --git a/archive/2.vm/074wait.cc b/archive/2.vm/074wait.cc
deleted file mode 100644
index 8eb4b887..00000000
--- a/archive/2.vm/074wait.cc
+++ /dev/null
@@ -1,664 +0,0 @@
-//: Routines can be put in a 'waiting' state, from which it will be ready to
-//: run again when a specific memory location changes its value. This is Mu's
-//: basic technique for orchestrating the order in which different routines
-//: operate.
-
-void test_wait_for_location() {
-  run(
-      "def f1 [\n"
-      "  10:num <- copy 34\n"
-      "  start-running f2\n"
-      "  20:location <- copy 10/unsafe\n"
-      "  wait-for-reset-then-set 20:location\n"
-         // wait for f2 to run and reset location 1
-      "  30:num <- copy 10:num\n"
-      "]\n"
-      "def f2 [\n"
-      "  10:location <- copy 0/unsafe\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "run: waiting for location 10 to reset\n"
-      "schedule: f2\n"
-      "schedule: waking up routine 1\n"
-      "schedule: f1\n"
-      "mem: storing 1 in location 30\n"
-  );
-}
-
-//: define the new state that all routines can be in
-
-:(before "End routine States")
-WAITING,
-:(before "End routine Fields")
-// only if state == WAITING
-int waiting_on_location;
-:(before "End routine Constructor")
-waiting_on_location = 0;
-
-:(before "End Mu Test Teardown")
-if (Passed && any_routines_waiting())
-  raise << Current_scenario->name << ": deadlock!\n" << end();
-:(before "End Run Routine")
-if (any_routines_waiting()) {
-  raise << "deadlock!\n" << end();
-  dump_waiting_routines();
-}
-:(before "End Test Teardown")
-if (Passed && any_routines_with_error())
-  raise << "some routines died with errors\n" << end();
-:(code)
-bool any_routines_waiting() {
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->state == WAITING)
-      return true;
-  }
-  return false;
-}
-void dump_waiting_routines() {
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->state == WAITING)
-      cerr << i << ": " << routine_label(Routines.at(i)) << '\n';
-  }
-}
-
-void test_wait_for_location_can_deadlock() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  10:num <- copy 1\n"
-      "  20:location <- copy 10/unsafe\n"
-      "  wait-for-reset-then-set 20:location\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: deadlock!\n"
-  );
-}
-
-//: Primitive recipe to put routines in that state.
-//: This primitive is also known elsewhere as compare-and-set (CAS). Used to
-//: build locks.
-
-:(before "End Primitive Recipe Declarations")
-WAIT_FOR_RESET_THEN_SET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "wait-for-reset-then-set", WAIT_FOR_RESET_THEN_SET);
-:(before "End Primitive Recipe Checks")
-case WAIT_FOR_RESET_THEN_SET: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_location(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case WAIT_FOR_RESET_THEN_SET: {
-  int loc = static_cast<int>(ingredients.at(0).at(0));
-  trace(Callstack_depth+1, "run") << "wait: *" << loc << " = " << get_or_insert(Memory, loc) << end();
-  if (get_or_insert(Memory, loc) == 0) {
-    trace(Callstack_depth+1, "run") << "location " << loc << " is already 0; setting" << end();
-    put(Memory, loc, 1);
-    break;
-  }
-  trace(Callstack_depth+1, "run") << "waiting for location " << loc << " to reset" << end();
-  Current_routine->state = WAITING;
-  Current_routine->waiting_on_location = loc;
-  break;
-}
-
-//: Counterpart to unlock a lock.
-:(before "End Primitive Recipe Declarations")
-RESET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "reset", RESET);
-:(before "End Primitive Recipe Checks")
-case RESET: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'reset' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_location(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'reset' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RESET: {
-  int loc = static_cast<int>(ingredients.at(0).at(0));
-  put(Memory, loc, 0);
-  trace(Callstack_depth+1, "run") << "reset: *" << loc << " = " << get_or_insert(Memory, loc) << end();
-  break;
-}
-
-//: scheduler tweak to get routines out of that state
-
-:(before "End Scheduler State Transitions")
-for (int i = 0;  i < SIZE(Routines);  ++i) {
-  if (Routines.at(i)->state != WAITING) continue;
-  int loc = Routines.at(i)->waiting_on_location;
-  if (loc && get_or_insert(Memory, loc) == 0) {
-    trace(100, "schedule") << "waking up routine " << Routines.at(i)->id << end();
-    put(Memory, loc, 1);
-    Routines.at(i)->state = RUNNING;
-    Routines.at(i)->waiting_on_location = 0;
-  }
-}
-
-//: Primitive to help compute locations to wait on.
-//: Only supports elements immediately inside containers; no arrays or
-//: containers within containers yet.
-
-:(code)
-void test_get_location() {
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  15:location <- get-location 12:point, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 13 in location 15\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-GET_LOCATION,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "get-location", GET_LOCATION);
-:(before "End Primitive Recipe Checks")
-case GET_LOCATION: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'get-location' expects exactly 2 ingredients in '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  reagent/*copy*/ base = inst.ingredients.at(0);
-  if (!canonize_type(base)) break;
-  if (!base.type) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  const type_tree* base_root_type = base.type->atom ? base.type : base.type->left;
-  if (!base_root_type->atom || base_root_type->value == 0 || !contains_key(Type, base_root_type->value) || get(Type, base_root_type->value).kind != CONTAINER) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  type_ordinal base_type = base.type->value;
-  const reagent& offset = inst.ingredients.at(1);
-  if (!is_literal(offset) || !is_mu_scalar(offset)) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'get-location' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  int offset_value = 0;
-  //: later layers will permit non-integer offsets
-  if (is_integer(offset.name)) {
-    offset_value = to_integer(offset.name);
-    if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type).elements)) {
-      raise << maybe(get(Recipe, r).name) << "invalid offset " << offset_value << " for '" << get(Type, base_type).name << "'\n" << end();
-      break;
-    }
-  }
-  else {
-    offset_value = offset.value;
-  }
-  if (inst.products.empty()) break;
-  if (!is_mu_location(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "'get-location " << base.original_string << ", " << offset.original_string << "' should write to type location but '" << inst.products.at(0).name << "' has type '" << names_to_string_without_quotes(inst.products.at(0).type) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case GET_LOCATION: {
-  reagent/*copy*/ base = current_instruction().ingredients.at(0);
-  canonize(base);
-  int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  const type_tree* base_type = get_base_type(base.type);
-  int offset = ingredients.at(1).at(0);
-  if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break;  // copied from Check above
-  int result = base_address;
-  for (int i = 0;  i < offset;  ++i)
-    result += size_of(element_type(base.type, i));
-  trace(Callstack_depth+1, "run") << "address to copy is " << result << end();
-  products.resize(1);
-  products.at(0).push_back(result);
-  break;
-}
-
-:(code)
-bool is_mu_location(reagent/*copy*/ x) {
-  if (!canonize_type(x)) return false;
-  if (!x.type) return false;
-  if (!x.type->atom) return false;
-  return x.type->value == get(Type_ordinal, "location");
-}
-
-void test_get_location_out_of_bounds() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  get-location 12:point-number/raw, 2:offset\n"  // point-number occupies 3 locations but has only 2 fields; out of bounds
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid offset 2 for 'point-number'\n"
-  );
-}
-
-void test_get_location_out_of_bounds_2() {
-  Hide_errors = true;
-  run(
-      "def main [\n"
-      "  12:num <- copy 34\n"
-      "  13:num <- copy 35\n"
-      "  14:num <- copy 36\n"
-      "  get-location 12:point-number/raw, -1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: invalid offset -1 for 'point-number'\n"
-  );
-}
-
-void test_get_location_product_type_mismatch() {
-  Hide_errors = true;
-  run(
-      "container boolbool [\n"
-      "  x:bool\n"
-      "  y:bool\n"
-      "]\n"
-      "def main [\n"
-      "  12:bool <- copy 1\n"
-      "  13:bool <- copy 0\n"
-      "  15:bool <- get-location 12:boolbool, 1:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: main: 'get-location 12:boolbool, 1:offset' should write to type location but '15' has type 'boolean'\n"
-  );
-}
-
-void test_get_location_indirect() {
-  // 'get-location' can read from container address
-  run(
-      "def main [\n"
-      "  1:num/alloc-id, 2:num <- copy 0, 10\n"
-      "  10:num/alloc-id, 11:num/x, 12:num/y <- copy 0, 34, 35\n"
-      "  20:location <- get-location 1:&:point/lookup, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 11 in location 20\n"
-  );
-}
-
-void test_get_location_indirect_2() {
-  run(
-      "def main [\n"
-      "  1:num/alloc-id, 2:num <- copy 0, 10\n"
-      "  10:num/alloc-id, 11:num/x, 12:num/y <- copy 0, 34, 35\n"
-      "  4:num/alloc-id, 5:num <- copy 0, 20\n"
-      "  4:&:location/lookup <- get-location 1:&:point/lookup, 0:offset\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 11 in location 21\n"
-  );
-}
-
-//: allow waiting on a routine to complete
-
-void test_wait_for_routine() {
-  run(
-      "def f1 [\n"
-         // add a few routines to run
-      "  1:num/routine <- start-running f2\n"
-      "  2:num/routine <- start-running f3\n"
-      "  wait-for-routine 1:num/routine\n"
-         // now wait for f2 to *complete* and modify location 13 before using its value
-      "  20:num <- copy 13:num\n"
-      "]\n"
-      "def f2 [\n"
-      "  10:num <- copy 0\n"  // just padding
-      "  switch\n"  // simulate a block; routine f1 shouldn't restart at this point
-      "  13:num <- copy 34\n"
-      "]\n"
-      "def f3 [\n"
-         // padding routine just to help simulate the block in f2 using 'switch'
-      "  11:num <- copy 0\n"
-      "  12:num <- copy 0\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "run: waiting for routine 2\n"
-      "schedule: f2\n"
-      "schedule: f3\n"
-      "schedule: f2\n"
-      "schedule: waking up routine 1\n"
-      "schedule: f1\n"
-      // if we got the synchronization wrong we'd be storing 0 in location 20
-      "mem: storing 34 in location 20\n"
-  );
-}
-
-:(before "End routine Fields")
-// only if state == WAITING
-int waiting_on_routine;
-:(before "End routine Constructor")
-waiting_on_routine = 0;
-
-:(before "End Primitive Recipe Declarations")
-WAIT_FOR_ROUTINE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "wait-for-routine", WAIT_FOR_ROUTINE);
-:(before "End Primitive Recipe Checks")
-case WAIT_FOR_ROUTINE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'wait-for-routine' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case WAIT_FOR_ROUTINE: {
-  if (ingredients.at(0).at(0) == Current_routine->id) {
-    raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  Current_routine->state = WAITING;
-  Current_routine->waiting_on_routine = ingredients.at(0).at(0);
-  trace(Callstack_depth+1, "run") << "waiting for routine " << ingredients.at(0).at(0) << end();
-  break;
-}
-
-:(before "End Scheduler State Transitions")
-// Wake up any routines waiting for other routines to complete.
-// Important: this must come after the scheduler loop above giving routines
-// waiting for locations to change a chance to wake up.
-for (int i = 0;  i < SIZE(Routines);  ++i) {
-  if (Routines.at(i)->state != WAITING) continue;
-  routine* waiter = Routines.at(i);
-  if (!waiter->waiting_on_routine) continue;
-  int id = waiter->waiting_on_routine;
-  assert(id != waiter->id);  // routine can't wait on itself
-  for (int j = 0;  j < SIZE(Routines);  ++j) {
-    const routine* waitee = Routines.at(j);
-    if (waitee->id == id && waitee->state != RUNNING && waitee->state != WAITING) {
-      // routine is COMPLETED or DISCONTINUED
-      trace(100, "schedule") << "waking up routine " << waiter->id << end();
-      waiter->state = RUNNING;
-      waiter->waiting_on_routine = 0;
-    }
-  }
-}
-
-//: yield voluntarily to let some other routine run
-
-:(before "End Primitive Recipe Declarations")
-SWITCH,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "switch", SWITCH);
-:(before "End Primitive Recipe Checks")
-case SWITCH: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SWITCH: {
-  ++current_step_index();
-  goto stop_running_current_routine;
-}
-
-:(code)
-void test_switch_preempts_current_routine() {
-  run(
-      "def f1 [\n"
-      "  start-running f2\n"
-      "  1:num <- copy 34\n"
-      "  switch\n"
-      "  3:num <- copy 36\n"
-      "]\n"
-      "def f2 [\n"
-      "  2:num <- copy 35\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-      // context switch
-      "mem: storing 35 in location 2\n"
-      // back to original thread
-      "mem: storing 36 in location 3\n"
-  );
-}
-
-//:: helpers for manipulating routines in tests
-//:
-//: Managing arbitrary scenarios requires the ability to:
-//:   a) check if a routine is blocked
-//:   b) restart a blocked routine ('restart')
-//:
-//: A routine is blocked either if it's waiting or if it explicitly signals
-//: that it's blocked (even as it periodically wakes up and polls for some
-//: event).
-//:
-//: Signalling blockedness might well be a huge hack. But Mu doesn't have Unix
-//: signals to avoid polling with, because signals are also pretty hacky.
-
-:(before "End routine Fields")
-bool blocked;
-:(before "End routine Constructor")
-blocked = false;
-
-:(before "End Primitive Recipe Declarations")
-CURRENT_ROUTINE_IS_BLOCKED,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "current-routine-is-blocked", CURRENT_ROUTINE_IS_BLOCKED);
-:(before "End Primitive Recipe Checks")
-case CURRENT_ROUTINE_IS_BLOCKED: {
-  if (!inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'current-routine-is-blocked' should have no ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CURRENT_ROUTINE_IS_BLOCKED: {
-  Current_routine->blocked = true;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CURRENT_ROUTINE_IS_UNBLOCKED,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "current-routine-is-unblocked", CURRENT_ROUTINE_IS_UNBLOCKED);
-:(before "End Primitive Recipe Checks")
-case CURRENT_ROUTINE_IS_UNBLOCKED: {
-  if (!inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'current-routine-is-unblocked' should have no ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CURRENT_ROUTINE_IS_UNBLOCKED: {
-  Current_routine->blocked = false;
-  break;
-}
-
-//: also allow waiting on a routine to block
-//: (just for tests; use wait_for_routine above wherever possible)
-
-:(code)
-void test_wait_for_routine_to_block() {
-  run(
-      "def f1 [\n"
-      "  1:num/routine <- start-running f2\n"
-      "  wait-for-routine-to-block 1:num/routine\n"
-         // now wait for f2 to run and modify location 10 before using its value
-      "  11:num <- copy 10:num\n"
-      "]\n"
-      "def f2 [\n"
-      "  10:num <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "schedule: f1\n"
-      "run: waiting for routine 2 to block\n"
-      "schedule: f2\n"
-      "schedule: waking up routine 1 because routine 2 is blocked\n"
-      "schedule: f1\n"
-      // if we got the synchronization wrong we'd be storing 0 in location 11
-      "mem: storing 34 in location 11\n"
-  );
-}
-
-:(before "End routine Fields")
-// only if state == WAITING
-int waiting_on_routine_to_block;
-:(before "End routine Constructor")
-waiting_on_routine_to_block = 0;
-
-:(before "End Primitive Recipe Declarations")
-WAIT_FOR_ROUTINE_TO_BLOCK,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "wait-for-routine-to-block", WAIT_FOR_ROUTINE_TO_BLOCK);
-:(before "End Primitive Recipe Checks")
-case WAIT_FOR_ROUTINE_TO_BLOCK: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'wait-for-routine-to-block' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine-to-block' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case WAIT_FOR_ROUTINE_TO_BLOCK: {
-  if (ingredients.at(0).at(0) == Current_routine->id) {
-    raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  Current_routine->state = WAITING;
-  Current_routine->waiting_on_routine_to_block = ingredients.at(0).at(0);
-  trace(Callstack_depth+1, "run") << "waiting for routine " << ingredients.at(0).at(0) << " to block" << end();
-  break;
-}
-
-:(before "End Scheduler State Transitions")
-// Wake up any routines waiting for other routines to stop running.
-for (int i = 0;  i < SIZE(Routines);  ++i) {
-  if (Routines.at(i)->state != WAITING) continue;
-  routine* waiter = Routines.at(i);
-  if (!waiter->waiting_on_routine_to_block) continue;
-  int id = waiter->waiting_on_routine_to_block;
-  assert(id != waiter->id);  // routine can't wait on itself
-  for (int j = 0;  j < SIZE(Routines);  ++j) {
-    const routine* waitee = Routines.at(j);
-    if (waitee->id != id) continue;
-    if (waitee->state != RUNNING || waitee->blocked) {
-      trace(100, "schedule") << "waking up routine " << waiter->id << " because routine " << waitee->id << " is blocked" << end();
-      waiter->state = RUNNING;
-      waiter->waiting_on_routine_to_block = 0;
-    }
-  }
-}
-
-//: helper for restarting blocking routines in tests
-
-:(before "End Primitive Recipe Declarations")
-RESTART,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "restart", RESTART);
-:(before "End Primitive Recipe Checks")
-case RESTART: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RESTART: {
-  int id = ingredients.at(0).at(0);
-  for (int i = 0;  i < SIZE(Routines);  ++i) {
-    if (Routines.at(i)->id == id) {
-      if (Routines.at(i)->state == WAITING)
-        Routines.at(i)->state = RUNNING;
-      Routines.at(i)->blocked = false;
-      break;
-    }
-  }
-  break;
-}
-
-:(code)
-void test_cannot_restart_completed_routine() {
-  Scheduling_interval = 1;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  r:num/routine-id <- start-running f\n"
-      "  x:num <- copy 0\n"  // wait for f to be scheduled
-      // r is COMPLETED by this point
-      "  restart r\n"  // should have no effect
-      "  x:num <- copy 0\n"  // give f time to be scheduled (though it shouldn't be)
-      "]\n"
-      "def f [\n"
-      "  1:num/raw <- copy 1\n"
-      "]\n"
-  );
-  // shouldn't crash
-}
-
-void test_restart_blocked_routine() {
-  Scheduling_interval = 1;
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  r:num/routine-id <- start-running f\n"
-      "  wait-for-routine-to-block r\n"  // get past the block in f below
-      "  restart r\n"
-      "  wait-for-routine-to-block r\n"  // should run f to completion
-      "]\n"
-      // function with one block
-      "def f [\n"
-      "  current-routine-is-blocked\n"
-         // 8 instructions of padding, many more than 'main' above
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "  1:num <- add 1:num, 1\n"
-      "]\n"
-  );
-  // make sure all of f ran
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 8 in location 1\n"
-  );
-}
diff --git a/archive/2.vm/075channel.mu b/archive/2.vm/075channel.mu
deleted file mode 100644
index c64492cb..00000000
--- a/archive/2.vm/075channel.mu
+++ /dev/null
@@ -1,510 +0,0 @@
-# Mu synchronizes between routines using channels rather than locks, like
-# Erlang and Go.
-#
-# The key property of channels: Writing to a full channel or reading from an
-# empty one will put the current routine in 'waiting' state until the
-# operation can be completed.
-#
-# Beware of addresses passed into channels. They can cause race conditions.
-
-scenario channel [
-  run [
-    local-scope
-    source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-    sink <- write sink, 34
-    10:num/raw, 11:bool/raw, source <- read source
-  ]
-  memory-should-contain [
-    10 <- 34
-    11 <- 0  # read was successful
-  ]
-]
-
-container channel:_elem [
-  lock:bool  # inefficient but simple: serialize all reads as well as writes
-  first-full:num  # for write
-  first-free:num  # for read
-  # A circular buffer contains values from index first-full up to (but not
-  # including) index first-free. The reader always modifies it at first-full,
-  # while the writer always modifies it at first-free.
-  data:&:@:_elem
-]
-
-# Since channels have two ends, and since it's an error to use either end from
-# multiple routines, let's distinguish the ends.
-
-container source:_elem [
-  chan:&:channel:_elem
-]
-
-container sink:_elem [
-  chan:&:channel:_elem
-]
-
-def new-channel capacity:num -> in:&:source:_elem, out:&:sink:_elem [
-  local-scope
-  load-inputs
-  result:&:channel:_elem <- new {(channel _elem): type}
-  *result <- put *result, first-full:offset, 0
-  *result <- put *result, first-free:offset, 0
-  capacity <- add capacity, 1  # unused slot for 'full?' below
-  data:&:@:_elem <- new _elem:type, capacity
-  *result <- put *result, data:offset, data
-  in <- new {(source _elem): type}
-  *in <- put *in, chan:offset, result
-  out <- new {(sink _elem): type}
-  *out <- put *out, chan:offset, result
-]
-
-# write a value to a channel
-def write out:&:sink:_elem, val:_elem -> out:&:sink:_elem [
-  local-scope
-  load-inputs
-  assert out, [write to null channel]
-  chan:&:channel:_elem <- get *out, chan:offset
-  <channel-write-initial>
-  # block until lock is acquired AND queue has room
-  lock:location <- get-location *chan, lock:offset
-#?   $print [write], 10/newline
-  {
-#?     $print [trying to acquire lock for writing], 10/newline
-    wait-for-reset-then-set lock
-#?     $print [lock acquired for writing], 10/newline
-    full?:bool <- channel-full? chan
-    break-unless full?
-#?     $print [but channel is full; relinquishing lock], 10/newline
-    # channel is full; relinquish lock and give a reader the opportunity to
-    # create room on it
-    reset lock
-    current-routine-is-blocked
-    switch  # avoid spinlocking
-    loop
-  }
-  current-routine-is-unblocked
-#?   $print [performing write], 10/newline
-  # store a deep copy of val
-  circular-buffer:&:@:_elem <- get *chan, data:offset
-  free:num <- get *chan, first-free:offset
-  *circular-buffer <- put-index *circular-buffer, free, val
-  # mark its slot as filled
-  free <- add free, 1
-  {
-    # wrap free around to 0 if necessary
-    len:num <- length *circular-buffer
-    at-end?:bool <- greater-or-equal free, len
-    break-unless at-end?
-    free <- copy 0
-  }
-  # write back
-  *chan <- put *chan, first-free:offset, free
-#?   $print [relinquishing lock after writing], 10/newline
-  reset lock
-]
-
-# read a value from a channel
-def read in:&:source:_elem -> result:_elem, eof?:bool, in:&:source:_elem [
-  local-scope
-  load-inputs
-  assert in, [read on null channel]
-  eof? <- copy false  # default result
-  chan:&:channel:_elem <- get *in, chan:offset
-  # block until lock is acquired AND queue has data
-  lock:location <- get-location *chan, lock:offset
-#?   $print [read], 10/newline
-  {
-#?     $print [trying to acquire lock for reading], 10/newline
-    wait-for-reset-then-set lock
-#?     $print [lock acquired for reading], 10/newline
-    empty?:bool <- channel-empty? chan
-    break-unless empty?
-#?     $print [but channel is empty; relinquishing lock], 10/newline
-    # channel is empty; relinquish lock and give a writer the opportunity to
-    # add to it
-    reset lock
-    current-routine-is-blocked
-    <channel-read-empty>
-    switch  # avoid spinlocking
-    loop
-  }
-  current-routine-is-unblocked
-  # pull result off
-  full:num <- get *chan, first-full:offset
-  circular-buffer:&:@:_elem <- get *chan, data:offset
-  result <- index *circular-buffer, full
-  # clear the slot
-  empty:&:_elem <- new _elem:type
-  *circular-buffer <- put-index *circular-buffer, full, *empty
-  # mark its slot as empty
-  full <- add full, 1
-  {
-    # wrap full around to 0 if necessary
-    len:num <- length *circular-buffer
-    at-end?:bool <- greater-or-equal full, len
-    break-unless at-end?
-    full <- copy 0
-  }
-  # write back
-  *chan <- put *chan, first-full:offset, full
-#?   $print [relinquishing lock after reading], 10/newline
-  reset lock
-]
-
-# todo: create a notion of iterator and iterable so we can read/write whole
-# aggregates (arrays, lists, ..) of _elems at once.
-
-scenario channel-initialization [
-  run [
-    local-scope
-    source:&:source:num <- new-channel 3/capacity
-    chan:&:channel:num <- get *source, chan:offset
-    10:num/raw <- get *chan, first-full:offset
-    11:num/raw <- get *chan, first-free:offset
-  ]
-  memory-should-contain [
-    10 <- 0  # first-full
-    11 <- 0  # first-free
-  ]
-]
-
-scenario channel-write-increments-free [
-  local-scope
-  _, sink:&:sink:num <- new-channel 3/capacity
-  run [
-    sink <- write sink, 34
-    chan:&:channel:num <- get *sink, chan:offset
-    10:num/raw <- get *chan, first-full:offset
-    11:num/raw <- get *chan, first-free:offset
-  ]
-  memory-should-contain [
-    10 <- 0  # first-full
-    11 <- 1  # first-free
-  ]
-]
-
-scenario channel-read-increments-full [
-  local-scope
-  source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-  sink <- write sink, 34
-  run [
-    _, _, source <- read source
-    chan:&:channel:num <- get *source, chan:offset
-    10:num/raw <- get *chan, first-full:offset
-    11:num/raw <- get *chan, first-free:offset
-  ]
-  memory-should-contain [
-    10 <- 1  # first-full
-    11 <- 1  # first-free
-  ]
-]
-
-scenario channel-wrap [
-  local-scope
-  # channel with just 1 slot
-  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-  chan:&:channel:num <- get *source, chan:offset
-  # write and read a value
-  sink <- write sink, 34
-  _, _, source <- read source
-  run [
-    # first-free will now be 1
-    10:num/raw <- get *chan, first-free:offset
-    11:num/raw <- get *chan, first-free:offset
-    # write second value, verify that first-free wraps
-    sink <- write sink, 34
-    20:num/raw <- get *chan, first-free:offset
-    # read second value, verify that first-full wraps
-    _, _, source <- read source
-    30:num/raw <- get *chan, first-full:offset
-  ]
-  memory-should-contain [
-    10 <- 1  # first-free after first write
-    11 <- 1  # first-full after first read
-    20 <- 0  # first-free after second write, wrapped
-    30 <- 0  # first-full after second read, wrapped
-  ]
-]
-
-scenario channel-new-empty-not-full [
-  run [
-    local-scope
-    source:&:source:num <- new-channel 3/capacity
-    chan:&:channel:num <- get *source, chan:offset
-    10:bool/raw <- channel-empty? chan
-    11:bool/raw <- channel-full? chan
-  ]
-  memory-should-contain [
-    10 <- 1  # empty?
-    11 <- 0  # full?
-  ]
-]
-
-scenario channel-write-not-empty [
-  local-scope
-  source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-  chan:&:channel:num <- get *source, chan:offset
-  run [
-    sink <- write sink, 34
-    10:bool/raw <- channel-empty? chan
-    11:bool/raw <- channel-full? chan
-  ]
-  memory-should-contain [
-    10 <- 0  # empty?
-    11 <- 0  # full?
-  ]
-]
-
-scenario channel-write-full [
-  local-scope
-  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-  chan:&:channel:num <- get *source, chan:offset
-  run [
-    sink <- write sink, 34
-    10:bool/raw <- channel-empty? chan
-    11:bool/raw <- channel-full? chan
-  ]
-  memory-should-contain [
-    10 <- 0  # empty?
-    11 <- 1  # full?
-  ]
-]
-
-scenario channel-read-not-full [
-  local-scope
-  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-  chan:&:channel:num <- get *source, chan:offset
-  sink <- write sink, 34
-  run [
-    _, _, source <- read source
-    10:bool/raw <- channel-empty? chan
-    11:bool/raw <- channel-full? chan
-  ]
-  memory-should-contain [
-    10 <- 1  # empty?
-    11 <- 0  # full?
-  ]
-]
-
-scenario channel-clear [
-  local-scope
-  # create a channel with a few items
-  source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-  chan:&:channel:num <- get *sink, chan:offset
-  write sink, 30
-  write sink, 31
-  write sink, 32
-  run [
-    clear source
-    10:bool/raw <- channel-empty? chan
-  ]
-  memory-should-contain [
-    10 <- 1  # after the call to 'clear', the channel should be empty
-  ]
-]
-
-def clear in:&:source:_elem -> in:&:source:_elem [
-  local-scope
-  load-inputs
-  chan:&:channel:_elem <- get *in, chan:offset
-  {
-    empty?:bool <- channel-empty? chan
-    break-if empty?
-    _, _, in <- read in
-    loop
-  }
-]
-
-## cancelling channels
-
-# every channel comes with a boolean signifying if it's been closed
-# initially this boolean is false
-container channel:_elem [
-  closed?:bool
-]
-
-# a channel can be closed from either the source or the sink
-# both routines can modify the 'closed?' bit, but they can only ever set it, so this is a benign race
-def close x:&:source:_elem -> x:&:source:_elem [
-  local-scope
-  load-inputs
-  chan:&:channel:_elem <- get *x, chan:offset
-  *chan <- put *chan, closed?:offset, true
-]
-def close x:&:sink:_elem -> x:&:sink:_elem [
-  local-scope
-  load-inputs
-  chan:&:channel:_elem <- get *x, chan:offset
-  *chan <- put *chan, closed?:offset, true
-]
-
-# once a channel is closed from one side, no further operations are expected from that side
-# if a channel is closed for reading,
-#   no further writes will be let through
-# if a channel is closed for writing,
-#   future reads continue until the channel empties,
-#   then the channel is also closed for reading
-after <channel-write-initial> [
-  closed?:bool <- get *chan, closed?:offset
-  return-if closed?
-]
-after <channel-read-empty> [
-  closed?:bool <- get *chan, closed?:offset
-  {
-    break-unless closed?
-    empty-result:&:_elem <- new _elem:type
-    current-routine-is-unblocked
-    return *empty-result, true
-  }
-]
-
-## helpers
-
-# An empty channel has first-free and first-full both at the same value.
-def channel-empty? chan:&:channel:_elem -> result:bool [
-  local-scope
-  load-inputs
-  # return chan.first-full == chan.first-free
-  full:num <- get *chan, first-full:offset
-  free:num <- get *chan, first-free:offset
-  result <- equal full, free
-]
-
-# A full channel has first-free just before first-full, wasting one slot.
-# (Other alternatives: https://www.snellman.net/blog/archive/2016-12-13-ring-buffers)
-def channel-full? chan:&:channel:_elem -> result:bool [
-  local-scope
-  load-inputs
-  # tmp = chan.first-free + 1
-  tmp:num <- get *chan, first-free:offset
-  tmp <- add tmp, 1
-  {
-    # if tmp == chan.capacity, tmp = 0
-    len:num <- capacity chan
-    at-end?:bool <- greater-or-equal tmp, len
-    break-unless at-end?
-    tmp <- copy 0
-  }
-  # return chan.first-full == tmp
-  full:num <- get *chan, first-full:offset
-  result <- equal full, tmp
-]
-
-def capacity chan:&:channel:_elem -> result:num [
-  local-scope
-  load-inputs
-  q:&:@:_elem <- get *chan, data:offset
-  result <- length *q
-]
-
-## helpers for channels of characters in particular
-
-def buffer-lines in:&:source:char, buffered-out:&:sink:char -> buffered-out:&:sink:char, in:&:source:char [
-  local-scope
-  load-inputs
-  # repeat forever
-  eof?:bool <- copy false
-  {
-    line:&:buffer:char <- new-buffer 30
-    # read characters from 'in' until newline, copy into line
-    {
-      +next-character
-      c:char, eof?:bool, in <- read in
-      break-if eof?
-      # drop a character on backspace
-      {
-        # special-case: if it's a backspace
-        backspace?:bool <- equal c, 8
-        break-unless backspace?
-        # drop previous character
-        {
-          buffer-length:num <- get *line, length:offset
-          buffer-empty?:bool <- equal buffer-length, 0
-          break-if buffer-empty?
-          buffer-length <- subtract buffer-length, 1
-          *line <- put *line, length:offset, buffer-length
-        }
-        # and don't append this one
-        loop +next-character
-      }
-      # append anything else
-      line <- append line, c
-      line-done?:bool <- equal c, 10/newline
-      break-if line-done?
-      loop
-    }
-    # copy line into 'buffered-out'
-    i:num <- copy 0
-    line-contents:text <- get *line, data:offset
-    max:num <- get *line, length:offset
-    {
-      done?:bool <- greater-or-equal i, max
-      break-if done?
-      c:char <- index *line-contents, i
-      buffered-out <- write buffered-out, c
-      i <- add i, 1
-      loop
-    }
-    {
-      break-unless eof?
-      buffered-out <- close buffered-out
-      return
-    }
-    loop
-  }
-]
-
-scenario buffer-lines-blocks-until-newline [
-  run [
-    local-scope
-    source:&:source:char, sink:&:sink:char <- new-channel 10/capacity
-    _, buffered-stdin:&:sink:char/buffered-stdin <- new-channel 10/capacity
-    buffered-chan:&:channel:char <- get *buffered-stdin, chan:offset
-    empty?:bool <- channel-empty? buffered-chan
-    assert empty?, [ 
-F buffer-lines-blocks-until-newline: channel should be empty after init]
-    # buffer stdin into buffered-stdin, try to read from buffered-stdin
-    buffer-routine:num <- start-running buffer-lines, source, buffered-stdin
-    wait-for-routine-to-block buffer-routine
-    empty? <- channel-empty? buffered-chan
-    assert empty?:bool, [ 
-F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up]
-    # write 'a'
-    sink <- write sink, 97/a
-    restart buffer-routine
-    wait-for-routine-to-block buffer-routine
-    empty? <- channel-empty? buffered-chan
-    assert empty?:bool, [ 
-F buffer-lines-blocks-until-newline: channel should be empty after writing 'a']
-    # write 'b'
-    sink <- write sink, 98/b
-    restart buffer-routine
-    wait-for-routine-to-block buffer-routine
-    empty? <- channel-empty? buffered-chan
-    assert empty?:bool, [ 
-F buffer-lines-blocks-until-newline: channel should be empty after writing 'b']
-    # write newline
-    sink <- write sink, 10/newline
-    restart buffer-routine
-    wait-for-routine-to-block buffer-routine
-    empty? <- channel-empty? buffered-chan
-    data-emitted?:bool <- not empty?
-    assert data-emitted?, [ 
-F buffer-lines-blocks-until-newline: channel should contain data after writing newline]
-    trace 1, [test], [reached end]
-  ]
-  trace-should-contain [
-    test: reached end
-  ]
-]
-
-def drain source:&:source:char -> result:text, source:&:source:char [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 30
-  {
-    c:char, done?:bool <- read source
-    break-if done?
-    buf <- append buf, c
-    loop
-  }
-  result <- buffer-to-array buf
-]
diff --git a/archive/2.vm/076continuation.cc b/archive/2.vm/076continuation.cc
deleted file mode 100644
index 670fef2f..00000000
--- a/archive/2.vm/076continuation.cc
+++ /dev/null
@@ -1,406 +0,0 @@
-//: Continuations are a powerful primitive for constructing advanced kinds of
-//: control *policies* like back-tracking.
-//:
-//: In Mu, continuations are first-class and delimited, and are constructed
-//: out of two primitives:
-//:
-//:  * 'call-with-continuation-mark' marks the top of the call stack and then
-//:    calls the provided recipe.
-//:  * 'return-continuation-until-mark' copies the top of the stack
-//:    until the mark, and returns it as the result of
-//:    'call-with-continuation-mark' (which might be a distant ancestor on the
-//:    call stack; intervening calls don't return)
-//:
-//: The resulting slice of the stack can now be called just like a regular
-//: recipe.
-//:
-//: See the example programs continuation*.mu to get a sense for the
-//: possibilities.
-//:
-//: Refinements:
-//:  * You can call a single continuation multiple times, and it will preserve
-//:    the state of its local variables at each stack frame between calls.
-//:    The stack frames of a continuation are not destroyed until the
-//:    continuation goes out of scope. See continuation2.mu.
-//:  * 'return-continuation-until-mark' doesn't consume the mark, so you can
-//:    return multiple continuations based on a single mark. In combination
-//:    with the fact that 'return-continuation-until-mark' can return from
-//:    regular calls, just as long as there was an earlier call to
-//:    'call-with-continuation-mark', this gives us a way to create resumable
-//:    recipes. See continuation3.mu.
-//:  * 'return-continuation-until-mark' can take ingredients to return just
-//:    like other 'return' instructions. It just implicitly also returns a
-//:    continuation as the first result. See continuation4.mu.
-//:  * Conversely, you can pass ingredients to a continuation when calling it,
-//:    to make it available to products of 'return-continuation-until-mark'.
-//:    See continuation5.mu.
-//:  * There can be multiple continuation marks on the stack at once;
-//:    'call-with-continuation-mark' and 'return-continuation-until-mark' both
-//:    need to pass in a tag to coordinate on the correct mark. This allows us
-//:    to save multiple continuations for different purposes (say if one is
-//:    for exceptions) with overlapping stack frames. See exception.mu.
-//:
-//: Inspired by James and Sabry, "Yield: Mainstream delimited continuations",
-//: Workshop on the Theory and Practice of Delimited Continuations, 2011.
-//: https://www.cs.indiana.edu/~sabry/papers/yield.pdf
-//:
-//: Caveats:
-//:  * At the moment we can't statically type-check continuations. So we raise
-//:    runtime errors for a call that doesn't return a continuation when the
-//:    caller expects, or one that returns a continuation when the caller
-//:    doesn't expect it. This shouldn't cause memory corruption, though.
-//:    There should still be no way to lookup addresses that aren't allocated.
-
-:(before "End Mu Types Initialization")
-type_ordinal continuation = Type_ordinal["continuation"] = Next_type_ordinal++;
-Type[continuation].name = "continuation";
-
-//: A continuation can be called like a recipe.
-:(before "End is_mu_recipe Atom Cases(r)")
-if (r.type->name == "continuation") return true;
-
-//: However, it can't be type-checked like most recipes. Pretend it's like a
-//: header-less recipe.
-:(after "Begin Reagent->Recipe(r, recipe_header)")
-if (r.type->atom && r.type->name == "continuation") {
-  result_header.has_header = false;
-  return result_header;
-}
-
-:(code)
-void test_delimited_continuation() {
-  run(
-      "recipe main [\n"
-      "  1:continuation <- call-with-continuation-mark 233/mark, f, 77\n"  // 77 is an argument to f
-      "  2:num <- copy 5\n"
-      "  {\n"
-      "    2:num <- call 1:continuation, 2:num\n"  // jump to 'return-continuation-until-mark' below
-      "    3:bool <- greater-or-equal 2:num, 8\n"
-      "    break-if 3:bool\n"
-      "    loop\n"
-      "  }\n"
-      "]\n"
-      "recipe f [\n"
-      "  11:num <- next-ingredient\n"
-      "  12:num <- g 11:num\n"
-      "  return 12:num\n"
-      "]\n"
-      "recipe g [\n"
-      "  21:num <- next-ingredient\n"
-      "  22:num <- return-continuation-until-mark 233/mark\n"
-      "  23:num <- add 22:num, 1\n"
-      "  return 23:num\n"
-      "]\n"
-  );
-  // first call of 'g' executes the part before return-continuation-until-mark
-  CHECK_TRACE_CONTENTS(
-      // first call of 'g' executes the part before return-continuation-until-mark
-      "mem: storing 77 in location 21\n"
-      "run: {2: \"number\"} <- copy {5: \"literal\"}\n"
-      "mem: storing 5 in location 2\n"
-      // calls of the continuation execute the part after return-continuation-until-mark
-      "run: {2: \"number\"} <- call {1: \"continuation\"}, {2: \"number\"}\n"
-      "mem: storing 5 in location 22\n"
-      "mem: storing 6 in location 2\n"
-      "run: {2: \"number\"} <- call {1: \"continuation\"}, {2: \"number\"}\n"
-      "mem: storing 6 in location 22\n"
-      "mem: storing 7 in location 2\n"
-      "run: {2: \"number\"} <- call {1: \"continuation\"}, {2: \"number\"}\n"
-      "mem: storing 7 in location 22\n"
-      "mem: storing 8 in location 2\n"
-  );
-  // first call of 'g' does not execute the part after return-continuation-until-mark
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 77 in location 22");
-  // calls of the continuation don't execute the part before return-continuation-until-mark
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 5 in location 21");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 6 in location 21");
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 7 in location 21");
-  // termination
-  CHECK_TRACE_DOESNT_CONTAIN("mem: storing 9 in location 2");
-}
-
-:(before "End call Fields")
-int continuation_mark_tag;
-:(before "End call Constructor")
-continuation_mark_tag = 0;
-
-:(before "End Primitive Recipe Declarations")
-CALL_WITH_CONTINUATION_MARK,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["call-with-continuation-mark"] = CALL_WITH_CONTINUATION_MARK;
-:(before "End Primitive Recipe Checks")
-case CALL_WITH_CONTINUATION_MARK: {
-  if (SIZE(inst.ingredients) < 2) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires at least two ingredients: a mark number and a recipe to call\n" << end();
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CALL_WITH_CONTINUATION_MARK: {
-  // like call, but mark the current call as a 'base of continuation' call
-  // before pushing the next one on it
-  trace(Callstack_depth+1, "trace") << "delimited continuation; incrementing callstack depth to " << Callstack_depth << end();
-  ++Callstack_depth;
-  assert(Callstack_depth < Max_depth);
-  instruction/*copy*/ caller_instruction = current_instruction();
-  Current_routine->calls.front().continuation_mark_tag = current_instruction().ingredients.at(0).value;
-  Current_routine->calls.push_front(call(ingredients.at(1).at(0)));
-  // drop the mark
-  caller_instruction.ingredients.erase(caller_instruction.ingredients.begin());
-  ingredients.erase(ingredients.begin());
-  // drop the callee
-  caller_instruction.ingredients.erase(caller_instruction.ingredients.begin());
-  ingredients.erase(ingredients.begin());
-  finish_call_housekeeping(caller_instruction, ingredients);
-  continue;
-}
-
-:(code)
-void test_next_ingredient_inside_continuation() {
-  run(
-      "recipe main [\n"
-      "  call-with-continuation-mark 233/mark, f, true\n"
-      "]\n"
-      "recipe f [\n"
-      "  10:bool <- next-input\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 10\n"
-  );
-}
-
-void test_delimited_continuation_out_of_recipe_variable() {
-  run(
-      "recipe main [\n"
-      "  x:recipe <- copy f\n"
-      "  call-with-continuation-mark 233/mark, x, true\n"
-      "]\n"
-      "recipe f [\n"
-      "  10:bool <- next-input\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 10\n"
-  );
-}
-
-//: save the slice of current call stack until the 'call-with-continuation-mark'
-//: call, and return it as the result.
-//: todo: implement delimited continuations in Mu's memory
-:(before "End Types")
-struct delimited_continuation {
-  call_stack frames;
-  int nrefs;
-  delimited_continuation(call_stack::iterator begin, call_stack::iterator end) :frames(call_stack(begin, end)), nrefs(0) {}
-};
-:(before "End Globals")
-map<long long int, delimited_continuation> Delimited_continuation;
-long long int Next_delimited_continuation_id = 1;  // 0 is null just like an address
-:(before "End Reset")
-Delimited_continuation.clear();
-Next_delimited_continuation_id = 1;
-
-:(before "End Primitive Recipe Declarations")
-RETURN_CONTINUATION_UNTIL_MARK,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["return-continuation-until-mark"] = RETURN_CONTINUATION_UNTIL_MARK;
-:(before "End Primitive Recipe Checks")
-case RETURN_CONTINUATION_UNTIL_MARK: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' requires at least one ingredient: a mark tag (number)\n" << end();
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RETURN_CONTINUATION_UNTIL_MARK: {
-  // I don't know how to think about next-ingredient in combination with
-  // continuations, so seems cleaner to just kill it. Functions have to read
-  // their inputs before ever returning a continuation.
-  Current_routine->calls.front().ingredient_atoms.clear();
-  Current_routine->calls.front().next_ingredient_to_process = 0;
-  // copy the current call stack until the most recent marked call
-  call_stack::iterator find_base_of_continuation(call_stack&, int);  // manual prototype containing '::'
-  call_stack::iterator base = find_base_of_continuation(Current_routine->calls, /*mark tag*/current_instruction().ingredients.at(0).value);
-  if (base == Current_routine->calls.end()) {
-    raise << maybe(current_recipe_name()) << "couldn't find a 'call-with-continuation-mark' to return to with tag " << current_instruction().ingredients.at(0).original_string << '\n' << end();
-    raise << maybe(current_recipe_name()) << "call stack:\n" << end();
-    for (call_stack::iterator p = Current_routine->calls.begin();  p != Current_routine->calls.end();  ++p)
-      raise << maybe(current_recipe_name()) << "  " << get(Recipe, p->running_recipe).name << '\n' << end();
-    break;
-  }
-  trace(Callstack_depth+1, "run") << "creating continuation " << Next_delimited_continuation_id << end();
-  put(Delimited_continuation, Next_delimited_continuation_id, delimited_continuation(Current_routine->calls.begin(), base));
-  while (Current_routine->calls.begin() != base) {
-    --Callstack_depth;
-    assert(Callstack_depth >= 0);
-    Current_routine->calls.pop_front();
-  }
-  // return it as the result of the marked call
-  products.resize(1);
-  products.at(0).push_back(Next_delimited_continuation_id);
-  // return any other ingredients passed in
-  copy(/*skip mark tag*/++ingredients.begin(), ingredients.end(), inserter(products, products.end()));
-  ++Next_delimited_continuation_id;
-  break;  // continue to process rest of marked call
-}
-
-:(code)
-call_stack::iterator find_base_of_continuation(call_stack& c, int mark_tag) {
-  for (call_stack::iterator p = c.begin(); p != c.end(); ++p)
-    if (p->continuation_mark_tag == mark_tag) return p;
-  return c.end();
-}
-
-//: overload 'call' for continuations
-:(after "Begin Call")
-if (is_mu_continuation(current_instruction().ingredients.at(0))) {
-  // copy multiple calls on to current call stack
-  assert(scalar(ingredients.at(0)));
-  trace(Callstack_depth+1, "run") << "calling continuation " << ingredients.at(0).at(0) << end();
-  if (!contains_key(Delimited_continuation, ingredients.at(0).at(0)))
-    raise << maybe(current_recipe_name()) << "no such delimited continuation " << current_instruction().ingredients.at(0).original_string << '\n' << end();
-  const call_stack& new_frames = get(Delimited_continuation, ingredients.at(0).at(0)).frames;
-  for (call_stack::const_reverse_iterator p = new_frames.rbegin(); p != new_frames.rend(); ++p)
-    Current_routine->calls.push_front(*p);
-  trace(Callstack_depth+1, "trace") << "calling delimited continuation; growing callstack depth to " << Callstack_depth+SIZE(new_frames) << end();
-  Callstack_depth += SIZE(new_frames);
-  assert(Callstack_depth < Max_depth);
-  // no call housekeeping; continuations don't support next-ingredient
-  copy(/*drop continuation*/++ingredients.begin(), ingredients.end(), inserter(products, products.begin()));
-  break;  // record results of resuming 'return-continuation-until-mark' instruction
-}
-
-:(code)
-void test_continuations_can_return_values() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  k:continuation, 1:num/raw <- call-with-continuation-mark 233/mark, f\n"
-      "]\n"
-      "def f [\n"
-      "  local-scope\n"
-      "  g\n"
-      "]\n"
-      "def g [\n"
-      "  local-scope\n"
-      "  return-continuation-until-mark 233/mark, 34\n"
-      "  stash [continuation called]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_continuations_continue_to_matching_mark() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  k:continuation, 1:num/raw <- call-with-continuation-mark 233/mark, f\n"
-      "  add 1, 1\n"
-      "]\n"
-      "def f [\n"
-      "  local-scope\n"
-      "  k2:continuation <- call-with-continuation-mark 234/mark, g\n"
-      "  add 2, 2\n"
-      "]\n"
-      "def g [\n"
-      "  local-scope\n"
-      "  return-continuation-until-mark 233/mark, 34\n"
-      "  stash [continuation called]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "run: add {1: \"literal\"}, {1: \"literal\"}\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("run: add {2: \"literal\"}, {2: \"literal\"}");
-}
-
-//: Allow shape-shifting recipes to return continuations.
-
-void test_call_shape_shifting_recipe_with_continuation_mark() {
-  run(
-      "def main [\n"
-      "  1:num <- call-with-continuation-mark 233/mark, f, 34\n"
-      "]\n"
-      "def f x:_elem -> y:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  y <- copy x\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-:(before "End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases")
-if (inst.name == "call-with-continuation-mark") {
-  if (SIZE(inst.ingredients) > 1 && is_recipe_literal(inst.ingredients.at(/*skip mark*/1))) {
-  resolve_indirect_continuation_call(r, index, inst, caller_recipe);
-  return;
-  }
-}
-:(code)
-void resolve_indirect_continuation_call(const recipe_ordinal r, int index, instruction& inst, const recipe& caller_recipe) {
-  instruction inst2;
-  inst2.name = inst.ingredients.at(/*skip mark*/1).name;
-  for (int i = /*skip mark and recipe*/2;  i < SIZE(inst.ingredients);  ++i)
-    inst2.ingredients.push_back(inst.ingredients.at(i));
-  for (int i = /*skip continuation*/1;  i < SIZE(inst.products);  ++i)
-    inst2.products.push_back(inst.products.at(i));
-  resolve_ambiguous_call(r, index, inst2, caller_recipe);
-  inst.ingredients.at(/*skip mark*/1).name = inst2.name;
-  inst.ingredients.at(/*skip mark*/1).set_value(get(Recipe_ordinal, inst2.name));
-}
-
-void test_call_shape_shifting_recipe_with_continuation_mark_and_no_outputs() {
-  run(
-      "def main [\n"
-      "  1:continuation <- call-with-continuation-mark 233/mark, f, 34\n"
-      "]\n"
-      "def f x:_elem [\n"
-      "  local-scope\n"
-      "  load-ingredients\n"
-      "  return-continuation-until-mark 233/mark\n"
-      "]\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-void test_continuation1() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  k:continuation <- call-with-continuation-mark 233/mark, create-yielder\n"
-      "  10:num/raw <- call k\n"
-      "]\n"
-      "def create-yielder -> n:num [\n"
-      "  local-scope\n"
-      "  load-inputs\n"
-      "  return-continuation-until-mark 233/mark\n"
-      "  return 1\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 1 in location 10\n"
-  );
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-:(code)
-bool is_mu_continuation(reagent/*copy*/ x) {
-  canonize_type(x);
-  return x.type && x.type->atom && x.type->value == get(Type_ordinal, "continuation");
-}
-
-// helper for debugging
-void dump(const int continuation_id) {
-  if (!contains_key(Delimited_continuation, continuation_id)) {
-    raise << "missing delimited continuation: " << continuation_id << '\n' << end();
-    return;
-  }
-  delimited_continuation& curr = get(Delimited_continuation, continuation_id);
-  dump(curr.frames);
-}
diff --git a/archive/2.vm/080display.cc b/archive/2.vm/080display.cc
deleted file mode 100644
index 6bf8e51d..00000000
--- a/archive/2.vm/080display.cc
+++ /dev/null
@@ -1,462 +0,0 @@
-//: Take raw control of the text-mode display and console, putting it in
-//: 'console' mode rather than the usual automatically-scrolling 'typewriter'
-//: mode.
-
-//:: Display management
-
-:(before "End Globals")
-int Display_row = 0;
-int Display_column = 0;
-
-:(before "End Includes")
-#define CHECK_SCREEN \
-    if (!tb_is_active()) { \
-      if (Run_tests) \
-        raise << maybe(current_recipe_name()) << "tried to print to real screen in a test!\n" << end(); \
-      else \
-        raise << maybe(current_recipe_name()) << "tried to print to real screen before 'open-console' or after 'close-console'\n" << end(); \
-      break; \
-    }
-#define CHECK_CONSOLE \
-    if (!tb_is_active()) { \
-      if (Run_tests) \
-        raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse in a test!\n" << end(); \
-      else \
-        raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse before 'open-console' or after 'close-console'\n" << end(); \
-      break; \
-    }
-
-:(before "End Primitive Recipe Declarations")
-OPEN_CONSOLE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "open-console", OPEN_CONSOLE);
-:(before "End Primitive Recipe Checks")
-case OPEN_CONSOLE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case OPEN_CONSOLE: {
-  tb_init();
-  std::setvbuf(stdout, NULL, _IONBF, 0);  // disable buffering in cout
-  Display_row = Display_column = 0;
-  int width = tb_width();
-  int height = tb_height();
-  if (width > 222 || height > 222) {
-    if (width > 222)
-      raise << "sorry, Mu doesn't support windows wider than 222 characters in console mode. Please resize your window.\n" << end();
-    if (height > 222)
-      raise << "sorry, Mu doesn't support windows taller than 222 characters in console mode. Please resize your window.\n" << end();
-    exit(1);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CLOSE_CONSOLE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "close-console", CLOSE_CONSOLE);
-:(before "End Primitive Recipe Checks")
-case CLOSE_CONSOLE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CLOSE_CONSOLE: {
-  tb_shutdown();
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CLEAR_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "clear-display", CLEAR_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case CLEAR_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CLEAR_DISPLAY: {
-  CHECK_SCREEN;
-  tb_clear();
-  Display_row = Display_column = 0;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-PRINT_CHARACTER_TO_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "print-character-to-display", PRINT_CHARACTER_TO_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case PRINT_CHARACTER_TO_DISPLAY: {
-  if (inst.ingredients.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'print-character-to-display' requires at least one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'print-character-to-display' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.ingredients) > 1) {
-    if (!is_mu_number(inst.ingredients.at(1))) {
-      raise << maybe(get(Recipe, r).name) << "second ingredient of 'print-character-to-display' should be a foreground color number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-      break;
-    }
-  }
-  if (SIZE(inst.ingredients) > 2) {
-    if (!is_mu_number(inst.ingredients.at(2))) {
-      raise << maybe(get(Recipe, r).name) << "third ingredient of 'print-character-to-display' should be a background color number, but got '" << inst.ingredients.at(2).original_string << "'\n" << end();
-      break;
-    }
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case PRINT_CHARACTER_TO_DISPLAY: {
-  CHECK_SCREEN;
-  int h=tb_height(), w=tb_width();
-  int height = (h >= 0) ? h : 0;
-  int width = (w >= 0) ? w : 0;
-  int c = ingredients.at(0).at(0);
-  int color = TB_WHITE;
-  if (SIZE(ingredients) > 1) {
-    color = ingredients.at(1).at(0);
-  }
-  int bg_color = TB_BLACK;
-  if (SIZE(ingredients) > 2) {
-    bg_color = ingredients.at(2).at(0);
-    if (bg_color == 0) bg_color = TB_BLACK;
-  }
-  tb_print(c, color, bg_color);
-  // track row and column, mimicking what happens on screen
-  if (c == '\n') {
-    if (Display_row < height-1) ++Display_row;  // otherwise we scroll and Display_row remains unchanged
-  }
-  else if (c == '\r') {
-    Display_column = 0;
-  }
-  else if (c == '\b') {
-    if (Display_column > 0) --Display_column;
-  }
-  else {
-    ++Display_column;
-    if (Display_column >= width) {
-      Display_column = 0;
-      if (Display_row < height-1) ++Display_row;
-    }
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CURSOR_POSITION_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "cursor-position-on-display", CURSOR_POSITION_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case CURSOR_POSITION_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CURSOR_POSITION_ON_DISPLAY: {
-  CHECK_SCREEN;
-  products.resize(2);
-  products.at(0).push_back(Display_row);
-  products.at(1).push_back(Display_column);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MOVE_CURSOR_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "move-cursor-on-display", MOVE_CURSOR_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case MOVE_CURSOR_ON_DISPLAY: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'move-cursor-on-display' requires two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'move-cursor-on-display' should be a row number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'move-cursor-on-display' should be a column number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MOVE_CURSOR_ON_DISPLAY: {
-  CHECK_SCREEN;
-  Display_row = ingredients.at(0).at(0);
-  Display_column = ingredients.at(1).at(0);
-  tb_set_cursor(Display_column, Display_row);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MOVE_CURSOR_DOWN_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "move-cursor-down-on-display", MOVE_CURSOR_DOWN_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case MOVE_CURSOR_DOWN_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MOVE_CURSOR_DOWN_ON_DISPLAY: {
-  CHECK_SCREEN;
-  int h=tb_height();
-  int height = (h >= 0) ? h : 0;
-  if (Display_row < height-1) {
-    ++Display_row;
-    tb_set_cursor(Display_column, Display_row);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MOVE_CURSOR_UP_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "move-cursor-up-on-display", MOVE_CURSOR_UP_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case MOVE_CURSOR_UP_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MOVE_CURSOR_UP_ON_DISPLAY: {
-  CHECK_SCREEN;
-  if (Display_row > 0) {
-    --Display_row;
-    tb_set_cursor(Display_column, Display_row);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MOVE_CURSOR_RIGHT_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "move-cursor-right-on-display", MOVE_CURSOR_RIGHT_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
-  CHECK_SCREEN;
-  int w=tb_width();
-  int width = (w >= 0) ? w : 0;
-  if (Display_column < width-1) {
-    ++Display_column;
-    tb_set_cursor(Display_column, Display_row);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-MOVE_CURSOR_LEFT_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "move-cursor-left-on-display", MOVE_CURSOR_LEFT_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case MOVE_CURSOR_LEFT_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case MOVE_CURSOR_LEFT_ON_DISPLAY: {
-  CHECK_SCREEN;
-  if (Display_column > 0) {
-    --Display_column;
-    tb_set_cursor(Display_column, Display_row);
-  }
-  break;
-}
-
-//: as a convenience, make $print mostly work in console mode
-:(before "End $print 10/newline Special-cases")
-else if (tb_is_active()) {
-  move_cursor_to_start_of_next_line_on_display();
-}
-:(code)
-void move_cursor_to_start_of_next_line_on_display() {
-  if (Display_row < tb_height()-1) ++Display_row;
-  else Display_row = 0;
-  Display_column = 0;
-  tb_set_cursor(Display_column, Display_row);
-}
-
-:(before "End Primitive Recipe Declarations")
-DISPLAY_WIDTH,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "display-width", DISPLAY_WIDTH);
-:(before "End Primitive Recipe Checks")
-case DISPLAY_WIDTH: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case DISPLAY_WIDTH: {
-  CHECK_SCREEN;
-  products.resize(1);
-  products.at(0).push_back(tb_width());
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-DISPLAY_HEIGHT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "display-height", DISPLAY_HEIGHT);
-:(before "End Primitive Recipe Checks")
-case DISPLAY_HEIGHT: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case DISPLAY_HEIGHT: {
-  CHECK_SCREEN;
-  products.resize(1);
-  products.at(0).push_back(tb_height());
-  break;
-}
-
-//:: Keyboard/mouse management
-
-:(before "End Primitive Recipe Declarations")
-WAIT_FOR_SOME_INTERACTION,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "wait-for-some-interaction", WAIT_FOR_SOME_INTERACTION);
-:(before "End Primitive Recipe Checks")
-case WAIT_FOR_SOME_INTERACTION: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case WAIT_FOR_SOME_INTERACTION: {
-  CHECK_SCREEN;
-  tb_event event;
-  tb_poll_event(&event);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CHECK_FOR_INTERACTION,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "check-for-interaction", CHECK_FOR_INTERACTION);
-:(before "End Primitive Recipe Checks")
-case CHECK_FOR_INTERACTION: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CHECK_FOR_INTERACTION: {
-  CHECK_CONSOLE;
-  products.resize(2);  // result and status
-  tb_event event;
-  int event_type = tb_peek_event(&event, 5/*ms*/);
-  if (event_type == TB_EVENT_KEY && event.ch) {
-    products.at(0).push_back(/*text event*/0);
-    products.at(0).push_back(event.ch);
-    products.at(0).push_back(0);
-    products.at(0).push_back(0);
-    products.at(1).push_back(/*found*/true);
-    break;
-  }
-  // treat keys within ascii as unicode characters
-  if (event_type == TB_EVENT_KEY && event.key < 0xff) {
-    products.at(0).push_back(/*text event*/0);
-    if (event.key == TB_KEY_CTRL_C) exit(1);
-    if (event.key == TB_KEY_BACKSPACE2) event.key = TB_KEY_BACKSPACE;
-    if (event.key == TB_KEY_CARRIAGE_RETURN) event.key = TB_KEY_NEWLINE;
-    products.at(0).push_back(event.key);
-    products.at(0).push_back(0);
-    products.at(0).push_back(0);
-    products.at(1).push_back(/*found*/true);
-    break;
-  }
-  // keys outside ascii aren't unicode characters but arbitrary termbox inventions
-  if (event_type == TB_EVENT_KEY) {
-    products.at(0).push_back(/*keycode event*/1);
-    products.at(0).push_back(event.key);
-    products.at(0).push_back(0);
-    products.at(0).push_back(0);
-    products.at(1).push_back(/*found*/true);
-    break;
-  }
-  if (event_type == TB_EVENT_MOUSE) {
-    products.at(0).push_back(/*touch event*/2);
-    products.at(0).push_back(event.key);  // which button, etc.
-    products.at(0).push_back(event.y);  // row
-    products.at(0).push_back(event.x);  // column
-    products.at(1).push_back(/*found*/true);
-    break;
-  }
-  if (event_type == TB_EVENT_RESIZE) {
-    products.at(0).push_back(/*resize event*/3);
-    products.at(0).push_back(event.w);  // width
-    products.at(0).push_back(event.h);  // height
-    products.at(0).push_back(0);
-    products.at(1).push_back(/*found*/true);
-    break;
-  }
-  assert(event_type == 0);
-  products.at(0).push_back(0);
-  products.at(0).push_back(0);
-  products.at(0).push_back(0);
-  products.at(0).push_back(0);
-  products.at(1).push_back(/*found*/false);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-INTERACTIONS_LEFT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "interactions-left?", INTERACTIONS_LEFT);
-:(before "End Primitive Recipe Checks")
-case INTERACTIONS_LEFT: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case INTERACTIONS_LEFT: {
-  CHECK_CONSOLE;
-  products.resize(1);
-  products.at(0).push_back(tb_event_ready());
-  break;
-}
-
-//: hacks to make text-mode apps more responsive under Unix
-
-:(before "End Primitive Recipe Declarations")
-CLEAR_LINE_ON_DISPLAY,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "clear-line-on-display", CLEAR_LINE_ON_DISPLAY);
-:(before "End Primitive Recipe Checks")
-case CLEAR_LINE_ON_DISPLAY: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CLEAR_LINE_ON_DISPLAY: {
-  CHECK_SCREEN;
-  int width = tb_width();
-  for (int x = Display_column;  x < width;  ++x)
-    tb_print(' ', TB_WHITE, TB_BLACK);
-  tb_set_cursor(Display_column, Display_row);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-CLEAR_DISPLAY_FROM,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "clear-display-from", CLEAR_DISPLAY_FROM);
-:(before "End Primitive Recipe Checks")
-case CLEAR_DISPLAY_FROM: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case CLEAR_DISPLAY_FROM: {
-  CHECK_SCREEN;
-  // todo: error checking
-  int row = ingredients.at(0).at(0);
-  int column = ingredients.at(1).at(0);
-  int left = ingredients.at(2).at(0);
-  int right = ingredients.at(3).at(0);
-  int height=tb_height();
-  for (/*nada*/;  row < height;  ++row, column=left) {  // start column from left in every inner loop except first
-    tb_set_cursor(column, row);
-    for (/*nada*/;  column <= right;  ++column)
-      tb_print(' ', TB_WHITE, TB_BLACK);
-  }
-  tb_set_cursor(Display_column, Display_row);
-  break;
-}
diff --git a/archive/2.vm/081print.mu b/archive/2.vm/081print.mu
deleted file mode 100644
index 98ea0f21..00000000
--- a/archive/2.vm/081print.mu
+++ /dev/null
@@ -1,914 +0,0 @@
-# Wrappers around print primitives that take a 'screen' object and are thus
-# easier to test.
-#
-# Screen objects are intended to exactly mimic the behavior of traditional
-# terminals. Moving a cursor too far right wraps it to the next line,
-# scrolling if necessary. The details are subtle:
-#
-# a) Rows can take unbounded values. When printing, large values for the row
-# saturate to the bottom row (because scrolling).
-#
-# b) If you print to a square (row, right) on the right margin, the cursor
-# position depends on whether 'row' is in range. If it is, the new cursor
-# position is (row+1, 0). If it isn't, the new cursor position is (row, 0).
-# Because scrolling.
-
-container screen [
-  num-rows:num
-  num-columns:num
-  cursor-row:num
-  cursor-column:num
-  data:&:@:screen-cell  # capacity num-rows*num-columns
-  pending-scroll?:bool
-  top-idx:num  # index inside data that corresponds to top-left of screen
-               # modified on scroll, wrapping around to the top of data
-]
-
-container screen-cell [
-  contents:char
-  color:num
-]
-
-def new-fake-screen w:num, h:num -> result:&:screen [
-  local-scope
-  load-inputs
-  result <- new screen:type
-  non-zero-width?:bool <- greater-than w, 0
-  assert non-zero-width?, [screen can't have zero width]
-  non-zero-height?:bool <- greater-than h, 0
-  assert non-zero-height?, [screen can't have zero height]
-  bufsize:num <- multiply w, h
-  data:&:@:screen-cell <- new screen-cell:type, bufsize
-  *result <- merge h/num-rows, w/num-columns, 0/cursor-row, 0/cursor-column, data, false/pending-scroll?, 0/top-idx
-  result <- clear-screen result
-]
-
-def clear-screen screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [clear-screen]
-  {
-    break-if screen
-    # real screen
-    clear-display
-    return
-  }
-  # fake screen
-  buf:&:@:screen-cell <- get *screen, data:offset
-  max:num <- length *buf
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, max
-    break-if done?
-    curr:screen-cell <- merge 0/empty, 7/white
-    *buf <- put-index *buf, i, curr
-    i <- add i, 1
-    loop
-  }
-  # reset cursor
-  *screen <- put *screen, cursor-row:offset, 0
-  *screen <- put *screen, cursor-column:offset, 0
-  *screen <- put *screen, top-idx:offset, 0
-]
-
-def fake-screen-is-empty? screen:&:screen -> result:bool [
-  local-scope
-  load-inputs
-#?   stash [fake-screen-is-empty?]
-  return-unless screen, true  # do nothing for real screens
-  buf:&:@:screen-cell <- get *screen, data:offset
-  i:num <- copy 0
-  len:num <- length *buf
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    curr:screen-cell <- index *buf, i
-    curr-contents:char <- get curr, contents:offset
-    i <- add i, 1
-    loop-unless curr-contents
-    # not 0
-    return false
-  }
-  return true
-]
-
-def print screen:&:screen, c:char -> screen:&:screen [
-  local-scope
-  load-inputs
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 7/white
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  c2:num <- character-to-code c
-  trace 90, [print-character], c2
-  {
-    # real screen
-    break-if screen
-    print-character-to-display c, color, bg-color
-    return
-  }
-  # fake screen
-  # (handle special cases exactly like in the real screen)
-  width:num <- get *screen, num-columns:offset
-  height:num <- get *screen, num-rows:offset
-  capacity:num <- multiply width, height
-  row:num <- get *screen, cursor-row:offset
-  column:num <- get *screen, cursor-column:offset
-  buf:&:@:screen-cell <- get *screen, data:offset
-  # some potentially slow sanity checks for preconditions {
-  # eliminate fractions from column and row
-  row <- round row
-  column <- round column
-  # if cursor is past left margin (error), reset to left margin
-  {
-    too-far-left?:bool <- lesser-than column, 0
-    break-unless too-far-left?
-    column <- copy 0
-    *screen <- put *screen, cursor-column:offset, column
-  }
-  # if cursor is at or past right margin, wrap
-  {
-    at-right?:bool <- greater-or-equal column, width
-    break-unless at-right?
-    column <- copy 0
-    *screen <- put *screen, cursor-column:offset, column
-    row <- add row, 1
-    *screen <- put *screen, cursor-row:offset, row
-  }
-  # }
-  # if there's a pending scroll, perform it
-  {
-    pending-scroll?:bool <- get *screen, pending-scroll?:offset
-    break-unless pending-scroll?
-#?     stash [scroll]
-    scroll-fake-screen screen
-    *screen <- put *screen, pending-scroll?:offset, false
-  }
-#?     $print [print-character (], row, [, ], column, [): ], c, 10/newline
-  # special-case: newline
-  {
-    newline?:bool <- equal c, 10/newline
-    break-unless newline?
-    cursor-down-on-fake-screen screen  # doesn't modify column
-    return
-  }
-  # special-case: linefeed
-  {
-    linefeed?:bool <- equal c, 13/linefeed
-    break-unless linefeed?
-    *screen <- put *screen, cursor-column:offset, 0
-    return
-  }
-  # special-case: backspace
-  # moves cursor left but does not erase
-  {
-    backspace?:bool <- equal c, 8/backspace
-    break-unless backspace?
-    {
-      break-unless column
-      column <- subtract column, 1
-      *screen <- put *screen, cursor-column:offset, column
-    }
-    return
-  }
-  # save character in fake screen
-  top-idx:num <- get *screen, top-idx:offset
-  index:num <- data-index row, column, width, height, top-idx
-  cursor:screen-cell <- merge c, color
-  *buf <- put-index *buf, index, cursor
-  # move cursor to next character, wrapping as necessary
-  # however, don't scroll just yet
-  column <- add column, 1
-  {
-    past-right?:bool <- greater-or-equal column, width
-    break-unless past-right?
-    column <- copy 0
-    row <- add row, 1
-    past-bottom?:bool <- greater-or-equal row, height
-    break-unless past-bottom?
-    # queue up a scroll
-#?     stash [pending scroll]
-    *screen <- put *screen, pending-scroll?:offset, true
-    row <- subtract row, 1  # update cursor as if scroll already happened
-  }
-  *screen <- put *screen, cursor-row:offset, row
-  *screen <- put *screen, cursor-column:offset, column
-]
-
-def cursor-down-on-fake-screen screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-down]
-  row:num <- get *screen, cursor-row:offset
-  height:num <- get *screen, num-rows:offset
-  bottom:num <- subtract height, 1
-  at-bottom?:bool <- greater-or-equal row, bottom
-  {
-    break-if at-bottom?
-    row <- add row, 1
-    *screen <- put *screen, cursor-row:offset, row
-  }
-  {
-    break-unless at-bottom?
-    scroll-fake-screen screen  # does not modify row
-  }
-]
-
-def scroll-fake-screen screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [scroll-fake-screen]
-  width:num <- get *screen, num-columns:offset
-  height:num <- get *screen, num-rows:offset
-  buf:&:@:screen-cell <- get *screen, data:offset
-  # clear top line and 'rotate' it to the bottom
-  top-idx:num <- get *screen, top-idx:offset  # 0 <= top-idx < len(buf)
-  next-top-idx:num <- add top-idx, width  # 0 <= next-top-idx <= len(buf)
-  empty-cell:screen-cell <- merge 0/empty, 7/white
-  {
-    done?:bool <- greater-or-equal top-idx, next-top-idx
-    break-if done?
-    put-index *buf, top-idx, empty-cell
-    top-idx <- add top-idx, 1
-    # no modulo; top-idx is always a multiple of width,
-    # so it can never wrap around inside this loop
-    loop
-  }
-  # top-idx now same as next-top-idx; wrap around if necessary
-  capacity:num <- multiply width, height
-  _, top-idx <- divide-with-remainder, top-idx, capacity
-  *screen <- put *screen, top-idx:offset, top-idx
-]
-
-# translate from screen (row, column) coordinates to an index into data
-# while accounting for scrolling (sliding top-idx)
-def data-index row:num, column:num, width:num, height:num, top-idx:num -> result:num [
-  local-scope
-  load-inputs
-  {
-    overflow?:bool <- greater-or-equal row, height
-    break-unless overflow?
-    row <- subtract height, 1
-  }
-  result <- multiply width, row
-  result <- add result, column, top-idx
-  capacity:num <- multiply width, height
-  _, result <- divide-with-remainder result, capacity
-]
-
-scenario print-character-at-top-left [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  run [
-    a:char <- copy 97/a
-    fake-screen <- print fake-screen, a:char
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    1:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    1 <- 6  # width*height
-    2 <- 97  # 'a'
-    3 <- 7  # white
-    # rest of screen is empty
-    4 <- 0
-  ]
-]
-
-scenario print-character-at-fractional-coordinate [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  a:char <- copy 97/a
-  run [
-    move-cursor fake-screen, 0.5, 0
-    fake-screen <- print fake-screen, a:char
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    1:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    1 <- 6  # width*height
-    2 <- 97  # 'a'
-    3 <- 7  # white
-    # rest of screen is empty
-    4 <- 0
-  ]
-]
-
-scenario print-character-in-color [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  run [
-    a:char <- copy 97/a
-    fake-screen <- print fake-screen, a:char, 1/red
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    1:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    1 <- 6  # width*height
-    2 <- 97  # 'a'
-    3 <- 1  # red
-    # rest of screen is empty
-    4 <- 0
-  ]
-]
-
-scenario print-backspace-character [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  run [
-    backspace:char <- copy 8/backspace
-    fake-screen <- print fake-screen, backspace
-    10:num/raw <- get *fake-screen, cursor-column:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    11:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    10 <- 0  # cursor column
-    11 <- 6  # width*height
-    12 <- 97  # still 'a'
-    13 <- 7  # white
-    # rest of screen is empty
-    14 <- 0
-  ]
-]
-
-scenario print-extra-backspace-character [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  run [
-    backspace:char <- copy 8/backspace
-    fake-screen <- print fake-screen, backspace
-    fake-screen <- print fake-screen, backspace  # cursor already at left margin
-    1:num/raw <- get *fake-screen, cursor-column:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    3:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    1 <- 0  # cursor column
-    3 <- 6  # width*height
-    4 <- 97  # still 'a'
-    5 <- 7  # white
-    # rest of screen is empty
-    6 <- 0
-  ]
-]
-
-scenario print-character-at-right-margin [
-  # fill top row of screen with text
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 2/width, 2/height
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  b:char <- copy 98/b
-  fake-screen <- print fake-screen, b
-  run [
-    # cursor now at next row
-    c:char <- copy 99/c
-    fake-screen <- print fake-screen, c
-    10:num/raw <- get *fake-screen, cursor-row:offset
-    11:num/raw <- get *fake-screen, cursor-column:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    12:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    10 <- 1  # cursor row
-    11 <- 1  # cursor column
-    12 <- 4  # width*height
-    13 <- 97  # 'a'
-    14 <- 7  # white
-    15 <- 98  # 'b'
-    16 <- 7  # white
-    17 <- 99  # 'c'
-    18 <- 7  # white
-    19 <- 0  # ' '
-    20 <- 7  # white
-  ]
-]
-
-scenario print-newline-character [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  run [
-    newline:char <- copy 10/newline
-    fake-screen <- print fake-screen, newline
-    10:num/raw <- get *fake-screen, cursor-row:offset
-    11:num/raw <- get *fake-screen, cursor-column:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    12:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    10 <- 1  # cursor row
-    11 <- 1  # cursor column
-    12 <- 6  # width*height
-    13 <- 97  # 'a'
-    14 <- 7  # white
-    # rest of screen is empty
-    15 <- 0
-  ]
-]
-
-scenario print-newline-at-bottom-line [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  newline:char <- copy 10/newline
-  fake-screen <- print fake-screen, newline
-  fake-screen <- print fake-screen, newline
-  run [
-    # cursor now at bottom of screen
-    fake-screen <- print fake-screen, newline
-    10:num/raw <- get *fake-screen, cursor-row:offset
-    11:num/raw <- get *fake-screen, cursor-column:offset
-  ]
-  # doesn't move further down
-  memory-should-contain [
-    10 <- 1  # cursor row
-    11 <- 0  # cursor column
-  ]
-]
-
-scenario print-character-at-bottom-right [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 2/width, 2/height
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  b:char <- copy 98/b
-  fake-screen <- print fake-screen, b
-  c:char <- copy 99/c
-  fake-screen <- print fake-screen, c
-  run [
-    # cursor now at bottom right
-    d:char <- copy 100/d
-    fake-screen <- print fake-screen, d
-    10:num/raw <- get *fake-screen, cursor-row:offset
-    11:num/raw <- get *fake-screen, cursor-column:offset
-    12:num/raw <- get *fake-screen, top-idx:offset
-    13:bool/raw <- get *fake-screen, pending-scroll?:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    20:@:screen-cell/raw <- copy *cell
-  ]
-  # cursor column wraps but the screen doesn't scroll yet
-  memory-should-contain [
-    10 <- 1  # cursor row
-    11 <- 0  # cursor column -- outside screen
-    12 <- 0  # top-idx -- not yet scrolled
-    13 <- 1  # pending-scroll?
-    20 <- 4  # screen size (width*height)
-    21 <- 97  # 'a'
-    22 <- 7  # white
-    23 <- 98  # 'b'
-    24 <- 7  # white
-    25 <- 99 # 'c'
-    26 <- 7  # white
-    27 <- 100  # 'd'
-    28 <- 7  # white
-  ]
-  run [
-    e:char <- copy 101/e
-    print fake-screen, e
-    10:num/raw <- get *fake-screen, cursor-row:offset
-    11:num/raw <- get *fake-screen, cursor-column:offset
-    12:num/raw <- get *fake-screen, top-idx:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    20:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    # text scrolls by 1, we lose the top line
-    10 <- 1  # cursor row
-    11 <- 1  # cursor column -- wrapped
-    12 <- 2  # top-idx -- scrolled
-    20 <- 4  # screen size (width*height)
-    # screen now checked in rotated order
-    25 <- 99 # 'c'
-    26 <- 7  # white
-    27 <- 100  # 'd'
-    28 <- 7  # white
-    # screen wraps; bottom line is cleared of old contents
-    21 <- 101  # 'e'
-    22 <- 7  # white
-    23 <- 0  # unused
-    24 <- 7  # white
-  ]
-]
-
-# even though our screen supports scrolling, some apps may want to avoid
-# scrolling
-# these helpers help check for scrolling at development time
-def save-top-idx screen:&:screen -> result:num [
-  local-scope
-  load-inputs
-  return-unless screen, 0  # check is only for fake screens
-  result <- get *screen, top-idx:offset
-]
-def assert-no-scroll screen:&:screen, old-top-idx:num [
-  local-scope
-  load-inputs
-  return-unless screen
-  new-top-idx:num <- get *screen, top-idx:offset
-  no-scroll?:bool <- equal old-top-idx, new-top-idx
-  assert no-scroll?, [render should never use screen's scrolling capabilities]
-]
-
-def clear-line screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [clear-line]
-  space:char <- copy 0/nul
-  {
-    break-if screen
-    # real screen
-    clear-line-on-display
-    return
-  }
-  # fake screen
-  width:num <- get *screen, num-columns:offset
-  column:num <- get *screen, cursor-column:offset
-  original-column:num <- copy column
-  # space over the entire line
-  {
-    right:num <- subtract width, 1
-    done?:bool <- greater-or-equal column, right
-    break-if done?
-    print screen, space
-    column <- add column, 1
-    loop
-  }
-  # now back to where the cursor was
-  *screen <- put *screen, cursor-column:offset, original-column
-]
-
-# only for non-scrolling apps
-def clear-line-until screen:&:screen, right:num/inclusive -> screen:&:screen [
-  local-scope
-  load-inputs
-  row:num, column:num <- cursor-position screen
-#?   stash [clear-line-until] row column
-  height:num <- screen-height screen
-  past-bottom?:bool <- greater-or-equal row, height
-  return-if past-bottom?
-  space:char <- copy 32/space
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  {
-    done?:bool <- greater-than column, right
-    break-if done?
-    screen <- print screen, space, 7/white, bg-color  # foreground color is mostly unused except if the cursor shows up at this cell
-    column <- add column, 1
-    loop
-  }
-]
-
-def cursor-position screen:&:screen -> row:num, column:num [
-  local-scope
-  load-inputs
-  {
-    break-if screen
-    # real screen
-    row, column <- cursor-position-on-display
-    return
-  }
-  # fake screen
-  row:num <- get *screen, cursor-row:offset
-  column:num <- get *screen, cursor-column:offset
-]
-
-def move-cursor screen:&:screen, new-row:num, new-column:num -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [move-cursor] new-row new-column
-  {
-    break-if screen
-    # real screen
-    move-cursor-on-display new-row, new-column
-    return
-  }
-  # fake screen
-  *screen <- put *screen, cursor-row:offset, new-row
-  *screen <- put *screen, cursor-column:offset, new-column
-  # if cursor column is within bounds, reset 'pending-scroll?'
-  {
-    width:num <- get *screen, num-columns:offset
-    scroll?:bool <- greater-or-equal new-column, width
-    break-if scroll?
-#?     stash [resetting pending-scroll?]
-    *screen <- put *screen, pending-scroll?:offset, false
-  }
-]
-
-scenario clear-line-erases-printed-characters [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  # print a character
-  a:char <- copy 97/a
-  fake-screen <- print fake-screen, a
-  # move cursor to start of line
-  fake-screen <- move-cursor fake-screen, 0/row, 0/column
-  run [
-    fake-screen <- clear-line fake-screen
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    10:@:screen-cell/raw <- copy *cell
-  ]
-  # screen should be blank
-  memory-should-contain [
-    10 <- 6  # width*height
-    11 <- 0
-    12 <- 7
-    13 <- 0
-    14 <- 7
-    15 <- 0
-    16 <- 7
-    17 <- 0
-    18 <- 7
-    19 <- 0
-    20 <- 7
-    21 <- 0
-    22 <- 7
-  ]
-]
-
-def cursor-down screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-down]
-  {
-    break-if screen
-    # real screen
-    move-cursor-down-on-display
-    return
-  }
-  # fake screen
-  cursor-down-on-fake-screen screen
-]
-
-scenario cursor-down-scrolls [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  # print something to screen and scroll
-  run [
-    print fake-screen, [abc]
-    cursor-to-next-line fake-screen
-    cursor-to-next-line fake-screen
-    data:&:@:screen-cell <- get *fake-screen, data:offset
-    10:@:screen-cell/raw <- copy *data
-  ]
-  # screen is now blank
-  memory-should-contain [
-    10 <- 6  # width*height
-    11 <- 0
-    12 <- 7  # white
-    13 <- 0
-    14 <- 7  # white
-    15 <- 0
-    16 <- 7  # white
-    17 <- 0
-    18 <- 7  # white
-    19 <- 0
-    20 <- 7  # white
-    21 <- 0
-    22 <- 7  # white
-  ]
-]
-
-def cursor-up screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-up]
-  {
-    break-if screen
-    # real screen
-    move-cursor-up-on-display
-    return
-  }
-  # fake screen
-  row:num <- get *screen, cursor-row:offset
-  at-top?:bool <- lesser-or-equal row, 0
-  return-if at-top?
-  row <- subtract row, 1
-  *screen <- put *screen, cursor-row:offset, row
-]
-
-def cursor-right screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-right]
-  {
-    break-if screen
-    # real screen
-    move-cursor-right-on-display
-    return
-  }
-  # fake screen
-  width:num <- get *screen, num-columns:offset
-  column:num <- get *screen, cursor-column:offset
-  max:num <- subtract width, 1
-  at-bottom?:bool <- greater-or-equal column, max
-  return-if at-bottom?
-  column <- add column, 1
-  *screen <- put *screen, cursor-column:offset, column
-]
-
-def cursor-left screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-left]
-  {
-    break-if screen
-    # real screen
-    move-cursor-left-on-display
-    return
-  }
-  # fake screen
-  column:num <- get *screen, cursor-column:offset
-  at-top?:bool <- lesser-or-equal column, 0
-  return-if at-top?
-  column <- subtract column, 1
-  *screen <- put *screen, cursor-column:offset, column
-]
-
-def cursor-to-start-of-line screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-to-start-of-line]
-  row:num <- cursor-position screen
-  screen <- move-cursor screen, row, 0/column
-]
-
-def cursor-to-next-line screen:&:screen -> screen:&:screen [
-  local-scope
-  load-inputs
-#?   stash [cursor-to-next-line]
-  screen <- cursor-down screen
-  screen <- cursor-to-start-of-line screen
-]
-
-def move-cursor-to-column screen:&:screen, column:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  row:num, _ <- cursor-position screen
-#?   stash [move-cursor-to-column] row
-  move-cursor screen, row, column
-]
-
-def screen-width screen:&:screen -> width:num [
-  local-scope
-  load-inputs
-#?   stash [screen-width]
-  {
-    break-unless screen
-    # fake screen
-    width <- get *screen, num-columns:offset
-    return
-  }
-  # real screen
-  width <- display-width
-]
-
-def screen-height screen:&:screen -> height:num [
-  local-scope
-  load-inputs
-#?   stash [screen-height]
-  {
-    break-unless screen
-    # fake screen
-    height <- get *screen, num-rows:offset
-    return
-  }
-  # real screen
-  height <- display-height
-]
-
-def print screen:&:screen, s:text -> screen:&:screen [
-  local-scope
-  load-inputs
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 7/white
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  len:num <- length *s
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    c:char <- index *s, i
-    print screen, c, color, bg-color
-    i <- add i, 1
-    loop
-  }
-]
-
-scenario print-text-wraps-past-right-margin [
-  local-scope
-  fake-screen:&:screen <- new-fake-screen 3/width, 2/height
-  run [
-    fake-screen <- print fake-screen, [abcd]
-    5:num/raw <- get *fake-screen, cursor-row:offset
-    6:num/raw <- get *fake-screen, cursor-column:offset
-    7:num/raw <- get *fake-screen, top-idx:offset
-    cell:&:@:screen-cell <- get *fake-screen, data:offset
-    10:@:screen-cell/raw <- copy *cell
-  ]
-  memory-should-contain [
-    5 <- 1  # cursor-row
-    6 <- 1  # cursor-column
-    7 <- 0  # top-idx
-    10 <- 6  # width*height
-    11 <- 97  # 'a'
-    12 <- 7  # white
-    13 <- 98  # 'b'
-    14 <- 7  # white
-    15 <- 99  # 'c'
-    16 <- 7  # white
-    17 <- 100  # 'd'
-    18 <- 7  # white
-    # rest of screen is empty
-    19 <- 0
-  ]
-]
-
-def print screen:&:screen, n:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 7/white
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  # todo: other bases besides decimal
-  s:text <- to-text n
-  screen <- print screen, s, color, bg-color
-]
-
-def print screen:&:screen, n:bool -> screen:&:screen [
-  local-scope
-  load-inputs
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 7/white
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  {
-    break-if n
-    screen <- print screen, [false], color, bg-color
-  }
-  {
-    break-unless n
-    screen <- print screen, [true], color, bg-color
-  }
-]
-
-def print screen:&:screen, n:&:_elem -> screen:&:screen [
-  local-scope
-  load-inputs
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 7/white
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    # default bg-color to black
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  n2:num <- deaddress n
-  screen <- print screen, n2, color, bg-color
-]
diff --git a/archive/2.vm/082scenario_screen.cc b/archive/2.vm/082scenario_screen.cc
deleted file mode 100644
index 39ba76e7..00000000
--- a/archive/2.vm/082scenario_screen.cc
+++ /dev/null
@@ -1,458 +0,0 @@
-//: Clean syntax to manipulate and check the screen in scenarios.
-//: Instructions 'assume-screen' and 'screen-should-contain' implicitly create
-//: a variable called 'screen' that is accessible to later instructions in the
-//: scenario. 'screen-should-contain' can check unicode characters in the fake
-//: screen
-
-//: first make sure we don't mangle these instructions in other transforms
-:(before "End initialize_transform_rewrite_literal_string_to_text()")
-recipes_taking_literal_strings.insert("screen-should-contain");
-recipes_taking_literal_strings.insert("screen-should-contain-in-color");
-
-:(code)
-void test_screen_in_scenario() {
-  run_mu_scenario(
-      "scenario screen-in-scenario [\n"
-      "  local-scope\n"
-      "  assume-screen 5/width, 3/height\n"
-      "  run [\n"
-      "    a:char <- copy 97/a\n"
-      "    screen:&:screen <- print screen:&:screen, a\n"
-      "  ]\n"
-      "  screen-should-contain [\n"
-      //    01234
-      "    .a    .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-void test_screen_in_scenario_unicode() {
-  // screen-should-contain can check unicode characters in the fake screen\n"
-  run_mu_scenario(
-      "scenario screen-in-scenario-unicode [\n"
-      "  local-scope\n"
-      "  assume-screen 5/width, 3/height\n"
-      "  run [\n"
-      "    lambda:char <- copy 955/greek-small-lambda\n"
-      "    screen:&:screen <- print screen:&:screen, lambda\n"
-      "    a:char <- copy 97/a\n"
-      "    screen:&:screen <- print screen:&:screen, a\n"
-      "  ]\n"
-      "  screen-should-contain [\n"
-      //    01234
-      "    .λa   .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-void test_screen_in_scenario_color() {
-  run_mu_scenario(
-      "scenario screen-in-scenario-color [\n"
-      "  local-scope\n"
-      "  assume-screen 5/width, 3/height\n"
-      "  run [\n"
-      "    lambda:char <- copy 955/greek-small-lambda\n"
-      "    screen:&:screen <- print screen:&:screen, lambda, 1/red\n"
-      "    a:char <- copy 97/a\n"
-      "    screen:&:screen <- print screen:&:screen, a, 7/white\n"
-      "  ]\n"
-         // screen-should-contain shows everything
-      "  screen-should-contain [\n"
-      //    01234
-      "    .λa   .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-         // screen-should-contain-in-color filters out everything except the
-         // given color, all you see is the 'a' in white.
-      "  screen-should-contain-in-color 7/white, [\n"
-      //    01234
-      "    . a   .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-         // ..and the λ in red.
-      "  screen-should-contain-in-color 1/red, [\n"
-      //    01234
-      "    .λ    .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-      "]\n"
-  );
-  // checks are inside scenario
-}
-
-void test_screen_in_scenario_error() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run_mu_scenario(
-      "scenario screen-in-scenario-error [\n"
-      "  local-scope\n"
-      "  assume-screen 5/width, 3/height\n"
-      "  run [\n"
-      "    a:char <- copy 97/a\n"
-      "    screen:&:screen <- print screen:&:screen, a\n"
-      "  ]\n"
-      "  screen-should-contain [\n"
-      //    01234
-      "    .b    .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - screen-in-scenario-error: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a')\n"
-  );
-}
-
-void test_screen_in_scenario_color_error() {
-  Scenario_testing_scenario = true;
-  Hide_errors = true;
-  run_mu_scenario(
-      "scenario screen-in-scenario-color-error [\n"
-      "  local-scope\n"
-      "  assume-screen 5/width, 3/height\n"
-      "  run [\n"
-      "    a:char <- copy 97/a\n"
-      "    screen:&:screen <- print screen:&:screen, a, 1/red\n"
-      "  ]\n"
-      "  screen-should-contain-in-color 2/green, [\n"
-      //    01234
-      "    .a    .\n"
-      "    .     .\n"
-      "    .     .\n"
-      "  ]\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: F - screen-in-scenario-color-error: expected screen location (0, 0) to contain 'a' in color 2 instead of 1\n"
-  );
-}
-
-void test_convert_names_does_not_fail_when_mixing_special_names_and_numeric_locations() {
-  Scenario_testing_scenario = true;
-  run(
-      "def main [\n"
-      "  screen:num <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_DOESNT_CONTAIN("error: mixing variable names and numeric addresses in main");
-  CHECK_TRACE_COUNT("error", 0);
-}
-
-//: It's easier to implement assume-screen and other similar scenario-only
-//: primitives if they always write to a fixed location. So we'll assign a
-//: single fixed location for the per-scenario screen, keyboard, file system,
-//: etc. Carve space for these fixed locations out of the reserved-for-test
-//: locations.
-
-:(before "End Globals")
-extern const int Max_variables_in_scenarios = Reserved_for_tests-100;
-int Next_predefined_global_for_scenarios = Max_variables_in_scenarios;
-:(before "End Reset")
-assert(Next_predefined_global_for_scenarios < Reserved_for_tests);
-
-:(before "End Globals")
-// Scenario Globals.
-extern const int SCREEN = next_predefined_global_for_scenarios(/*size_of(address:screen)*/2);
-// End Scenario Globals.
-:(code)
-int next_predefined_global_for_scenarios(int size) {
-  int result = Next_predefined_global_for_scenarios;
-  Next_predefined_global_for_scenarios += size;
-  return result;
-}
-
-//: give 'screen' a fixed location in scenarios
-:(before "End Special Scenario Variable Names(r)")
-Name[r]["screen"] = SCREEN;
-//: make 'screen' always a raw location in scenarios
-:(before "End is_special_name Special-cases")
-if (s == "screen") return true;
-
-:(before "End Rewrite Instruction(curr, recipe result)")
-// rewrite 'assume-screen width, height' to
-// 'screen:&:screen <- new-fake-screen width, height'
-if (curr.name == "assume-screen") {
-  curr.name = "new-fake-screen";
-  if (!curr.products.empty()) {
-    raise << result.name << ": 'assume-screen' has no products\n" << end();
-  }
-  else if (!starts_with(result.name, "scenario_")) {
-    raise << result.name << ": 'assume-screen' can't be called here, only in scenarios\n" << end();
-  }
-  else {
-    assert(curr.products.empty());
-    curr.products.push_back(reagent("screen:&:screen/raw"));
-    curr.products.at(0).set_value(SCREEN);
-  }
-}
-
-:(code)
-void test_assume_screen_shows_up_in_errors() {
-  Hide_errors = true;
-  run_mu_scenario(
-      "scenario assume-screen-shows-up-in-errors [\n"
-      "  assume-screen width, 5\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: assume-screen-shows-up-in-errors: missing type for 'width' in 'assume-screen width, 5'\n"
-  );
-}
-
-//: screen-should-contain is a regular instruction
-:(before "End Primitive Recipe Declarations")
-SCREEN_SHOULD_CONTAIN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "screen-should-contain", SCREEN_SHOULD_CONTAIN);
-:(before "End Primitive Recipe Checks")
-case SCREEN_SHOULD_CONTAIN: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'screen-should-contain' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain' should be a literal string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SCREEN_SHOULD_CONTAIN: {
-  if (!Passed) break;
-  assert(scalar(ingredients.at(0)));
-  check_screen(current_instruction().ingredients.at(0).name, -1);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-SCREEN_SHOULD_CONTAIN_IN_COLOR,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "screen-should-contain-in-color", SCREEN_SHOULD_CONTAIN_IN_COLOR);
-:(before "End Primitive Recipe Checks")
-case SCREEN_SHOULD_CONTAIN_IN_COLOR: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'screen-should-contain-in-color' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain-in-color' should be a number (color code), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  if (!is_literal_text(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of 'screen-should-contain-in-color' should be a literal string, but got '" << inst.ingredients.at(1).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SCREEN_SHOULD_CONTAIN_IN_COLOR: {
-  if (!Passed) break;
-  assert(scalar(ingredients.at(0)));
-  assert(scalar(ingredients.at(1)));
-  check_screen(current_instruction().ingredients.at(1).name, ingredients.at(0).at(0));
-  break;
-}
-
-:(before "End Types")
-// scan an array of characters in a unicode-aware, bounds-checked manner
-struct raw_string_stream {
-  int index;
-  const int max;
-  const char* buf;
-
-  raw_string_stream(const string&);
-  uint32_t get();  // unicode codepoint
-  uint32_t peek();  // unicode codepoint
-  bool at_end() const;
-  void skip_whitespace_and_comments();
-};
-
-:(code)
-void check_screen(const string& expected_contents, const int color) {
-  int screen_location = get_or_insert(Memory, SCREEN+/*skip address alloc id*/1) + /*skip payload alloc id*/1;
-  reagent screen("x:screen");  // just to ensure screen.type is reclaimed
-  int screen_data_location = find_element_location(screen_location, "data", screen.type, "check_screen");  // type: address:array:character
-  assert(screen_data_location >= 0);
-//?   cerr << "screen data is at location " << screen_data_location << '\n';
-  int screen_data_start = get_or_insert(Memory, screen_data_location+/*skip address alloc id*/1) + /*skip payload alloc id*/1;  // type: array:character
-//?   cerr << "screen data start is at " << screen_data_start << '\n';
-  int screen_width_location = find_element_location(screen_location, "num-columns", screen.type, "check_screen");
-//?   cerr << "screen width is at location " << screen_width_location << '\n';
-  int screen_width = get_or_insert(Memory, screen_width_location);
-//?   cerr << "screen width: " << screen_width << '\n';
-  int screen_height_location = find_element_location(screen_location, "num-rows", screen.type, "check_screen");
-//?   cerr << "screen height is at location " << screen_height_location << '\n';
-  int screen_height = get_or_insert(Memory, screen_height_location);
-//?   cerr << "screen height: " << screen_height << '\n';
-  int top_index_location= find_element_location(screen_location, "top-idx", screen.type, "check_screen");
-//?   cerr << "top of screen is at location " << top_index_location << '\n';
-  int top_index = get_or_insert(Memory, top_index_location);
-//?   cerr << "top of screen is index " << top_index << '\n';
-  raw_string_stream cursor(expected_contents);
-  // todo: too-long expected_contents should fail
-  for (int i=0, row=top_index/screen_width;  i < screen_height;  ++i, row=(row+1)%screen_height) {
-    cursor.skip_whitespace_and_comments();
-    if (cursor.at_end()) break;
-    if (cursor.get() != '.') {
-      raise << maybe(current_recipe_name()) << "each row of the expected screen should start with a '.'\n" << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-    int addr = screen_data_start+/*length*/1+row*screen_width* /*size of screen-cell*/2;
-    for (int column = 0;  column < screen_width;  ++column, addr+= /*size of screen-cell*/2) {
-      const int cell_color_offset = 1;
-      uint32_t curr = cursor.get();
-      if (get_or_insert(Memory, addr) == 0 && isspace(curr)) continue;
-      if (curr == ' ' && color != -1 && color != get_or_insert(Memory, addr+cell_color_offset)) {
-        // filter out other colors
-        continue;
-      }
-      if (get_or_insert(Memory, addr) != 0 && get_or_insert(Memory, addr) == curr) {
-        if (color == -1 || color == get_or_insert(Memory, addr+cell_color_offset)) continue;
-        // contents match but color is off
-        if (!Hide_errors) cerr << '\n';
-        raise << "F - " << maybe(current_recipe_name()) << "expected screen location (" << row << ", " << column << ") to contain '" << unicode_character_at(addr) << "' in color " << color << " instead of " << no_scientific(get_or_insert(Memory, addr+cell_color_offset)) << "\n" << end();
-        if (!Hide_errors) dump_screen();
-        if (!Scenario_testing_scenario) Passed = false;
-        return;
-      }
-
-      // really a mismatch
-      // can't print multi-byte unicode characters in errors just yet. not very useful for debugging anyway.
-      char expected_pretty[10] = {0};
-      if (curr < 256 && !iscntrl(curr)) {
-        // " ('<curr>')"
-        expected_pretty[0] = ' ', expected_pretty[1] = '(', expected_pretty[2] = '\'', expected_pretty[3] = static_cast<unsigned char>(curr), expected_pretty[4] = '\'', expected_pretty[5] = ')', expected_pretty[6] = '\0';
-      }
-      char actual_pretty[10] = {0};
-      if (get_or_insert(Memory, addr) < 256 && !iscntrl(get_or_insert(Memory, addr))) {
-        // " ('<curr>')"
-        actual_pretty[0] = ' ', actual_pretty[1] = '(', actual_pretty[2] = '\'', actual_pretty[3] = static_cast<unsigned char>(get_or_insert(Memory, addr)), actual_pretty[4] = '\'', actual_pretty[5] = ')', actual_pretty[6] = '\0';
-      }
-
-      ostringstream color_phrase;
-      if (color != -1) color_phrase << " in color " << color;
-      if (!Hide_errors) cerr << '\n';
-      raise << "F - " << maybe(current_recipe_name()) << "expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << color_phrase.str() << " instead of " << no_scientific(get_or_insert(Memory, addr)) << actual_pretty << '\n' << end();
-      if (!Hide_errors) dump_screen();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-    if (cursor.get() != '.') {
-      raise << maybe(current_recipe_name()) << "row " << row << " of the expected screen is too long\n" << end();
-      if (!Scenario_testing_scenario) Passed = false;
-      return;
-    }
-  }
-  cursor.skip_whitespace_and_comments();
-  if (!cursor.at_end()) {
-    raise << maybe(current_recipe_name()) << "expected screen has too many rows\n" << end();
-    Passed = false;
-  }
-}
-
-const char* unicode_character_at(int addr) {
-  int unicode_code_point = static_cast<int>(get_or_insert(Memory, addr));
-  return to_unicode(unicode_code_point);
-}
-
-raw_string_stream::raw_string_stream(const string& backing) :index(0), max(SIZE(backing)), buf(backing.c_str()) {}
-
-bool raw_string_stream::at_end() const {
-  if (index >= max) return true;
-  if (tb_utf8_char_length(buf[index]) > max-index) {
-    raise << "unicode string seems corrupted at index "<< index << " character " << static_cast<int>(buf[index]) << '\n' << end();
-    return true;
-  }
-  return false;
-}
-
-uint32_t raw_string_stream::get() {
-  assert(index < max);  // caller must check bounds before calling 'get'
-  uint32_t result = 0;
-  int length = tb_utf8_char_to_unicode(&result, &buf[index]);
-  assert(length != TB_EOF);
-  index += length;
-  return result;
-}
-
-uint32_t raw_string_stream::peek() {
-  assert(index < max);  // caller must check bounds before calling 'get'
-  uint32_t result = 0;
-  int length = tb_utf8_char_to_unicode(&result, &buf[index]);
-  assert(length != TB_EOF);
-  return result;
-}
-
-void raw_string_stream::skip_whitespace_and_comments() {
-  while (!at_end()) {
-    if (isspace(peek())) get();
-    else if (peek() == '#') {
-      // skip comment
-      get();
-      while (peek() != '\n') get();  // implicitly also handles CRLF
-    }
-    else break;
-  }
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_SCREEN,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$dump-screen", _DUMP_SCREEN);
-:(before "End Primitive Recipe Checks")
-case _DUMP_SCREEN: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _DUMP_SCREEN: {
-  dump_screen();
-  break;
-}
-
-:(code)
-void dump_screen() {
-  int screen_location = get_or_insert(Memory, SCREEN+/*skip address alloc id*/1) + /*skip payload alloc id*/1;
-  reagent screen("x:screen");  // just to ensure screen.type is reclaimed
-  int screen_data_location = find_element_location(screen_location, "data", screen.type, "check_screen");  // type: address:array:character
-  assert(screen_data_location >= 0);
-//?   cerr << "screen data is at location " << screen_data_location << '\n';
-  int screen_data_start = get_or_insert(Memory, screen_data_location+/*skip address alloc id*/1) + /*skip payload alloc id*/1;  // type: array:character
-//?   cerr << "screen data start is at " << screen_data_start << '\n';
-  int screen_width_location = find_element_location(screen_location, "num-columns", screen.type, "check_screen");
-//?   cerr << "screen width is at location " << screen_width_location << '\n';
-  int screen_width = get_or_insert(Memory, screen_width_location);
-//?   cerr << "screen width: " << screen_width << '\n';
-  int screen_height_location = find_element_location(screen_location, "num-rows", screen.type, "check_screen");
-//?   cerr << "screen height is at location " << screen_height_location << '\n';
-  int screen_height = get_or_insert(Memory, screen_height_location);
-//?   cerr << "screen height: " << screen_height << '\n';
-  int top_index_location= find_element_location(screen_location, "top-idx", screen.type, "check_screen");
-//?   cerr << "top of screen is at location " << top_index_location << '\n';
-  int top_index = get_or_insert(Memory, top_index_location);
-//?   cerr << "top of screen is index " << top_index << '\n';
-  for (int i=0, row=top_index/screen_width;  i < screen_height;  ++i, row=(row+1)%screen_height) {
-    cerr << '.';
-    int curr = screen_data_start+/*length*/1+row*screen_width* /*size of screen-cell*/2;
-    for (int col = 0;  col < screen_width;  ++col) {
-      if (get_or_insert(Memory, curr))
-        cerr << to_unicode(static_cast<uint32_t>(get_or_insert(Memory, curr)));
-      else
-        cerr << ' ';
-      curr += /*size of screen-cell*/2;
-    }
-    cerr << ".\n";
-  }
-}
diff --git a/archive/2.vm/083scenario_screen_test.mu b/archive/2.vm/083scenario_screen_test.mu
deleted file mode 100644
index b4ac6e5e..00000000
--- a/archive/2.vm/083scenario_screen_test.mu
+++ /dev/null
@@ -1,47 +0,0 @@
-# To check our support for screens in scenarios, rewrite tests from print.mu
-
-scenario print-character-at-top-left-2 [
-  local-scope
-  assume-screen 3/width, 2/height
-  run [
-    a:char <- copy 97/a
-    screen <- print screen, a
-  ]
-  screen-should-contain [
-    .a  .
-    .   .
-  ]
-]
-
-scenario clear-line-erases-printed-characters-2 [
-  local-scope
-  assume-screen 5/width, 3/height
-  # print a character
-  a:char <- copy 97/a
-  screen <- print screen, a
-  # move cursor to start of line
-  screen <- move-cursor screen, 0/row, 0/column
-  run [
-    screen <- clear-line screen
-  ]
-  screen-should-contain [
-    .     .
-    .     .
-    .     .
-  ]
-]
-
-scenario scroll-screen [
-  local-scope
-  assume-screen 3/width, 2/height
-  run [
-    a:char <- copy 97/a
-    move-cursor screen, 1/row, 2/column
-    screen <- print screen, a
-    screen <- print screen, a
-  ]
-  screen-should-contain [
-    .  a.
-    .a  .
-  ]
-]
diff --git a/archive/2.vm/084console.mu b/archive/2.vm/084console.mu
deleted file mode 100644
index bd18226a..00000000
--- a/archive/2.vm/084console.mu
+++ /dev/null
@@ -1,104 +0,0 @@
-# Wrappers around interaction primitives that take a potentially fake object
-# and are thus easier to test.
-
-exclusive-container event [
-  text:char
-  keycode:num  # keys on keyboard without a unicode representation
-  touch:touch-event  # mouse, track ball, etc.
-  resize:resize-event
-  # update the assume-console handler if you add more variants
-]
-
-container touch-event [
-  type:num
-  row:num
-  column:num
-]
-
-container resize-event [
-  width:num
-  height:num
-]
-
-container console [
-  current-event-index:num
-  events:&:@:event
-]
-
-def new-fake-console events:&:@:event -> result:&:console [
-  local-scope
-  load-inputs
-  result:&:console <- new console:type
-  *result <- put *result, events:offset, events
-]
-
-def read-event console:&:console -> result:event, found?:bool, quit?:bool, console:&:console [
-  local-scope
-  load-inputs
-  {
-    break-unless console
-    current-event-index:num <- get *console, current-event-index:offset
-    buf:&:@:event <- get *console, events:offset
-    {
-      max:num <- length *buf
-      done?:bool <- greater-or-equal current-event-index, max
-      break-unless done?
-      dummy:&:event <- new event:type
-      return *dummy, true/found, true/quit
-    }
-    result <- index *buf, current-event-index
-    current-event-index <- add current-event-index, 1
-    *console <- put *console, current-event-index:offset, current-event-index
-    return result, true/found, false/quit
-  }
-  switch  # real event source is infrequent; avoid polling it too much
-  result:event, found?:bool <- check-for-interaction
-  return result, found?, false/quit
-]
-
-# variant of read-event for just keyboard events. Discards everything that
-# isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get
-# newlines, tabs, ctrl-d..
-def read-key console:&:console -> result:char, found?:bool, quit?:bool, console:&:console [
-  local-scope
-  load-inputs
-  x:event, found?:bool, quit?:bool, console <- read-event console
-  return-if quit?, 0, found?, quit?
-  return-unless found?, 0, found?, quit?
-  c:char, converted?:bool <- maybe-convert x, text:variant
-  return-unless converted?, 0, false/found, false/quit
-  return c, true/found, false/quit
-]
-
-def send-keys-to-channel console:&:console, chan:&:sink:char, screen:&:screen -> console:&:console, chan:&:sink:char, screen:&:screen [
-  local-scope
-  load-inputs
-  {
-    c:char, found?:bool, quit?:bool, console <- read-key console
-    loop-unless found?
-    break-if quit?
-    assert c, [invalid event, expected text]
-    screen <- print screen, c
-    chan <- write chan, c
-    loop
-  }
-  chan <- close chan
-]
-
-def wait-for-event console:&:console -> console:&:console [
-  local-scope
-  load-inputs
-  {
-    _, found?:bool <- read-event console
-    break-if found?
-    switch
-    loop
-  }
-]
-
-def has-more-events? console:&:console -> result:bool [
-  local-scope
-  load-inputs
-  return-if console, false  # fake events are processed as soon as they arrive
-  result <- interactions-left?
-]
diff --git a/archive/2.vm/085scenario_console.cc b/archive/2.vm/085scenario_console.cc
deleted file mode 100644
index 75c2a289..00000000
--- a/archive/2.vm/085scenario_console.cc
+++ /dev/null
@@ -1,317 +0,0 @@
-//: Clean syntax to manipulate and check the console in scenarios.
-//: Instruction 'assume-console' implicitly creates a variable called
-//: 'console' that is accessible inside other 'run' instructions in the
-//: scenario. Like with the fake screen, 'assume-console' transparently
-//: supports unicode.
-
-//: first make sure we don't mangle this instruction in other transforms
-:(before "End initialize_transform_rewrite_literal_string_to_text()")
-recipes_taking_literal_strings.insert("assume-console");
-
-:(code)
-void test_keyboard_in_scenario() {
-  run_mu_scenario(
-      "scenario keyboard-in-scenario [\n"
-      "  assume-console [\n"
-      "    type [abc]\n"
-      "  ]\n"
-      "  run [\n"
-      "    1:char, 2:bool <- read-key console\n"
-      "    3:char, 4:bool <- read-key console\n"
-      "    5:char, 6:bool <- read-key console\n"
-      "    7:char, 8:bool, 9:bool <- read-key console\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 97\n"  // 'a'
-      "    2 <- 1\n"
-      "    3 <- 98\n"  // 'b'
-      "    4 <- 1\n"
-      "    5 <- 99\n"  // 'c'
-      "    6 <- 1\n"
-      "    7 <- 0\n"  // unset
-      "    8 <- 1\n"
-      "    9 <- 1\n"  // end of test events
-      "  ]\n"
-      "]\n"
-  );
-}
-
-:(before "End Scenario Globals")
-extern const int CONSOLE = next_predefined_global_for_scenarios(/*size_of(address:console)*/2);
-//: give 'console' a fixed location in scenarios
-:(before "End Special Scenario Variable Names(r)")
-Name[r]["console"] = CONSOLE;
-//: make 'console' always a raw location in scenarios
-:(before "End is_special_name Special-cases")
-if (s == "console") return true;
-
-:(before "End Primitive Recipe Declarations")
-ASSUME_CONSOLE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "assume-console", ASSUME_CONSOLE);
-:(before "End Primitive Recipe Checks")
-case ASSUME_CONSOLE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ASSUME_CONSOLE: {
-  // create a temporary recipe just for parsing; it won't contain valid instructions
-  istringstream in("[" + current_instruction().ingredients.at(0).name + "]");
-  recipe r;
-  slurp_body(in, r);
-  int num_events = count_events(r);
-  // initialize the events like in new-fake-console
-  int size = /*length*/1 + num_events*size_of_event();
-  int event_data_address = allocate(size);
-  // store length
-  put(Memory, event_data_address+/*skip alloc id*/1, num_events);
-  int curr_address = event_data_address + /*skip alloc id*/1 + /*skip length*/1;
-  for (int i = 0;  i < SIZE(r.steps);  ++i) {
-    const instruction& inst = r.steps.at(i);
-    if (inst.name == "left-click") {
-      trace(Callstack_depth+1, "mem") << "storing 'left-click' event starting at " << Current_routine->alloc << end();
-      put(Memory, curr_address, /*tag for 'touch-event' variant of 'event' exclusive-container*/2);
-      put(Memory, curr_address+/*skip tag*/1+/*offset of 'type' in 'mouse-event'*/0, TB_KEY_MOUSE_LEFT);
-      put(Memory, curr_address+/*skip tag*/1+/*offset of 'row' in 'mouse-event'*/1, to_integer(inst.ingredients.at(0).name));
-      put(Memory, curr_address+/*skip tag*/1+/*offset of 'column' in 'mouse-event'*/2, to_integer(inst.ingredients.at(1).name));
-      curr_address += size_of_event();
-    }
-    else if (inst.name == "press") {
-      trace(Callstack_depth+1, "mem") << "storing 'press' event starting at " << curr_address << end();
-      string key = inst.ingredients.at(0).name;
-      if (is_integer(key))
-        put(Memory, curr_address+1, to_integer(key));
-      else if (contains_key(Key, key))
-        put(Memory, curr_address+1, Key[key]);
-      else
-        raise << "assume-console: can't press '" << key << "'\n" << end();
-      if (get_or_insert(Memory, curr_address+1) < 256)
-        // these keys are in ascii
-        put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0);
-      else {
-        // distinguish from unicode
-        put(Memory, curr_address, /*tag for 'keycode' variant of 'event' exclusive-container*/1);
-      }
-      curr_address += size_of_event();
-    }
-    // End Event Handlers
-    else {
-      // keyboard input
-      assert(inst.name == "type");
-      trace(Callstack_depth+1, "mem") << "storing 'type' event starting at " << curr_address << end();
-      const string& contents = inst.ingredients.at(0).name;
-      const char* raw_contents = contents.c_str();
-      int num_keyboard_events = unicode_length(contents);
-      int curr = 0;
-      for (int i = 0;  i < num_keyboard_events;  ++i) {
-        trace(Callstack_depth+1, "mem") << "storing 'text' tag at " << curr_address << end();
-        put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0);
-        uint32_t curr_character;
-        assert(curr < SIZE(contents));
-        tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]);
-        trace(Callstack_depth+1, "mem") << "storing character " << curr_character << " at " << curr_address+/*skip exclusive container tag*/1 << end();
-        put(Memory, curr_address+/*skip exclusive container tag*/1, curr_character);
-        curr += tb_utf8_char_length(raw_contents[curr]);
-        curr_address += size_of_event();
-      }
-    }
-  }
-  assert(curr_address == event_data_address+/*skip alloc id*/1+size);
-  // wrap the array of events in a console object
-  int console_address = allocate(size_of_console());
-  trace(Callstack_depth+1, "mem") << "storing console in " << console_address << end();
-  put(Memory, CONSOLE+/*skip alloc id*/1, console_address);
-  trace(Callstack_depth+1, "mem") << "storing console data in " << console_address+/*offset of 'data' in container 'events'*/1 << end();
-  put(Memory, console_address+/*skip alloc id*/1+/*offset of 'data' in container 'events'*/1+/*skip alloc id of 'data'*/1, event_data_address);
-  break;
-}
-
-:(before "End Globals")
-map<string, int> Key;
-:(before "End One-time Setup")
-initialize_key_names();
-:(code)
-void initialize_key_names() {
-  Key["F1"] = TB_KEY_F1;
-  Key["F2"] = TB_KEY_F2;
-  Key["F3"] = TB_KEY_F3;
-  Key["F4"] = TB_KEY_F4;
-  Key["F5"] = TB_KEY_F5;
-  Key["F6"] = TB_KEY_F6;
-  Key["F7"] = TB_KEY_F7;
-  Key["F8"] = TB_KEY_F8;
-  Key["F9"] = TB_KEY_F9;
-  Key["F10"] = TB_KEY_F10;
-  Key["F11"] = TB_KEY_F11;
-  Key["F12"] = TB_KEY_F12;
-  Key["insert"] = TB_KEY_INSERT;
-  Key["delete"] = TB_KEY_DELETE;
-  Key["home"] = TB_KEY_HOME;
-  Key["end"] = TB_KEY_END;
-  Key["page-up"] = TB_KEY_PGUP;
-  Key["page-down"] = TB_KEY_PGDN;
-  Key["up-arrow"] = TB_KEY_ARROW_UP;
-  Key["down-arrow"] = TB_KEY_ARROW_DOWN;
-  Key["left-arrow"] = TB_KEY_ARROW_LEFT;
-  Key["right-arrow"] = TB_KEY_ARROW_RIGHT;
-  Key["ctrl-a"] = TB_KEY_CTRL_A;
-  Key["ctrl-b"] = TB_KEY_CTRL_B;
-  Key["ctrl-c"] = TB_KEY_CTRL_C;
-  Key["ctrl-d"] = TB_KEY_CTRL_D;
-  Key["ctrl-e"] = TB_KEY_CTRL_E;
-  Key["ctrl-f"] = TB_KEY_CTRL_F;
-  Key["ctrl-g"] = TB_KEY_CTRL_G;
-  Key["backspace"] = TB_KEY_BACKSPACE;
-  Key["ctrl-h"] = TB_KEY_CTRL_H;
-  Key["tab"] = TB_KEY_TAB;
-  Key["ctrl-i"] = TB_KEY_CTRL_I;
-  Key["ctrl-j"] = TB_KEY_CTRL_J;
-  Key["enter"] = TB_KEY_NEWLINE;  // ignore CR/LF distinction; there is only 'enter'
-  Key["ctrl-k"] = TB_KEY_CTRL_K;
-  Key["ctrl-l"] = TB_KEY_CTRL_L;
-  Key["ctrl-m"] = TB_KEY_CTRL_M;
-  Key["ctrl-n"] = TB_KEY_CTRL_N;
-  Key["ctrl-o"] = TB_KEY_CTRL_O;
-  Key["ctrl-p"] = TB_KEY_CTRL_P;
-  Key["ctrl-q"] = TB_KEY_CTRL_Q;
-  Key["ctrl-r"] = TB_KEY_CTRL_R;
-  Key["ctrl-s"] = TB_KEY_CTRL_S;
-  Key["ctrl-t"] = TB_KEY_CTRL_T;
-  Key["ctrl-u"] = TB_KEY_CTRL_U;
-  Key["ctrl-v"] = TB_KEY_CTRL_V;
-  Key["ctrl-w"] = TB_KEY_CTRL_W;
-  Key["ctrl-x"] = TB_KEY_CTRL_X;
-  Key["ctrl-y"] = TB_KEY_CTRL_Y;
-  Key["ctrl-z"] = TB_KEY_CTRL_Z;
-  Key["escape"] = TB_KEY_ESC;
-  Key["ctrl-slash"] = TB_KEY_CTRL_SLASH;
-}
-
-:(after "Begin check_or_set_invalid_types(r)")
-if (is_scenario(caller))
-  initialize_special_name(r);
-:(code)
-bool is_scenario(const recipe& caller) {
-  return starts_with(caller.name, "scenario_");
-}
-void initialize_special_name(reagent& r) {
-  if (r.type) return;
-  // no need for screen
-  if (r.name == "console") r.type = new_type_tree("address:console");
-  // End Initialize Type Of Special Name In Scenario(r)
-}
-
-void test_events_in_scenario() {
-  run_mu_scenario(
-      "scenario events-in-scenario [\n"
-      "  assume-console [\n"
-      "    type [abc]\n"
-      "    left-click 0, 1\n"
-      "    press up-arrow\n"
-      "    type [d]\n"
-      "  ]\n"
-      "  run [\n"
-           // 3 keyboard events; each event occupies 4 locations
-      "    1:event <- read-event console\n"
-      "    5:event <- read-event console\n"
-      "    9:event <- read-event console\n"
-           // mouse click
-      "    13:event <- read-event console\n"
-           // non-character keycode
-      "    17:event <- read-event console\n"
-           // final keyboard event
-      "    21:event <- read-event console\n"
-      "  ]\n"
-      "  memory-should-contain [\n"
-      "    1 <- 0\n"  // 'text'
-      "    2 <- 97\n"  // 'a'
-      "    3 <- 0\n"  // unused
-      "    4 <- 0\n"  // unused
-      "    5 <- 0\n"  // 'text'
-      "    6 <- 98\n"  // 'b'
-      "    7 <- 0\n"  // unused
-      "    8 <- 0\n"  // unused
-      "    9 <- 0\n"  // 'text'
-      "    10 <- 99\n"  // 'c'
-      "    11 <- 0\n"  // unused
-      "    12 <- 0\n"  // unused
-      "    13 <- 2\n"  // 'mouse'
-      "    14 <- 65513\n"  // mouse click
-      "    15 <- 0\n"  // row
-      "    16 <- 1\n"  // column
-      "    17 <- 1\n"  // 'keycode'
-      "    18 <- 65517\n"  // up arrow
-      "    19 <- 0\n"  // unused
-      "    20 <- 0\n"  // unused
-      "    21 <- 0\n"  // 'text'
-      "    22 <- 100\n"  // 'd'
-      "    23 <- 0\n"  // unused
-      "    24 <- 0\n"  // unused
-      "    25 <- 0\n"
-      "  ]\n"
-      "]\n"
-  );
-}
-
-//: Deal with special keys and unmatched brackets by allowing each test to
-//: independently choose the unicode symbol to denote them.
-:(before "End Primitive Recipe Declarations")
-REPLACE_IN_CONSOLE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "replace-in-console", REPLACE_IN_CONSOLE);
-:(before "End Primitive Recipe Checks")
-case REPLACE_IN_CONSOLE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case REPLACE_IN_CONSOLE: {
-  assert(scalar(ingredients.at(0)));
-  if (!get_or_insert(Memory, CONSOLE)) {
-    raise << "console not initialized\n" << end();
-    break;
-  }
-  int console_address = get_or_insert(Memory, CONSOLE);
-  int console_data = get_or_insert(Memory, console_address+1);
-  int length = get_or_insert(Memory, console_data);  // array length
-  for (int i = 0, curr = console_data+1;  i < length;  ++i, curr+=size_of_event()) {
-    if (get_or_insert(Memory, curr) != /*text*/0) continue;
-    if (get_or_insert(Memory, curr+1) != ingredients.at(0).at(0)) continue;
-    for (int n = 0;  n < size_of_event();  ++n)
-      put(Memory, curr+n, ingredients.at(1).at(n));
-  }
-  break;
-}
-
-:(code)
-int count_events(const recipe& r) {
-  int result = 0;
-  for (int i = 0;  i < SIZE(r.steps);  ++i) {
-    const instruction& curr = r.steps.at(i);
-    if (curr.name == "type")
-      result += unicode_length(curr.ingredients.at(0).name);
-    else
-      ++result;
-  }
-  return result;
-}
-
-int size_of_event() {
-  // memoize result if already computed
-  static int result = 0;
-  if (result) return result;
-  type_tree* type = new type_tree("event");
-  result = size_of(type);
-  delete type;
-  return result;
-}
-
-int size_of_console() {
-  // memoize result if already computed
-  static int result = 0;
-  if (result) return result;
-  assert(get(Type_ordinal, "console"));
-  type_tree* type = new type_tree("console");
-  result = size_of(type);
-  delete type;
-  return result;
-}
diff --git a/archive/2.vm/086scenario_console_test.mu b/archive/2.vm/086scenario_console_test.mu
deleted file mode 100644
index f5aa1438..00000000
--- a/archive/2.vm/086scenario_console_test.mu
+++ /dev/null
@@ -1,25 +0,0 @@
-# To check our support for consoles in scenarios, rewrite tests from
-# scenario_console.mu
-# Tests for console interface.
-
-scenario read-key-in-mu [
-  assume-console [
-    type [abc]
-  ]
-  run [
-    1:char, 2:bool <- read-key console
-    3:char, 4:bool <- read-key console
-    5:char, 6:bool <- read-key console
-    7:char, 8:bool <- read-key console
-  ]
-  memory-should-contain [
-    1 <- 97  # 'a'
-    2 <- 1
-    3 <- 98  # 'b'
-    4 <- 1
-    5 <- 99  # 'c'
-    6 <- 1
-    7 <- 0  # eof
-    8 <- 1
-  ]
-]
diff --git a/archive/2.vm/087file.cc b/archive/2.vm/087file.cc
deleted file mode 100644
index 9fd056db..00000000
--- a/archive/2.vm/087file.cc
+++ /dev/null
@@ -1,225 +0,0 @@
-//: Interacting with the file system.
-//:   '$open-file-for-reading' returns a FILE* as a number (ugh)
-//:   '$read-from-file' accepts a number, interprets it as a FILE* (double ugh) and reads a character from it
-//: Similarly for writing files.
-//: These interfaces are ugly and tied to the current (Linux) host Mu happens
-//: to be implemented atop. Later layers will wrap them with better, more
-//: testable interfaces.
-//:
-//: Clearly we don't care about performance or any of that so far.
-//: todo: reading/writing binary files
-
-:(before "End Primitive Recipe Declarations")
-_OPEN_FILE_FOR_READING,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$open-file-for-reading", _OPEN_FILE_FOR_READING);
-:(before "End Primitive Recipe Checks")
-case _OPEN_FILE_FOR_READING: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-reading' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-reading' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _OPEN_FILE_FOR_READING: {
-  string filename = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
-  assert(sizeof(long long int) >= sizeof(FILE*));
-  FILE* f = fopen(filename.c_str(), "r");
-  long long int result = reinterpret_cast<long long int>(f);
-  products.resize(1);
-  products.at(0).push_back(static_cast<double>(result));
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_OPEN_FILE_FOR_WRITING,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$open-file-for-writing", _OPEN_FILE_FOR_WRITING);
-:(before "End Primitive Recipe Checks")
-case _OPEN_FILE_FOR_WRITING: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-writing' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-writing' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _OPEN_FILE_FOR_WRITING: {
-  string filename = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
-  assert(sizeof(long long int) >= sizeof(FILE*));
-  long long int result = reinterpret_cast<long long int>(fopen(filename.c_str(), "w"));
-  products.resize(1);
-  products.at(0).push_back(static_cast<double>(result));
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_READ_FROM_FILE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$read-from-file", _READ_FROM_FILE);
-:(before "End Primitive Recipe Checks")
-case _READ_FROM_FILE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly two products, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_character(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$read-from-file' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_boolean(inst.products.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second product of '$read-from-file' should be a boolean, but got '" << to_string(inst.products.at(1)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _READ_FROM_FILE: {
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  FILE* f = reinterpret_cast<FILE*>(x);
-  if (f == NULL) {
-    raise << maybe(current_recipe_name()) << "can't read from null file in '" << to_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  products.resize(2);
-  if (feof(f)) {
-    products.at(0).push_back(0);
-    products.at(1).push_back(1);  // eof
-    break;
-  }
-  if (ferror(f)) {
-    raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  char c = getc(f);  // todo: unicode
-  if (c == EOF) {
-    products.at(0).push_back(0);
-    products.at(1).push_back(1);  // eof
-    break;
-  }
-  if (ferror(f)) {
-    raise << maybe(current_recipe_name()) << "couldn't read from file in '" << to_string(current_instruction()) << "'\n" << end();
-    raise << "  errno: " << errno << '\n' << end();
-    break;
-  }
-  products.at(0).push_back(c);
-  products.at(1).push_back(0);  // not eof
-  break;
-}
-:(before "End Includes")
-#include <errno.h>
-
-:(before "End Primitive Recipe Declarations")
-_WRITE_TO_FILE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$write-to-file", _WRITE_TO_FILE);
-:(before "End Primitive Recipe Checks")
-case _WRITE_TO_FILE: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'$write-to-file' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$write-to-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_character(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of '$write-to-file' should be a character, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (!inst.products.empty()) {
-    raise << maybe(get(Recipe, r).name) << "'$write-to-file' writes to no products, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _WRITE_TO_FILE: {
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  FILE* f = reinterpret_cast<FILE*>(x);
-  if (f == NULL) {
-    raise << maybe(current_recipe_name()) << "can't write to null file in '" << to_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  if (feof(f)) break;
-  if (ferror(f)) {
-    raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end();
-    break;
-  }
-  long long int y = static_cast<long long int>(ingredients.at(1).at(0));
-  char c = static_cast<char>(y);
-  putc(c, f);  // todo: unicode
-  if (ferror(f)) {
-    raise << maybe(current_recipe_name()) << "couldn't write to file in '" << to_string(current_instruction()) << "'\n" << end();
-    raise << "  errno: " << errno << '\n' << end();
-    break;
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLOSE_FILE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$close-file", _CLOSE_FILE);
-:(before "End Primitive Recipe Checks")
-case _CLOSE_FILE: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (inst.products.at(0).name != inst.ingredients.at(0).name) {
-    raise << maybe(get(Recipe, r).name) << "'$close-file' requires its product to be the same as its ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _CLOSE_FILE: {
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  FILE* f = reinterpret_cast<FILE*>(x);
-  fclose(f);
-  products.resize(1);
-  products.at(0).push_back(0);  // todo: ensure that caller always resets the ingredient
-  break;
-}
diff --git a/archive/2.vm/088file.mu b/archive/2.vm/088file.mu
deleted file mode 100644
index da3e35d3..00000000
--- a/archive/2.vm/088file.mu
+++ /dev/null
@@ -1,213 +0,0 @@
-# Wrappers around file system primitives that take a 'resources' object and
-# are thus easier to test.
-#
-# - start-reading - asynchronously open a file, returning a channel source for
-#   receiving the results
-# - start-writing - asynchronously open a file, returning a channel sink for
-#   the data to write
-# - slurp - synchronously read from a file
-# - dump - synchronously write to a file
-
-container resources [
-  lock:bool
-  data:&:@:resource
-]
-
-container resource [
-  name:text
-  contents:text
-]
-
-def start-reading resources:&:resources, filename:text -> contents:&:source:char, error?:bool [
-  local-scope
-  load-inputs
-  error? <- copy false
-  {
-    break-unless resources
-    # fake file system
-    contents, error? <- start-reading-from-fake-resource resources, filename
-    return
-  }
-  # real file system
-  file:num <- $open-file-for-reading filename
-  return-unless file, null/no-contents, true/error
-  contents:&:source:char, sink:&:sink:char <- new-channel 30
-  start-running receive-from-file file, sink
-]
-
-def slurp resources:&:resources, filename:text -> contents:text, error?:bool [
-  local-scope
-  load-inputs
-  source:&:source:char, error?:bool <- start-reading resources, filename
-  return-if error?, null/no-contents
-  buf:&:buffer:char <- new-buffer 30/capacity
-  {
-    c:char, done?:bool, source <- read source
-    break-if done?
-    buf <- append buf, c
-    loop
-  }
-  contents <- buffer-to-array buf
-]
-
-def start-reading-from-fake-resource resources:&:resources, resource:text -> contents:&:source:char, error?:bool [
-  local-scope
-  load-inputs
-  error? <- copy false
-  i:num <- copy 0
-  data:&:@:resource <- get *resources, data:offset
-  len:num <- length *data
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    tmp:resource <- index *data, i
-    i <- add i, 1
-    curr-resource:text <- get tmp, name:offset
-    found?:bool <- equal resource, curr-resource
-    loop-unless found?
-    contents:&:source:char, sink:&:sink:char <- new-channel 30
-    curr-contents:text <- get tmp, contents:offset
-    start-running receive-from-text curr-contents, sink
-    return
-  }
-  return null/no-such-resource, true/error-found
-]
-
-def receive-from-file file:num, sink:&:sink:char -> sink:&:sink:char [
-  local-scope
-  load-inputs
-  {
-    c:char, eof?:bool <- $read-from-file file
-    break-if eof?
-    sink <- write sink, c
-    loop
-  }
-  sink <- close sink
-  file <- $close-file file
-]
-
-def receive-from-text contents:text, sink:&:sink:char -> sink:&:sink:char [
-  local-scope
-  load-inputs
-  i:num <- copy 0
-  len:num <- length *contents
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    c:char <- index *contents, i
-    sink <- write sink, c
-    i <- add i, 1
-    loop
-  }
-  sink <- close sink
-]
-
-def start-writing resources:&:resources, filename:text -> sink:&:sink:char, routine-id:num, error?:bool [
-  local-scope
-  load-inputs
-  error? <- copy false
-  source:&:source:char, sink:&:sink:char <- new-channel 30
-  {
-    break-unless resources
-    # fake file system
-    routine-id <- start-running transmit-to-fake-resource resources, filename, source
-    return
-  }
-  # real file system
-  file:num <- $open-file-for-writing filename
-  return-unless file, null/sink, 0/routine-id, true/error
-  {
-    break-if file
-    msg:text <- append [no such file: ] filename
-    assert file, msg
-  }
-  routine-id <- start-running transmit-to-file file, source
-]
-
-def dump resources:&:resources, filename:text, contents:text -> resources:&:resources, error?:bool [
-  local-scope
-  load-inputs
-  # todo: really create an empty file
-  return-unless contents, resources, false/no-error
-  sink-file:&:sink:char, write-routine:num, error?:bool <- start-writing resources, filename
-  return-if error?
-  i:num <- copy 0
-  len:num <- length *contents
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    c:char <- index *contents, i
-    sink-file <- write sink-file, c
-    i <- add i, 1
-    loop
-  }
-  close sink-file
-  # make sure to wait for the file to be actually written to disk
-  # (Mu practices structured concurrency: http://250bpm.com/blog:71)
-  wait-for-routine write-routine
-]
-
-def transmit-to-file file:num, source:&:source:char -> source:&:source:char [
-  local-scope
-  load-inputs
-  {
-    c:char, done?:bool, source <- read source
-    break-if done?
-    $write-to-file file, c
-    loop
-  }
-  file <- $close-file file
-]
-
-def transmit-to-fake-resource resources:&:resources, filename:text, source:&:source:char -> resources:&:resources, source:&:source:char [
-  local-scope
-  load-inputs
-  lock:location <- get-location *resources, lock:offset
-  wait-for-reset-then-set lock
-  # compute new file contents
-  buf:&:buffer:char <- new-buffer 30
-  {
-    c:char, done?:bool, source <- read source
-    break-if done?
-    buf <- append buf, c
-    loop
-  }
-  contents:text <- buffer-to-array buf
-  new-resource:resource <- merge filename, contents
-  # write to resources
-  curr-filename:text <- copy null
-  data:&:@:resource <- get *resources, data:offset
-  # replace file contents if it already exists
-  i:num <- copy 0
-  len:num <- length *data
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    tmp:resource <- index *data, i
-    curr-filename <- get tmp, name:offset
-    found?:bool <- equal filename, curr-filename
-    {
-      break-unless found?
-      put-index *data, i, new-resource
-      jump +unlock-and-exit
-    }
-    i <- add i, 1
-    loop
-  }
-  # if file didn't already exist, make room for it
-  new-len:num <- add len, 1
-  new-data:&:@:resource <- new resource:type, new-len
-  put *resources, data:offset, new-data
-  # copy over old files
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    tmp:resource <- index *data, i
-    put-index *new-data, i, tmp
-  }
-  # write new file
-  put-index *new-data, len, new-resource
-  +unlock-and-exit
-  reset lock
-]
diff --git a/archive/2.vm/089scenario_filesystem.cc b/archive/2.vm/089scenario_filesystem.cc
deleted file mode 100644
index c49c20f8..00000000
--- a/archive/2.vm/089scenario_filesystem.cc
+++ /dev/null
@@ -1,245 +0,0 @@
-//: Clean syntax to manipulate and check the file system in scenarios.
-//: Instruction 'assume-resources' implicitly creates a variable called
-//: 'resources' that is accessible to later instructions in the scenario.
-
-void test_simple_filesystem() {
-  run_mu_scenario(
-      "scenario simple-filesystem [\n"
-      "  local-scope\n"
-      "  assume-resources [\n"
-           // file 'a' containing two lines of data
-      "    [a] <- [\n"
-      "      |a bc|\n"
-      "      |de f|\n"
-      "    ]\n"
-           // directory 'b' containing two files, 'c' and 'd'
-      "    [b/c] <- []\n"
-      "    [b/d] <- [\n"
-      "      |xyz|\n"
-      "    ]\n"
-      "  ]\n"
-      "  data:&:@:resource <- get *resources, data:offset\n"
-      "  file1:resource <- index *data, 0\n"
-      "  file1-name:text <- get file1, name:offset\n"
-      "  10:@:char/raw <- copy *file1-name\n"
-      "  file1-contents:text <- get file1, contents:offset\n"
-      "  100:@:char/raw <- copy *file1-contents\n"
-      "  file2:resource <- index *data, 1\n"
-      "  file2-name:text <- get file2, name:offset\n"
-      "  30:@:char/raw <- copy *file2-name\n"
-      "  file2-contents:text <- get file2, contents:offset\n"
-      "  40:@:char/raw <- copy *file2-contents\n"
-      "  file3:resource <- index *data, 2\n"
-      "  file3-name:text <- get file3, name:offset\n"
-      "  50:@:char/raw <- copy *file3-name\n"
-      "  file3-contents:text <- get file3, contents:offset\n"
-      "  60:@:char/raw <- copy *file3-contents\n"
-      "  memory-should-contain [\n"
-      "    10:array:character <- [a]\n"
-      "    100:array:character <- [a bc\n"
-      "de f\n"
-      "]\n"
-      "    30:array:character <- [b/c]\n"
-      "    40:array:character <- []\n"
-      "    50:array:character <- [b/d]\n"
-      "    60:array:character <- [xyz\n"
-      "]\n"
-      "  ]\n"
-      "]\n"
-  );
-}
-
-void test_escaping_file_contents() {
-  run_mu_scenario(
-      "scenario escaping-file-contents [\n"
-      "  local-scope\n"
-      "  assume-resources [\n"
-           // file 'a' containing a '|'
-           // need to escape '\\' once for each block
-      "    [a] <- [\n"
-      "      |x\\\\\\\\|yz|\n"
-      "    ]\n"
-      "  ]\n"
-      "  data:&:@:resource <- get *resources, data:offset\n"
-      "  file1:resource <- index *data, 0\n"
-      "  file1-name:text <- get file1, name:offset\n"
-      "  10:@:char/raw <- copy *file1-name\n"
-      "  file1-contents:text <- get file1, contents:offset\n"
-      "  20:@:char/raw <- copy *file1-contents\n"
-      "  memory-should-contain [\n"
-      "    10:array:character <- [a]\n"
-      "    20:array:character <- [x|yz\n"
-      "]\n"
-      "  ]\n"
-      "]\n"
-  );
-}
-
-:(before "End Globals")
-extern const int RESOURCES = next_predefined_global_for_scenarios(/*size_of(address:resources)*/2);
-//: give 'resources' a fixed location in scenarios
-:(before "End Special Scenario Variable Names(r)")
-Name[r]["resources"] = RESOURCES;
-//: make 'resources' always a raw location in scenarios
-:(before "End is_special_name Special-cases")
-if (s == "resources") return true;
-:(before "End Initialize Type Of Special Name In Scenario(r)")
-if (r.name == "resources") r.type = new_type_tree("address:resources");
-
-:(before "End initialize_transform_rewrite_literal_string_to_text()")
-recipes_taking_literal_strings.insert("assume-resources");
-
-//: screen-should-contain is a regular instruction
-:(before "End Primitive Recipe Declarations")
-ASSUME_RESOURCES,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "assume-resources", ASSUME_RESOURCES);
-:(before "End Primitive Recipe Checks")
-case ASSUME_RESOURCES: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case ASSUME_RESOURCES: {
-  assert(scalar(ingredients.at(0)));
-  assume_resources(current_instruction().ingredients.at(0).name, current_recipe_name());
-  break;
-}
-
-:(code)
-void assume_resources(const string& data, const string& caller) {
-  map<string, string> contents;
-  parse_resources(data, contents, caller);
-  construct_resources_object(contents);
-}
-
-void parse_resources(const string& data, map<string, string>& out, const string& caller) {
-  istringstream in(data);
-  in >> std::noskipws;
-  while (true) {
-    if (!has_data(in)) break;
-    skip_whitespace_and_comments(in);
-    if (!has_data(in)) break;
-    string filename = next_word(in);
-    if (filename.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete 'resources' block at end of file (0)\n" << end();
-      return;
-    }
-    if (*filename.begin() != '[') {
-      raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end();
-      break;
-    }
-    if (*filename.rbegin() != ']') {
-      raise << caller << ": assume-resources: filename '" << filename << "' must end with a ']'\n" << end();
-      break;
-    }
-    filename.erase(0, 1);
-    filename.erase(SIZE(filename)-1);
-    if (!has_data(in)) {
-      raise << caller << ": assume-resources: no data for filename '" << filename << "'\n" << end();
-      break;
-    }
-    string arrow = next_word(in);
-    if (arrow.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete 'resources' block at end of file (1)\n" << end();
-      return;
-    }
-    if (arrow != "<-") {
-      raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end();
-      break;
-    }
-    if (!has_data(in)) {
-      raise << caller << ": assume-resources: no data for filename '" << filename << "' after '<-'\n" << end();
-      break;
-    }
-    string contents = next_word(in);
-    if (contents.empty()) {
-      assert(!has_data(in));
-      raise << "incomplete 'resources' block at end of file (2)\n" << end();
-      return;
-    }
-    if (*contents.begin() != '[') {
-      raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end();
-      break;
-    }
-    if (*contents.rbegin() != ']') {
-      raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must end with a ']'\n" << end();
-      break;
-    }
-    contents.erase(0, 1);
-    contents.erase(SIZE(contents)-1);
-    put(out, filename, munge_resources_contents(contents, filename, caller));
-  }
-}
-
-string munge_resources_contents(const string& data, const string& filename, const string& caller) {
-  if (data.empty()) return "";
-  istringstream in(data);
-  in >> std::noskipws;
-  skip_whitespace_and_comments(in);
-  ostringstream out;
-  while (true) {
-    if (!has_data(in)) break;
-    skip_whitespace(in);
-    if (!has_data(in)) break;
-    if (in.peek() != '|') {
-      raise << caller << ": assume-resources: file contents for filename '" << filename << "' must be delimited in '|'s\n" << end();
-      break;
-    }
-    in.get();  // skip leading '|'
-    string line;
-    getline(in, line);
-    for (int i = 0;  i < SIZE(line);  ++i) {
-      if (line.at(i) == '|') break;
-      if (line.at(i) == '\\') {
-        ++i;  // skip
-        if (i == SIZE(line)) {
-          raise << caller << ": assume-resources: file contents can't end a line with '\\'\n" << end();
-          break;
-        }
-      }
-      out << line.at(i);
-    }
-    // todo: some way to represent a file without a final newline
-    out << '\n';
-  }
-  return out.str();
-}
-
-void construct_resources_object(const map<string, string>& contents) {
-  int resources_data_address = allocate(SIZE(contents) * /*size of resource*/4 + /*array length*/1);
-  int curr = resources_data_address + /*skip alloc id*/1 + /*skip array length*/1;
-  for (map<string, string>::const_iterator p = contents.begin();  p != contents.end();  ++p) {
-    ++curr;  // skip alloc id of resource.name
-    put(Memory, curr, new_mu_text(p->first));
-    trace(Callstack_depth+1, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end();
-    ++curr;
-    ++curr;  // skip alloc id of resource.contents
-    put(Memory, curr, new_mu_text(p->second));
-    trace(Callstack_depth+1, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end();
-    ++curr;
-  }
-  curr = resources_data_address + /*skip alloc id of resources.data*/1;
-  put(Memory, curr, SIZE(contents));  // array length
-  trace(Callstack_depth+1, "mem") << "storing resources size " << get(Memory, curr) << " in location " << curr << end();
-  // wrap the resources data in a 'resources' object
-  int resources_address = allocate(size_of_resources());
-  curr = resources_address+/*alloc id*/1+/*offset of 'data' element*/1+/*skip alloc id of 'data' element*/1;
-  put(Memory, curr, resources_data_address);
-  trace(Callstack_depth+1, "mem") << "storing resources data address " << resources_data_address << " in location " << curr << end();
-  // save in product
-  put(Memory, RESOURCES+/*skip alloc id*/1, resources_address);
-  trace(Callstack_depth+1, "mem") << "storing resources address " << resources_address << " in location " << RESOURCES << end();
-}
-
-int size_of_resources() {
-  // memoize result if already computed
-  static int result = 0;
-  if (result) return result;
-  assert(get(Type_ordinal, "resources"));
-  type_tree* type = new type_tree("resources");
-  result = size_of(type);
-  delete type;
-  return result;
-}
diff --git a/archive/2.vm/090scenario_filesystem_test.mu b/archive/2.vm/090scenario_filesystem_test.mu
deleted file mode 100644
index b487bfe0..00000000
--- a/archive/2.vm/090scenario_filesystem_test.mu
+++ /dev/null
@@ -1,99 +0,0 @@
-# Check our support for fake file systems in scenarios.
-
-scenario read-from-fake-file [
-  local-scope
-  assume-resources [
-    [a] <- [
-      |xyz|
-    ]
-  ]
-  contents:&:source:char <- start-reading resources, [a]
-  1:char/raw <- read contents
-  2:char/raw <- read contents
-  3:char/raw <- read contents
-  4:char/raw <- read contents
-  _, 5:bool/raw <- read contents
-  memory-should-contain [
-    1 <- 120  # x
-    2 <- 121  # y
-    3 <- 122  # z
-    4 <- 10  # newline
-    5 <- 1  # eof
-  ]
-]
-
-scenario write-to-new-fake-file [
-  local-scope
-  assume-resources [
-  ]
-  sink:&:sink:char, writer:num/routine <- start-writing resources, [a]
-  sink <- write sink, 120/x
-  sink <- write sink, 121/y
-  close sink
-  wait-for-routine writer
-  contents-read-back:text <- slurp resources, [a]
-  10:bool/raw <- equal contents-read-back, [xy]
-  memory-should-contain [
-    10 <- 1  # file contents read back exactly match what was written
-  ]
-]
-
-scenario write-to-new-fake-file-2 [
-  local-scope
-  assume-resources [
-    [a] <- [
-      |abc|
-    ]
-  ]
-  sink:&:sink:char, writer:num/routine <- start-writing resources, [b]
-  sink <- write sink, 120/x
-  sink <- write sink, 121/y
-  close sink
-  wait-for-routine writer
-  contents-read-back:text <- slurp resources, [b]
-  10:bool/raw <- equal contents-read-back, [xy]
-  memory-should-contain [
-    10 <- 1  # file contents read back exactly match what was written
-  ]
-]
-
-scenario write-to-fake-file-that-exists [
-  local-scope
-  assume-resources [
-    [a] <- []
-  ]
-  sink:&:sink:char, writer:num/routine <- start-writing resources, [a]
-  sink <- write sink, 120/x
-  sink <- write sink, 121/y
-  close sink
-  wait-for-routine writer
-  contents-read-back:text <- slurp resources, [a]
-  10:bool/raw <- equal contents-read-back, [xy]
-  memory-should-contain [
-    10 <- 1  # file contents read back exactly match what was written
-  ]
-]
-
-scenario write-to-existing-file-preserves-other-files [
-  local-scope
-  assume-resources [
-    [a] <- []
-    [b] <- [
-      |bcd|
-    ]
-  ]
-  sink:&:sink:char, writer:num/routine <- start-writing resources, [a]
-  sink <- write sink, 120/x
-  sink <- write sink, 121/y
-  close sink
-  wait-for-routine writer
-  contents-read-back:text <- slurp resources, [a]
-  10:bool/raw <- equal contents-read-back, [xy]
-  other-file-contents:text <- slurp resources, [b]
-  11:bool/raw <- equal other-file-contents, [bcd
-]
-  memory-should-contain [
-    10 <- 1  # file contents read back exactly match what was written
-    11 <- 1  # other files also continue to persist unchanged
-  ]
-]
diff --git a/archive/2.vm/091socket.cc b/archive/2.vm/091socket.cc
deleted file mode 100644
index a0f3b948..00000000
--- a/archive/2.vm/091socket.cc
+++ /dev/null
@@ -1,348 +0,0 @@
-:(before "End Types")
-struct socket_t {
-  int fd;
-  sockaddr_in addr;
-  bool polled;
-  socket_t() {
-    fd = 0;
-    polled = false;
-    bzero(&addr, sizeof(addr));
-  }
-};
-
-:(before "End Primitive Recipe Declarations")
-_OPEN_CLIENT_SOCKET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$open-client-socket", _OPEN_CLIENT_SOCKET);
-:(before "End Primitive Recipe Checks")
-case _OPEN_CLIENT_SOCKET: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly two ingredients, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-client-socket' should be text (the hostname), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second ingredient of '$open-client-socket' should be a number (the port of the hostname to connect to), but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$open-client-socket' should be a number (socket handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _OPEN_CLIENT_SOCKET: {
-  string host = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
-  int port = ingredients.at(1).at(0);
-  socket_t* client = client_socket(host, port);
-  products.resize(1);
-  if (client->fd < 0) {  // error
-    delete client;
-    products.at(0).push_back(0);
-    break;
-  }
-  long long int result = reinterpret_cast<long long int>(client);
-  products.at(0).push_back(static_cast<double>(result));
-  break;
-}
-:(code)
-socket_t* client_socket(const string& host, int port) {
-  socket_t* result = new socket_t;
-  result->fd = socket(AF_INET, SOCK_STREAM, 0);
-  if (result->fd < 0) {
-    raise << "Failed to create socket.\n" << end();
-    return result;
-  }
-  result->addr.sin_family = AF_INET;
-  hostent* tmp = gethostbyname(host.c_str());
-  bcopy(tmp->h_addr, reinterpret_cast<char*>(&result->addr.sin_addr.s_addr), tmp->h_length);
-  result->addr.sin_port = htons(port);
-  if (connect(result->fd, reinterpret_cast<sockaddr*>(&result->addr), sizeof(result->addr)) < 0) {
-    close(result->fd);
-    result->fd = -1;
-    raise << "Failed to connect to " << host << ':' << port << '\n' << end();
-  }
-  return result;
-}
-
-:(before "End Primitive Recipe Declarations")
-_OPEN_SERVER_SOCKET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$open-server-socket", _OPEN_SERVER_SOCKET);
-:(before "End Primitive Recipe Checks")
-case _OPEN_SERVER_SOCKET: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one ingredient (the port to listen for requests on), but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-server-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$open-server-socket' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _OPEN_SERVER_SOCKET: {
-  int port = ingredients.at(0).at(0);
-  socket_t* server = server_socket(port);
-  products.resize(1);
-  if (server->fd < 0) {
-    delete server;
-    products.at(0).push_back(0);
-    break;
-  }
-  long long int result = reinterpret_cast<long long int>(server);
-  products.at(0).push_back(static_cast<double>(result));
-  break;
-}
-:(code)
-socket_t* server_socket(int port) {
-  socket_t* result = new socket_t;
-  result->fd = socket(AF_INET, SOCK_STREAM, 0);
-  if (result->fd < 0) {
-    raise << "Failed to create server socket.\n" << end();
-    return result;
-  }
-  int dummy = 0;
-  setsockopt(result->fd, SOL_SOCKET, SO_REUSEADDR, &dummy, sizeof(dummy));
-  result->addr.sin_family = AF_INET;
-  result->addr.sin_addr.s_addr = Current_scenario ? htonl(INADDR_LOOPBACK) : INADDR_ANY;  // run tests without running afoul of any firewall
-  result->addr.sin_port = htons(port);
-  if (bind(result->fd, reinterpret_cast<sockaddr*>(&result->addr), sizeof(result->addr)) >= 0) {
-    listen(result->fd, /*queue length*/5);
-  }
-  else {
-    close(result->fd);
-    result->fd = -1;
-    raise << "Failed to bind result socket to port " << port << ". Something's already using that port.\n" << end();
-  }
-  return result;
-}
-
-:(before "End Primitive Recipe Declarations")
-_ACCEPT,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$accept", _ACCEPT);
-:(before "End Primitive Recipe Checks")
-case _ACCEPT: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$accept' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$accept' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _ACCEPT: {
-  products.resize(2);
-  products.at(1).push_back(ingredients.at(0).at(0));  // indicate it modifies its ingredient
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  socket_t* server = reinterpret_cast<socket_t*>(x);
-  if (server) {
-    socket_t* session = accept_session(server);
-    long long int result = reinterpret_cast<long long int>(session);
-    products.at(0).push_back(static_cast<double>(result));
-  }
-  else {
-    products.at(0).push_back(0);
-  }
-  break;
-}
-:(code)
-socket_t* accept_session(socket_t* server) {
-  if (server->fd == 0) return NULL;
-  socket_t* result = new socket_t;
-  socklen_t dummy = sizeof(result->addr);
-  result->fd = accept(server->fd, reinterpret_cast<sockaddr*>(&result->addr), &dummy);
-  return result;
-}
-
-:(before "End Primitive Recipe Declarations")
-_READ_FROM_SOCKET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$read-from-socket", _READ_FROM_SOCKET);
-:(before "End Primitive Recipe Checks")
-case _READ_FROM_SOCKET: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires exactly one ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-socket' should be a number (socket), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  int nprod = SIZE(inst.products);
-  if (nprod == 0 || nprod > 4) {
-    raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires 1-4 products, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_character(inst.products.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first product of '$read-from-socket' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end();
-    break;
-  }
-  if (nprod > 1 && !is_mu_boolean(inst.products.at(1))) {
-    raise << maybe(get(Recipe, r).name) << "second product of '$read-from-socket' should be a boolean (data received?), but got '" << to_string(inst.products.at(1)) << "'\n" << end();
-    break;
-  }
-  if (nprod > 2 && !is_mu_boolean(inst.products.at(2))) {
-    raise << maybe(get(Recipe, r).name) << "third product of '$read-from-socket' should be a boolean (eof?), but got '" << to_string(inst.products.at(2)) << "'\n" << end();
-    break;
-  }
-  if (nprod > 3 && !is_mu_number(inst.products.at(3))) {
-    raise << maybe(get(Recipe, r).name) << "fourth product of '$read-from-socket' should be a number (error code), but got '" << to_string(inst.products.at(3)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _READ_FROM_SOCKET: {
-  products.resize(4);
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  socket_t* socket = reinterpret_cast<socket_t*>(x);
-  // 1. we'd like to simply read() from the socket
-  // however read() on a socket never returns EOF, so we wouldn't know when to stop
-  // 2. recv() can signal EOF, but it also signals "no data yet" in the beginning
-  // so use poll() in the beginning to wait for data before calling recv()
-  // 3. but poll() will block on EOF, so only use poll() on the very first
-  // $read-from-socket on a socket
-  //
-  // Also, there was an unresolved issue where attempts to read() a small
-  // number of bytes (less than 447 on Linux and Mac) would cause browsers to
-  // prematurely close the connection. See commit 3403. That seems to be gone
-  // after moving to recv()+poll(). It was never observed on OpenBSD.
-  if (!socket->polled) {
-    pollfd p;
-    bzero(&p, sizeof(p));
-    p.fd = socket->fd;
-    p.events = POLLIN | POLLHUP;
-    int poll_result = poll(&p, /*num pollfds*/1, /*timeout*/100/*ms*/);
-    if (poll_result == 0) {
-      products.at(0).push_back(/*no data*/0);
-      products.at(1).push_back(/*found*/false);
-      products.at(2).push_back(/*eof*/false);
-      products.at(3).push_back(/*error*/0);
-      break;
-    }
-    else if (poll_result < 0) {
-      int error_code = errno;
-      raise << maybe(current_recipe_name()) << "error in $read-from-socket\n" << end();
-      products.at(0).push_back(/*no data*/0);
-      products.at(1).push_back(/*found*/false);
-      products.at(2).push_back(/*eof*/false);
-      products.at(3).push_back(error_code);
-      break;
-    }
-    socket->polled = true;
-  }
-  char c = '\0';
-  int error_code = 0;
-  int bytes_read = recv(socket->fd, &c, /*single byte*/1, MSG_DONTWAIT);
-  if (bytes_read < 0) error_code = errno;
-//?   if (error_code) {
-//?     ostringstream out;
-//?     out << "error in $read-from-socket " << socket->fd;
-//?     perror(out.str().c_str());
-//?   }
-  products.at(0).push_back(c);
-  products.at(1).push_back(/*found*/true);
-  products.at(2).push_back(/*eof*/bytes_read <= 0);
-  products.at(3).push_back(error_code);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_WRITE_TO_SOCKET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$write-to-socket", _WRITE_TO_SOCKET);
-:(before "End Primitive Recipe Checks")
-case _WRITE_TO_SOCKET: {
-  if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'$write-to-socket' requires exactly two ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _WRITE_TO_SOCKET: {
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  socket_t* socket = reinterpret_cast<socket_t*>(x);
-  // write just one character at a time to the socket
-  long long int y = static_cast<long long int>(ingredients.at(1).at(0));
-  char c = static_cast<char>(y);
-  if (write(socket->fd, &c, 1) != 1) {
-    raise << maybe(current_recipe_name()) << "failed to write to socket\n" << end();
-    exit(0);
-  }
-  products.resize(1);
-  products.at(0).push_back(ingredients.at(0).at(0));
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLOSE_SOCKET,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$close-socket", _CLOSE_SOCKET);
-:(before "End Primitive Recipe Checks")
-case _CLOSE_SOCKET: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly two ingredient, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (!is_mu_number(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  if (SIZE(inst.products) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly one product, but got '" << to_original_string(inst) << "'\n" << end();
-    break;
-  }
-  if (inst.products.at(0).name != inst.ingredients.at(0).name) {
-    raise << maybe(get(Recipe, r).name) << "product of '$close-socket' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _CLOSE_SOCKET: {
-  long long int x = static_cast<long long int>(ingredients.at(0).at(0));
-  socket_t* socket = reinterpret_cast<socket_t*>(x);
-  close(socket->fd);
-  delete socket;
-  products.resize(1);
-  products.at(0).push_back(0);  // make sure we can't reuse the socket
-  break;
-}
-
-:(before "End Includes")
-#include <netinet/in.h>
-#include <netdb.h>
-#include <poll.h>
-#include <sys/socket.h>
-#include <unistd.h>
diff --git a/archive/2.vm/092socket.mu b/archive/2.vm/092socket.mu
deleted file mode 100644
index b0dca4b7..00000000
--- a/archive/2.vm/092socket.mu
+++ /dev/null
@@ -1,177 +0,0 @@
-# Wrappers around socket primitives that are easier to test.
-
-# To test server operations, just run a real client against localhost.
-scenario example-server-test [
-  local-scope
-  # test server without a fake on a random (real) port
-  # that way repeatedly running the test will give ports time to timeout and
-  # close before reusing them
-  make-random-nondeterministic
-  port:num <- random-in-range null/real-random-numbers, 8000, 8100
-  run [
-    socket:num <- $open-server-socket port
-    assert socket, [ 
-F - example-server-test: $open-server-socket failed]
-    handler-routine:number <- start-running serve-one-request socket, example-handler
-  ]
-  source:&:source:char <- start-reading-from-network null/real-resources, [localhost/], port
-  response:text <- drain source
-  10:@:char/raw <- copy *response
-  memory-should-contain [
-    10:array:character <- [abc]
-  ]
-  socket <- $close-socket socket
-]
-# helper just for this scenario
-def example-handler query:text -> response:text [
-  local-scope
-  load-inputs
-  return [abc]
-]
-
-# To test client operations, use 'assume-resources' with a filename that
-# begins with a hostname. (Filenames starting with '/' are assumed to be
-# local.)
-scenario example-client-test [
-  local-scope
-  assume-resources [
-    [example.com/] <- [
-      |abc|
-    ]
-  ]
-  run [
-    source:&:source:char <- start-reading-from-network resources, [example.com/]
-  ]
-  contents:text <- drain source
-  10:@:char/raw <- copy *contents
-  memory-should-contain [
-    10:array:character <- [abc
-]
-  ]
-]
-
-type request-handler = (recipe text -> text)
-
-def serve-one-request socket:num, request-handler:request-handler -> socket:num [
-  local-scope
-  load-inputs
-  session:num <- $accept socket
-  assert session, [ 
-F - example-server-test: $accept failed]
-  contents:&:source:char, sink:&:sink:char <- new-channel 30
-  start-running receive-from-socket session, sink
-  query:text <- drain contents
-  response:text <- call request-handler, query
-  write-to-socket session, response
-  session <- $close-socket session
-]
-
-def start-reading-from-network resources:&:resources, uri:text -> contents:&:source:char [
-  local-scope
-  load-inputs
-  {
-    port:num, port-found?:boolean <- next-input
-    break-if port-found?
-    port <- copy 80/http-port
-  }
-  {
-    break-unless resources
-    # fake network
-    contents <- start-reading-from-fake-resource resources, uri
-    return
-  }
-  # real network
-  host:text, path:text <- split-at uri, 47/slash
-  socket:num <- $open-client-socket host, port
-  assert socket, [contents]
-  req:text <- interpolate [GET _ HTTP/1.1], path
-  request-socket socket, req
-  contents:&:source:char, sink:&:sink:char <- new-channel 10000
-  start-running receive-from-client-socket-and-close socket, sink
-]
-
-def request-socket socket:num, s:text -> socket:num [
-  local-scope
-  load-inputs
-  write-to-socket socket, s
-  $write-to-socket socket, 13/cr
-  $write-to-socket socket, 10/lf
-  # empty line to delimit request
-  $write-to-socket socket, 13/cr
-  $write-to-socket socket, 10/lf
-]
-
-def receive-from-socket socket:num, sink:&:sink:char -> sink:&:sink:char, socket:num [
-  local-scope
-  load-inputs
-  {
-    +next-attempt
-    c:char, found?:bool, eof?:bool, error:num <- $read-from-socket socket
-    break-if eof?
-    break-if error
-    {
-      break-unless found?
-      sink <- write sink, c
-    }
-    {
-      break-if found?
-      switch
-    }
-    loop
-  }
-  sink <- close sink
-]
-
-def receive-from-client-socket-and-close socket:num, sink:&:sink:char -> sink:&:sink:char, socket:num [
-  local-scope
-  load-inputs
-  sink <- receive-from-socket socket, sink
-  socket <- $close-socket socket
-]
-
-def write-to-socket socket:num, s:text [
-  local-scope
-  load-inputs
-  len:num <- length *s
-  i:num <- copy 0
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    c:char <- index *s, i
-    $write-to-socket socket, c
-    i <- add i, 1
-    loop
-  }
-]
-
-# like split-first, but don't eat the delimiter
-def split-at text:text, delim:char -> x:text, y:text [
-  local-scope
-  load-inputs
-  # empty text? return empty texts
-  len:num <- length *text
-  {
-    empty?:bool <- equal len, 0
-    break-unless empty?
-    x:text <- new []
-    y:text <- new []
-    return
-  }
-  idx:num <- find-next text, delim, 0
-  x:text <- copy-range text, 0, idx
-  y:text <- copy-range text, idx, len
-]
-
-scenario text-split-at [
-  local-scope
-  x:text <- new [a/b]
-  run [
-    y:text, z:text <- split-at x, 47/slash
-    10:@:char/raw <- copy *y
-    20:@:char/raw <- copy *z
-  ]
-  memory-should-contain [
-    10:array:character <- [a]
-    20:array:character <- [/b]
-  ]
-]
diff --git a/archive/2.vm/099hardware_checks.cc b/archive/2.vm/099hardware_checks.cc
deleted file mode 100644
index c1039c1f..00000000
--- a/archive/2.vm/099hardware_checks.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-//: Let's raise errors when students use real hardware in any recipes besides
-//: 'main'. Part of the goal is to teach them testing hygiene and dependency
-//: injection.
-//:
-//: This is easy to sidestep, it's for feedback rather than safety.
-
-:(before "End Globals")
-vector<type_tree*> Real_hardware_types;
-:(before "Begin transform_all")
-setup_real_hardware_types();
-:(before "End transform_all")
-teardown_real_hardware_types();
-:(code)
-void setup_real_hardware_types() {
-  Real_hardware_types.push_back(parse_type("address:screen"));
-  Real_hardware_types.push_back(parse_type("address:console"));
-  Real_hardware_types.push_back(parse_type("address:resources"));
-}
-type_tree* parse_type(string s) {
-  reagent x("x:"+s);
-  type_tree* result = x.type;
-  x.type = NULL;  // don't deallocate on return
-  return result;
-}
-void teardown_real_hardware_types() {
-  for (int i = 0;  i < SIZE(Real_hardware_types);  ++i)
-    delete Real_hardware_types.at(i);
-  Real_hardware_types.clear();
-}
-
-:(before "End Checks")
-Transform.push_back(check_for_misuse_of_real_hardware);
-:(code)
-void check_for_misuse_of_real_hardware(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
-  if (caller.name == "main") return;
-  if (starts_with(caller.name, "scenario_")) return;
-  trace(101, "transform") << "--- check if recipe " << caller.name << " has any dependency-injection mistakes" << end();
-  for (int index = 0;  index < SIZE(caller.steps);  ++index) {
-    const instruction& inst = caller.steps.at(index);
-    if (is_primitive(inst.operation)) continue;
-    for (int i = 0;  i < SIZE(inst.ingredients);  ++i) {
-      const reagent& ing = inst.ingredients.at(i);
-      if (!is_literal(ing) || ing.name != "0") continue;
-      const recipe& callee = get(Recipe, inst.operation);
-      if (!callee.has_header) continue;
-      if (i >= SIZE(callee.ingredients)) continue;
-      const reagent& expected_ing = callee.ingredients.at(i);
-      for (int j = 0;  j < SIZE(Real_hardware_types);  ++j) {
-        if (*Real_hardware_types.at(j) == *expected_ing.type)
-          raise << maybe(caller.name) << "'" << to_original_string(inst) << "': only 'main' can pass 0 into a " << to_string(expected_ing.type) << '\n' << end();
-      }
-    }
-  }
-}
-
-void test_warn_on_using_real_screen_directly_in_non_main_recipe() {
-  Hide_errors = true;
-  transform(
-      "def foo [\n"
-      "  print 0, 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "error: foo: 'print 0, 34': only 'main' can pass 0 into a (address screen)\n"
-  );
-}
diff --git a/archive/2.vm/101run_sandboxed.cc b/archive/2.vm/101run_sandboxed.cc
deleted file mode 100644
index e464bbe3..00000000
--- a/archive/2.vm/101run_sandboxed.cc
+++ /dev/null
@@ -1,711 +0,0 @@
-//: Helper for various programming environments: run arbitrary Mu code and
-//: return some result in text form.
-
-void test_run_interactive_code() {
-  run(
-      "def main [\n"
-      "  1:num <- copy 0\n"  // reserve space for the sandbox
-      "  10:text <- new [1:num/raw <- copy 34]\n"
-//?       "  $print 10:num [|] 11:num [: ] 1000:num [|] *10:text [ (] 10:text [)] 10/newline\n"
-      "  run-sandboxed 10:text\n"
-      "  20:num <- copy 1:num\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 20\n"
-  );
-}
-
-void test_run_interactive_empty() {
-  run(
-      "def main [\n"
-      "  10:text <- copy null\n"
-      "  20:text <- run-sandboxed 10:text\n"
-      "]\n"
-  );
-  // result is null
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 20\n"
-      "mem: storing 0 in location 21\n"
-  );
-}
-
-//: As the name suggests, 'run-sandboxed' will prevent certain operations that
-//: regular Mu code can perform.
-:(before "End Globals")
-bool Sandbox_mode = false;
-//: for starters, users can't override 'main' when the environment is running
-:(before "End Load Recipe Name")
-if (Sandbox_mode && result.name == "main") {
-  slurp_balanced_bracket(in);
-  return -1;
-}
-
-//: run code in 'interactive mode', i.e. with errors off and return:
-//:   stringified output in case we want to print it to screen
-//:   any errors encountered
-//:   simulated screen any prints went to
-//:   any 'app' layer traces generated
-:(before "End Primitive Recipe Declarations")
-RUN_SANDBOXED,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "run-sandboxed", RUN_SANDBOXED);
-:(before "End Primitive Recipe Checks")
-case RUN_SANDBOXED: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'run-sandboxed' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'run-sandboxed' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RUN_SANDBOXED: {
-  bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(/*skip alloc id*/1));
-  if (!new_code_pushed_to_stack) {
-    products.resize(5);
-    products.at(0).push_back(/*alloc id*/0);
-    products.at(0).push_back(0);
-    products.at(1).push_back(/*alloc id*/0);
-    products.at(1).push_back(trace_error_contents());
-    products.at(2).push_back(/*alloc id*/0);
-    products.at(2).push_back(0);
-    products.at(3).push_back(/*alloc id*/0);
-    products.at(3).push_back(trace_app_contents());
-    products.at(4).push_back(1);  // completed
-    run_code_end();
-    break;  // done with this instruction
-  }
-  else {
-    continue;  // not done with caller; don't increment current_step_index()
-  }
-}
-
-//: To show results in the sandbox Mu uses a hack: it saves the products
-//: returned by each instruction while Track_most_recent_products is true, and
-//: keeps the most recent such result around so that it can be returned as the
-//: result of a sandbox.
-
-:(before "End Globals")
-bool Track_most_recent_products = false;
-int Call_depth_to_track_most_recent_products_at = 0;
-string Most_recent_products;
-:(before "End Reset")
-Track_most_recent_products = false;
-Call_depth_to_track_most_recent_products_at = 0;
-Most_recent_products = "";
-
-:(before "End Globals")
-trace_stream* Save_trace_stream = NULL;
-string Save_trace_file;
-int Save_callstack_depth = 0;
-:(code)
-// reads a string, tries to call it as code (treating it as a test), saving
-// all errors.
-// returns true if successfully called (no errors found during load and transform)
-bool run_interactive(int address) {
-//?   cerr << "run_interactive: " << address << '\n';
-  assert(contains_key(Recipe_ordinal, "interactive") && get(Recipe_ordinal, "interactive") != 0);
-  // try to sandbox the run as best you can
-  // todo: test this
-  if (!Current_scenario) {
-    for (int i = 1; i < Reserved_for_tests; ++i)
-      Memory.erase(i);
-  }
-  string command = trim(strip_comments(read_mu_text(address)));
-//?   cerr << "command: " << command << '\n';
-  Name[get(Recipe_ordinal, "interactive")].clear();
-  run_code_begin(/*should_stash_snapshots*/true);
-  if (command.empty()) return false;
-  // don't kill the current routine on parse errors
-  routine* save_current_routine = Current_routine;
-  Current_routine = NULL;
-  // call run(string) but without the scheduling
-  load(string("recipe! interactive [\n") +
-          "local-scope\n" +
-          "screen:&:screen <- next-ingredient\n" +
-          "$start-tracking-products\n" +
-          command + "\n" +
-          "$stop-tracking-products\n" +
-          "return screen\n" +
-       "]\n");
-  transform_all();
-  Current_routine = save_current_routine;
-  if (trace_count("error") > 0) return false;
-  // now call 'sandbox' which will run 'interactive' in a separate routine,
-  // and wait for it
-  if (Save_trace_stream) {
-    ++Save_callstack_depth;
-    trace(Save_callstack_depth+1, "trace") << "run-sandboxed: incrementing callstack depth to " << Save_callstack_depth << end();
-    assert(Save_callstack_depth < Max_depth);
-  }
-  Current_routine->calls.push_front(call(get(Recipe_ordinal, "sandbox")));
-  return true;
-}
-
-//: Carefully update all state to exactly how it was -- including snapshots.
-
-:(before "End Globals")
-bool Run_profiler_stash = false;
-map<string, recipe_ordinal> Recipe_ordinal_snapshot_stash;
-map<recipe_ordinal, recipe> Recipe_snapshot_stash;
-map<string, type_ordinal> Type_ordinal_snapshot_stash;
-map<type_ordinal, type_info> Type_snapshot_stash;
-map<recipe_ordinal, map<string, int> > Name_snapshot_stash;
-map<string, vector<recipe_ordinal> > Recipe_variants_snapshot_stash;
-map<string, type_tree*> Type_abbreviations_snapshot_stash;
-vector<scenario> Scenarios_snapshot_stash;
-set<string> Scenario_names_snapshot_stash;
-
-:(code)
-void run_code_begin(bool should_stash_snapshots) {
-  // stuff to undo later, in run_code_end()
-  Hide_errors = true;
-  Disable_redefine_checks = true;
-  Run_profiler_stash = Run_profiler;
-  Run_profiler = false;
-  if (should_stash_snapshots)
-    stash_snapshots();
-  Save_trace_stream = Trace_stream;
-  Save_callstack_depth = Callstack_depth;
-  Callstack_depth = Initial_callstack_depth;
-  Trace_stream = new trace_stream;
-  if (Save_trace_stream)
-    Trace_stream->collect_depth = Save_trace_stream->collect_depth;
-}
-
-void run_code_end() {
-  Hide_errors = false;
-  Disable_redefine_checks = false;
-  Run_profiler = Run_profiler_stash;
-  Run_profiler_stash = false;
-//?   ofstream fout("sandbox.log");
-//?   fout << Trace_stream->readable_contents("");
-//?   fout.close();
-  delete Trace_stream;
-  Trace_stream = Save_trace_stream;
-  Callstack_depth = Save_callstack_depth;
-  Save_trace_stream = NULL;
-  Save_trace_file.clear();
-  Save_callstack_depth = 0;
-  Recipe.erase(get(Recipe_ordinal, "interactive"));  // keep past sandboxes from inserting errors
-  if (!Recipe_snapshot_stash.empty())
-    unstash_snapshots();
-}
-
-// keep sync'd with save_snapshots and restore_snapshots
-void stash_snapshots() {
-  assert(Recipe_ordinal_snapshot_stash.empty());
-  Recipe_ordinal_snapshot_stash = Recipe_ordinal_snapshot;
-  assert(Recipe_snapshot_stash.empty());
-  Recipe_snapshot_stash = Recipe_snapshot;
-  assert(Type_ordinal_snapshot_stash.empty());
-  Type_ordinal_snapshot_stash = Type_ordinal_snapshot;
-  assert(Type_snapshot_stash.empty());
-  Type_snapshot_stash = Type_snapshot;
-  assert(Name_snapshot_stash.empty());
-  Name_snapshot_stash = Name_snapshot;
-  assert(Recipe_variants_snapshot_stash.empty());
-  Recipe_variants_snapshot_stash = Recipe_variants_snapshot;
-  assert(Type_abbreviations_snapshot_stash.empty());
-  Type_abbreviations_snapshot_stash = Type_abbreviations_snapshot;
-  assert(Scenarios_snapshot_stash.empty());
-  Scenarios_snapshot_stash = Scenarios_snapshot;
-  assert(Scenario_names_snapshot_stash.empty());
-  Scenario_names_snapshot_stash = Scenario_names_snapshot;
-  save_snapshots();
-}
-void unstash_snapshots() {
-  restore_snapshots();
-  Recipe_ordinal_snapshot = Recipe_ordinal_snapshot_stash;  Recipe_ordinal_snapshot_stash.clear();
-  Recipe_snapshot = Recipe_snapshot_stash;  Recipe_snapshot_stash.clear();
-  Type_ordinal_snapshot = Type_ordinal_snapshot_stash;  Type_ordinal_snapshot_stash.clear();
-  Type_snapshot = Type_snapshot_stash;  Type_snapshot_stash.clear();
-  Name_snapshot = Name_snapshot_stash;  Name_snapshot_stash.clear();
-  Recipe_variants_snapshot = Recipe_variants_snapshot_stash;  Recipe_variants_snapshot_stash.clear();
-  Type_abbreviations_snapshot = Type_abbreviations_snapshot_stash;  Type_abbreviations_snapshot_stash.clear();
-  Scenarios_snapshot = Scenarios_snapshot_stash;  Scenarios_snapshot_stash.clear();
-  Scenario_names_snapshot = Scenario_names_snapshot_stash;  Scenario_names_snapshot_stash.clear();
-}
-
-:(before "End Mu Prelude")
-load(string(
-"recipe interactive [\n") +  // just a dummy version to initialize the Recipe_ordinal and so on
-"]\n" +
-"recipe sandbox [\n" +
-  "local-scope\n" +
-//?   "$print [aaa] 10/newline\n" +
-  "screen:&:screen <- new-fake-screen 30, 5\n" +
-  "routine-id:num <- start-running interactive, screen\n" +
-  "limit-time routine-id, 100000/instructions\n" +
-  "wait-for-routine routine-id\n" +
-//?   "$print [bbb] 10/newline\n" +
-  "instructions-run:num <- number-of-instructions routine-id\n" +
-  "stash instructions-run [instructions run]\n" +
-  "sandbox-state:num <- routine-state routine-id\n" +
-  "completed?:bool <- equal sandbox-state, 1/completed\n" +
-//?   "$print [completed: ] completed? 10/newline\n" +
-  "output:text <- $most-recent-products\n" +
-//?   "$print [zzz] 10/newline\n" +
-//?   "$print output\n" +
-  "errors:text <- save-errors\n" +
-  "stashes:text <- save-app-trace\n" +
-  "$cleanup-run-sandboxed\n" +
-  "return output, errors, screen, stashes, completed?\n" +
-"]\n");
-
-//: adjust errors in the sandbox
-:(before "End maybe(recipe_name) Special-cases")
-if (recipe_name == "interactive") return "";
-
-:(code)
-void test_run_interactive_comments() {
-  run(
-      "def main [\n"
-      "  1:text <- new [# ab\n"
-      "add 2, 2]\n"
-      "  2:text <- run-sandboxed 1:text\n"
-      "  3:@:char <- copy *2:text\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 52 in location 4\n"
-  );
-}
-
-:(before "End Primitive Recipe Declarations")
-_START_TRACKING_PRODUCTS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$start-tracking-products", _START_TRACKING_PRODUCTS);
-:(before "End Primitive Recipe Checks")
-case _START_TRACKING_PRODUCTS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _START_TRACKING_PRODUCTS: {
-  Track_most_recent_products = true;
-  Call_depth_to_track_most_recent_products_at = SIZE(Current_routine->calls);
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_STOP_TRACKING_PRODUCTS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$stop-tracking-products", _STOP_TRACKING_PRODUCTS);
-:(before "End Primitive Recipe Checks")
-case _STOP_TRACKING_PRODUCTS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _STOP_TRACKING_PRODUCTS: {
-  Track_most_recent_products = false;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_MOST_RECENT_PRODUCTS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$most-recent-products", _MOST_RECENT_PRODUCTS);
-:(before "End Primitive Recipe Checks")
-case _MOST_RECENT_PRODUCTS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _MOST_RECENT_PRODUCTS: {
-  products.resize(1);
-  products.at(0).push_back(/*alloc id*/0);
-  products.at(0).push_back(new_mu_text(Most_recent_products));
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-SAVE_ERRORS,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "save-errors", SAVE_ERRORS);
-:(before "End Primitive Recipe Checks")
-case SAVE_ERRORS: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SAVE_ERRORS: {
-  products.resize(1);
-  products.at(0).push_back(/*alloc id*/0);
-  products.at(0).push_back(trace_error_contents());
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-SAVE_APP_TRACE,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "save-app-trace", SAVE_APP_TRACE);
-:(before "End Primitive Recipe Checks")
-case SAVE_APP_TRACE: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case SAVE_APP_TRACE: {
-  products.resize(1);
-  products.at(0).push_back(/*alloc id*/0);
-  products.at(0).push_back(trace_app_contents());
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLEANUP_RUN_SANDBOXED,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$cleanup-run-sandboxed", _CLEANUP_RUN_SANDBOXED);
-:(before "End Primitive Recipe Checks")
-case _CLEANUP_RUN_SANDBOXED: {
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case _CLEANUP_RUN_SANDBOXED: {
-  run_code_end();
-  break;
-}
-
-:(code)
-void test_run_interactive_converts_result_to_text() {
-  // try to interactively add 2 and 2
-  run(
-      "def main [\n"
-      "  10:text <- new [add 2, 2]\n"
-      "  20:text <- run-sandboxed 10:text\n"
-      "  30:@:char <- copy *20:text\n"
-      "]\n"
-  );
-  // first letter in the output should be '4' in utf-8
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 52 in location 31\n"
-  );
-}
-
-void test_run_interactive_ignores_products_in_nested_functions() {
-  run(
-      "def main [\n"
-      "  10:text <- new [foo]\n"
-      "  20:text <- run-sandboxed 10:text\n"
-      "  30:@:char <- copy *20:text\n"
-      "]\n"
-      "def foo [\n"
-      "  40:num <- copy 1234\n"
-      "  {\n"
-      "    break\n"
-      "    reply 5678\n"
-      "  }\n"
-      "]\n"
-  );
-  // no product should have been tracked
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 30\n"
-  );
-}
-
-void test_run_interactive_ignores_products_in_previous_instructions() {
-  run(
-      "def main [\n"
-      "  10:text <- new [\n"
-      "    add 1, 1\n"  // generates a product
-      "    foo]\n"  // no products
-      "  20:text <- run-sandboxed 10:text\n"
-      "  30:@:char <- copy *20:text\n"
-      "]\n"
-      "def foo [\n"
-      "  40:num <- copy 1234\n"
-      "  {\n"
-      "    break\n"
-      "    reply 5678\n"
-      "  }\n"
-      "]\n"
-  );
-  // no product should have been tracked
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 30\n"
-  );
-}
-
-void test_run_interactive_remembers_products_before_final_label() {
-  run(
-      "def main [\n"
-      "  10:text <- new [\n"
-      "    add 1, 1\n"  // generates a product
-      "    +foo]\n"  // no products
-      "  20:text <- run-sandboxed 10:text\n"
-      "  30:@:char <- copy *20:text\n"
-      "]\n"
-      "def foo [\n"
-      "  40:num <- copy 1234\n"
-      "  {\n"
-      "    break\n"
-      "    reply 5678\n"
-      "  }\n"
-      "]\n"
-  );
-  // product tracked
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 50 in location 31\n"
-  );
-}
-
-void test_run_interactive_returns_text() {
-  // try to interactively add 2 and 2
-  run(
-      "def main [\n"
-      "  1:text <- new [\n"
-      "    x:text <- new [a]\n"
-      "    y:text <- new [b]\n"
-      "    z:text <- append x:text, y:text\n"
-      "  ]\n"
-      "  10:text <- run-sandboxed 1:text\n"
-//?       "  $print 10:text 10/newline\n"
-      "  20:@:char <- copy *10:text\n"
-      "]\n"
-  );
-  // output contains "ab"
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 97 in location 21\n"
-      "mem: storing 98 in location 22\n"
-  );
-}
-
-void test_run_interactive_returns_errors() {
-  run(
-      "def main [\n"
-         // run a command that generates an error
-      "  10:text <- new [x:num <- copy 34\n"
-      "get x:num, foo:offset]\n"
-      "  20:text, 30:text <- run-sandboxed 10:text\n"
-      "  40:@:char <- copy *30:text\n"
-      "]\n"
-  );
-  // error should be "unknown element foo in container number"
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 117 in location 41\n"
-      "mem: storing 110 in location 42\n"
-      "mem: storing 107 in location 43\n"
-      "mem: storing 110 in location 44\n"
-      // ...
-  );
-}
-
-void test_run_interactive_with_comment() {
-  run(
-      "def main [\n"
-         // 2 instructions, with a comment after the first
-      "  10:text <- new [a:num <- copy 0  # abc\n"
-      "b:num <- copy 0\n"
-      "]\n"
-      "  20:text, 30:text <- run-sandboxed 10:text\n"
-      "]\n"
-  );
-  // no errors
-  // skip alloc id
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 30\n"
-      "mem: storing 0 in location 31\n"
-  );
-}
-
-:(after "Running One Instruction")
-if (Track_most_recent_products && SIZE(Current_routine->calls) == Call_depth_to_track_most_recent_products_at
-    && !current_instruction().is_label
-    && current_instruction().name != "$stop-tracking-products") {
-  Most_recent_products = "";
-}
-:(before "End Running One Instruction")
-if (Track_most_recent_products && SIZE(Current_routine->calls) == Call_depth_to_track_most_recent_products_at) {
-  Most_recent_products = track_most_recent_products(current_instruction(), products);
-//?   cerr << "most recent products: " << Most_recent_products << '\n';
-}
-:(code)
-string track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) {
-  ostringstream out;
-  for (int i = 0; i < SIZE(products); ++i) {
-    // A sandbox can print a string result, but only if it is actually saved
-    // to a variable in the sandbox, because otherwise the results are
-    // reclaimed before the sandbox sees them. So you get these interactions
-    // in the sandbox:
-    //
-    //    new [abc]
-    //    => <address>
-    //
-    //    x:text <- new [abc]
-    //    => abc
-    if (i < SIZE(instruction.products)) {
-      if (is_mu_text(instruction.products.at(i))) {
-        if (SIZE(products.at(i)) != 2) continue;  // weak silent check for address
-        out << read_mu_text(products.at(i).at(/*skip alloc id*/1)) << '\n';
-        continue;
-      }
-    }
-    for (int j = 0; j < SIZE(products.at(i)); ++j)
-      out << no_scientific(products.at(i).at(j)) << ' ';
-    out << '\n';
-  }
-  return out.str();
-}
-
-:(code)
-string strip_comments(string in) {
-  ostringstream result;
-  for (int i = 0; i < SIZE(in); ++i) {
-    if (in.at(i) != '#') {
-      result << in.at(i);
-    }
-    else {
-      while (i+1 < SIZE(in) && in.at(i+1) != '\n')
-        ++i;
-    }
-  }
-  return result.str();
-}
-
-int stringified_value_of_location(int address) {
-  // convert to string
-  ostringstream out;
-  out << no_scientific(get_or_insert(Memory, address));
-  return new_mu_text(out.str());
-}
-
-int trace_error_contents() {
-  if (!Trace_stream) return 0;
-  ostringstream out;
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
-    if (p->label != "error") continue;
-    out << p->contents;
-    if (*--p->contents.end() != '\n') out << '\n';
-  }
-  string result = out.str();
-  truncate(result);
-  if (result.empty()) return 0;
-  return new_mu_text(result);
-}
-
-int trace_app_contents() {
-  if (!Trace_stream) return 0;
-  ostringstream out;
-  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
-    if (p->depth != App_depth) continue;
-    out << p->contents;
-    if (*--p->contents.end() != '\n') out << '\n';
-  }
-  string result = out.str();
-  if (result.empty()) return 0;
-  truncate(result);
-  return new_mu_text(result);
-}
-
-void truncate(string& x) {
-  if (SIZE(x) > 1024) {
-    x.erase(1024);
-    *x.rbegin() = '\n';
-    *++x.rbegin() = '.';
-    *++++x.rbegin() = '.';
-  }
-}
-
-//: simpler version of run-sandboxed: doesn't do any running, just loads
-//: recipes and reports errors.
-
-:(before "End Primitive Recipe Declarations")
-RELOAD,
-:(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "reload", RELOAD);
-:(before "End Primitive Recipe Checks")
-case RELOAD: {
-  if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end();
-    break;
-  }
-  if (!is_mu_text(inst.ingredients.at(0))) {
-    raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
-    break;
-  }
-  break;
-}
-:(before "End Primitive Recipe Implementations")
-case RELOAD: {
-  restore_non_recipe_snapshots();
-  string code = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
-  run_code_begin(/*should_stash_snapshots*/false);
-  routine* save_current_routine = Current_routine;
-  Current_routine = NULL;
-  Sandbox_mode = true;
-  vector<recipe_ordinal> recipes_reloaded = load(code);
-  transform_all();
-  Trace_stream->newline();  // flush trace
-  Sandbox_mode = false;
-  Current_routine = save_current_routine;
-  products.resize(1);
-  products.at(0).push_back(/*alloc id*/0);
-  products.at(0).push_back(trace_error_contents());
-  run_code_end();  // wait until we're done with the trace contents
-  break;
-}
-
-:(code)
-void test_reload_loads_function_definitions() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:text <- new [recipe foo [\n"
-      "    1:num/raw <- copy 34\n"
-      "  ]]\n"
-      "  reload x\n"
-      "  run-sandboxed [foo]\n"
-      "  2:num/raw <- copy 1:num/raw\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 2\n"
-  );
-}
-
-void test_reload_continues_past_error() {
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:text <- new [recipe foo [\n"
-      "    get 1234:num, foo:offset\n"
-      "  ]]\n"
-      "  reload x\n"
-      "  1:num/raw <- copy 34\n"
-      "]\n"
-  );
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 34 in location 1\n"
-  );
-}
-
-void test_reload_can_repeatedly_load_container_definitions() {
-  // define a container and try to create it (merge requires knowing container size)
-  run(
-      "def main [\n"
-      "  local-scope\n"
-      "  x:text <- new [\n"
-      "    container foo [\n"
-      "      x:num\n"
-      "      y:num\n"
-      "    ]\n"
-      "    recipe bar [\n"
-      "      local-scope\n"
-      "      x:foo <- merge 34, 35\n"
-      "    ]\n"
-      "  ]\n"
-         // save warning addresses in locations of type 'number' to avoid
-         // spurious changes to them due to 'abandon'
-      "  10:text/raw <- reload x\n"
-      "  20:text/raw <- reload x\n"
-      "]\n"
-  );
-  // no errors on either load
-  CHECK_TRACE_CONTENTS(
-      "mem: storing 0 in location 10\n"
-      "mem: storing 0 in location 11\n"
-      "mem: storing 0 in location 20\n"
-      "mem: storing 0 in location 21\n"
-  );
-}
diff --git a/archive/2.vm/998check_type_pointers.cc b/archive/2.vm/998check_type_pointers.cc
deleted file mode 100644
index da19cf3e..00000000
--- a/archive/2.vm/998check_type_pointers.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-//: enable this when tracking down null types
-//: (but it interferes with edit/; since recipes created in the environment
-//: can raise warnings here which will stop running the entire environment)
-//? :(before "End Transform All")
-//? check_type_pointers();
-//? 
-//? :(code)
-//? void check_type_pointers() {
-//?   for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {
-//?     if (any_type_ingredient_in_header(p->first)) continue;
-//?     const recipe& r = p->second;
-//?     for (long long int i = 0; i < SIZE(r.steps); ++i) {
-//?       const instruction& inst = r.steps.at(i);
-//?       for (long long int j = 0; j < SIZE(inst.ingredients); ++j) {
-//?         if (!inst.ingredients.at(j).type) {
-//?           raise_error << maybe(r.name) << " '" << inst.to_string() << "' -- " << inst.ingredients.at(j).to_string() << " has no type\n" << end();
-//?           return;
-//?         }
-//?         if (!inst.ingredients.at(j).properties.at(0).second) {
-//?           raise_error << maybe(r.name) << " '" << inst.to_string() << "' -- " << inst.ingredients.at(j).to_string() << " has no type name\n" << end();
-//?           return;
-//?         }
-//?       }
-//?       for (long long int j = 0; j < SIZE(inst.products); ++j) {
-//?         if (!inst.products.at(j).type) {
-//?           raise_error << maybe(r.name) << " '" << inst.to_string() << "' -- " << inst.products.at(j).to_string() << " has no type\n" << end();
-//?           return;
-//?         }
-//?         if (!inst.products.at(j).properties.at(0).second) {
-//?           raise_error << maybe(r.name) << " '" << inst.to_string() << "' -- " << inst.products.at(j).to_string() << " has no type name\n" << end();
-//?           return;
-//?         }
-//?       }
-//?     }
-//?   }
-//? }
diff --git a/archive/2.vm/999spaces.cc b/archive/2.vm/999spaces.cc
deleted file mode 100644
index adbbf8a9..00000000
--- a/archive/2.vm/999spaces.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-//: Since different layers all carve out different parts of various namespaces
-//: (recipes, memory, etc.) for their own use, there's no previous place where
-//: we can lay out the big picture of what uses what. So we'll do that here
-//: and just have to manually remember to update it when we move boundaries
-//: around.
-//:
-//:: Memory
-//:
-//: Location 0 - unused (since it can help uncover bugs)
-//: Locations 1-899 - reserved for tests
-//: Locations 900-999 - reserved for predefined globals in Mu scenarios, like keyboard, screen, etc.
-:(before "End Reset")
-assert(Max_variables_in_scenarios == 900);
-//: Locations 1000 ('Reserved_for_tests') onward - available to the allocator in chunks of size Initial_memory_per_routine.
-assert(Reserved_for_tests == 1000);
-
-//:: Recipes
-//:
-//: 0 - unused (IDLE; do nothing)
-//: 1-199 - primitives
-assert(MAX_PRIMITIVE_RECIPES < 200);
-//: 200-999 - defined in .mu files as sequences of primitives
-assert(Next_recipe_ordinal == 1000);
-//: 1000 onwards - reserved for tests, cleared between tests
-
-//:: Depths for tracing
-//:
-//: 0 - errors
-//: 1-99 - app-level trace statements in Mu
-//: 100-9999 - call-stack statements (mostly label run)
-assert(Initial_callstack_depth == 100);
-
-//:: Summary of transforms and their dependencies
-//: begin transforms
-//:   begin instruction inserting transforms
-//:     52 insert fragments
-//:      ↳ 52.2 check fragments
-//:   ---
-//:     53 rewrite 'stash' instructions
-//:   end instruction inserting transforms
-//:
-//:   begin instruction modifying transforms
-//:     56.2 check header ingredients
-//:      ↳ 56.4 fill in return ingredients
-//:     48 check or set types by name
-//:
-//:     begin type modifying transforms
-//:       56.3 deduce types from header
-//:     ---
-//:       30 check or set invalid containers
-//:     end type modifying transforms
-//:         ↱ 46 collect surrounding spaces
-//:      ↳ 42 transform names
-//:         ↳ 57 static dispatch
-//:   ---
-//:     13 update instruction operation
-//:     40 transform braces
-//:     41 transform labels
-//:   end instruction modifying transforms
-//:    ↳ 60 check immutable ingredients
-//:
-//:   begin checks
-//:   ---
-//:     21 check instruction
-//:     ↳ 61 check indirect calls against header
-//:     ↳ 56 check calls against header
-//:     ↳ 43 transform 'new' to 'allocate'
-//:     30 check merge calls
-//:     36 check types of return instructions
-//:     43 check default space
-//:     56 check return instructions against header
-//:   end checks
-//: end transforms
-
-//:: Summary of type-checking in different phases
-//: when dispatching instructions we accept first recipe that:
-//:   strictly matches all types
-//:   maps literal 0 or literal 1 to boolean for some ingredients
-//:   performs some other acceptable type conversion
-//:     literal 0 -> address
-//:     literal -> character
-//: when checking instructions we ensure that types match, and that literals map to some scalar
-//:   (address can only map to literal 0)
-//:   (boolean can only map to literal 0 or literal 1)
-//:     (but conditionals can take any scalar)
-//: at runtime we perform no checks
diff --git a/archive/2.vm/Readme.md b/archive/2.vm/Readme.md
deleted file mode 100644
index a7394530..00000000
--- a/archive/2.vm/Readme.md
+++ /dev/null
@@ -1,449 +0,0 @@
-Mu explores ways to turn arbitrary manual tests into reproducible automated
-tests. Hoped-for benefits:
-
-1. Projects release with confidence without requiring manual QA or causing
-   regressions for their users.
-
-1. Open source projects become easier for outsiders to comprehend, since they
-   can more confidently try out changes with the knowledge that they'll get
-   rapid feedback if they break something. Projects also become more
-   *rewrite-friendly* for insiders: it's easier to leave your project's
-   historical accidents and other baggage behind if you can be confident of
-   not causing regressions.
-
-1. It becomes easier to teach programming by emphasizing tests far earlier
-   than we do today.
-
-The hypothesis is that designing the entire system to be testable from day 1
-and from the ground up would radically impact the culture of an eco-system in
-a way that no bolted-on tool or service at higher levels can replicate. It
-would make it easier to write programs that can be [easily understood by newcomers](http://akkartik.name/about).
-It would reassure authors that an app is free from regression if all automated
-tests pass. It would make the stack easy to rewrite and simplify by dropping
-features, without fear that a subset of targeted apps might break. As a result
-people might fork projects more easily, and also exchange code between
-disparate forks more easily (copy the tests over, then try copying code over
-and making tests pass, rewriting and polishing where necessary). The community
-would have in effect a diversified portfolio of forks, a “wavefront” of
-possible combinations of features and alternative implementations of features
-instead of the single trunk with monotonically growing complexity that we get
-today. Application writers who wrote thorough tests for their apps (something
-they just can’t do today) would be able to bounce around between forks more
-easily without getting locked in to a single one as currently happens.
-
-In this quest, Mu is currently experimenting with the following mechanisms:
-
-1. New, testable interfaces for the operating system. Currently manual tests
-   are hard to automate because a file you rely on might be deleted, the
-   network might go down, etc. To make manual tests reproducible it suffices
-   to improve the 15 or so OS syscalls through which a computer talks to the
-   outside world. We have to allow programs to transparently write to a fake
-   screen, read from a fake disk/network, etc. In Mu, printing to screen
-   explicitly takes a screen object, so it can be called on the real screen,
-   or on a fake screen inside tests, so that we can then check the expected
-   state of the screen at the end of a test. Here's a test for a little
-   text-mode chessboard program in Mu (delimiting the edge of the 'screen'
-   with dots):
-
-   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img alt='a screen test' src='https://github.com/akkartik/mu/html/archive/2.vm/chessboard-test.png'>
-
-   We've built up similarly *dependency-injected* interfaces to the keyboard,
-   mouse, disk and network.
-
-1. Support for testing side-effects like performance, deadlock-freedom,
-   race-freeness, memory usage, etc. Mu's *white-box tests* can check not just
-   the results of a function call, but also the presence or absence of
-   specific events in the log of its progress. For example, here's a test that
-   our string-comparison function doesn't scan individual characters unless it
-   has to:
-
-   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img alt='white-box test' src='https://github.com/akkartik/mu/html/archive/2.vm/tracing-test.png'>
-
-   Another example: if a sort function logs each swap, a performance test can
-   check that the number of swaps doesn't quadruple when the size of the input
-   doubles.
-
-   Besides expanding the scope of tests, this ability also allows more
-   radical refactoring without needing to modify tests. All Mu's tests call a
-   top-level function rather than individual sub-systems directly. As a result
-   the way the subsystems are invoked can be radically changed (interface
-   changes, making synchronous functions asynchronous, etc.). As long as the
-   new versions emit the same implementation-independent events in the logs,
-   the tests will continue to pass. ([More information.](http://akkartik.name/post/tracing-tests))
-
-1. Organizing code and tests in layers of functionality, so that outsiders can
-   build simple and successively more complex versions of a project, gradually
-   enabling more peripheral features. Think of it as a cleaned-up `git log`
-   for the project. ([More information.](http://akkartik.name/post/wart-layers))
-
-These mechanisms exist in the context of a low-level statement-oriented
-language (like Basic, or Assembly). The language is as powerful as C for
-low-level pointer operations and manual memory management, but much safer,
-paying some run-time overhead to validate pointers. It also provides a number
-of features usually associated with higher-level languages: strong
-type-safety, function overloading, lexical scope, generic functions,
-higher-order functions, and [delimited continuations](http://akkartik.name/coroutines-in-mu).
-
-*Taking Mu for a spin*
-
-Mu is currently implemented in C++ and requires a Unix-like environment. It's
-been tested on Ubuntu, Mac OS X and OpenBSD; on x86, x86\_64 and ARMv7; and on
-recent versions of GCC and Clang. Since it uses no bleeding-edge language
-features and has no exotic dependencies, it should work with most reasonable
-versions, compilers or processors.
-
-Running Mu will always (re)compile it if necessary:
-
-  ```shell
-  $ cd mu/archives/2.vm
-  $ ./mu
-  ```
-
-As a simple example, here's a program with some arithmetic:
-
-<img alt='code example' src='https://github.com/akkartik/mu/html/archive/2.vm/example1.png'>
-
-Mu functions are lists of instructions, one to a line. Each instruction
-operates on some *ingredients* and returns some *products*.
-
-  ```
-  [products] <- instruction [ingredients]
-  ```
-
-Product and ingredient *reagents* cannot contain instructions or infix
-expressions. On the other hand, you can have any number of them. In
-particular, you can have any number of products. For example, you can perform
-integer division as follows:
-
-  ```
-  quotient:number, remainder:number <- divide-with-remainder 11, 3
-  ```
-
-Each reagent consists of a name and its type, separated by a colon. You only
-have to specify the type the first time you mention a name, but you can be
-more explicit if you choose. Types can be multiple words and even arbitrary
-trees, like:
-
-  ```nim
-  x:array:number:3  # x is an array of 3 numbers
-  y:list:number  # y is a list of numbers
-  # ':' is just syntactic sugar
-  {z: (map (address array character) (list number))}   # map from string to list of numbers
-  ```
-
-Try out the program now:
-
-  ```shell
-  $ ./mu example1.mu
-  $
-  ```
-
-Not much to see yet, since it doesn't print anything. To print the result, try
-adding the instruction `$print a` to the function.
-
----
-
-Here's a second example, of a function that can take ingredients:
-
-<img alt='fahrenheit to celsius' src='https://github.com/akkartik/mu/html/archive/2.vm/f2c-1.png'>
-
-Functions can specify headers showing their expected ingredients and products,
-separated by `->` (unlike the `<-` in calls).
-
-Once defined, functions can be called just like primitives. No need to mess
-with a `CALL` instruction or push/pop arguments to the stack.
-
-Since Mu is a low-level VM language, it provides extra control at the cost of
-verbosity. Using `local-scope`, you have explicit control over stack frames to
-isolate your functions in a type-safe manner. You can also create more
-sophisticated setups like closures. One consequence of this extra control: you
-have to explicitly `load-ingredients` after you set up the stack.
-
-An alternative syntax is what the above example is converted to internally:
-
-<img alt='fahrenheit to celsius desugared' src='https://github.com/akkartik/mu/html/archive/2.vm/f2c-2.png'>
-
-The header gets dropped after checking types at call-sites, and after
-replacing `load-ingredients` with explicit instructions to load each
-ingredient separately, and to explicitly return products to the caller. After
-this translation functions are once again just lists of instructions.
-
-This alternative syntax isn't just an implementation detail. It turns out to
-be easier to teach functions to non-programmers by starting with this syntax,
-so that they can visualize a pipe from caller to callee, and see the names of
-variables get translated one by one through the pipe.
-
----
-
-A third example, this time illustrating conditionals:
-
-<img alt='factorial example' src='https://github.com/akkartik/mu/html/archive/2.vm/factorial.png'>
-
-In spite of how it looks, this is still just a list of instructions and
-labels. Internally, the instructions `break` and `loop` get converted to
-`jump` instructions to after the enclosing `}` or `{` labels, respectively.
-
-Try out the factorial program now:
-
-  ```shell
-  $ ./mu factorial.mu
-  result: 120  # factorial of 5
-  ```
-
-You can also run its unit tests:
-
-  ```shell
-  $ ./mu test factorial.mu
-  ```
-
-Here's what one of the tests inside `factorial.mu` looks like:
-
-<img alt='test example' src='https://github.com/akkartik/mu/html/archive/2.vm/factorial-test.png'>
-
-Every test conceptually spins up a really lightweight virtual machine, so you
-can do things like check the value of specific locations in memory. You can
-also print to screen and check that the screen contains what you expect at the
-end of a test. For example, you've seen earlier how `chessboard.mu` checks the
-initial position of a game of chess (delimiting the edges of the screen with
-dots):
-
-<img alt='screen test' src='https://github.com/akkartik/mu/html/archive/2.vm/chessboard-test.png'>
-
-Similarly you can fake the keyboard to pretend someone typed something:
-
-<img alt='fake keyboard' src='https://github.com/akkartik/mu/html/archive/2.vm/fake-keyboard.png'>
-
-..or clicked somewhere:
-
-<img alt='fake console (keyboard, mouse, ..)' src='https://github.com/akkartik/mu/html/archive/2.vm/fake-console.png'>
-
-Within tests you can map arbitrary paths (local files or URLs) to contents:
-
-<img alt='fake file-system and network' src='https://github.com/akkartik/mu/html/archive/2.vm/resources.png'>
-
-As we add graphics, audio, and so on, we'll augment scenarios with
-corresponding abilities.
-
----
-
-Mu assumes that all ingredients passed in to functions are immutable by
-default -- *unless* they are also products. So this program will throw an
-error:
-
-<img alt='immutable ingredient triggering an error' src='https://github.com/akkartik/mu/html/archive/2.vm/immutable-error.png'>
-
-To modify `foo`'s ingredient, you have to add it to the list of products
-returned:
-
-<img alt='mutable ingredient' src='https://github.com/akkartik/mu/html/archive/2.vm/mutable.png'>
-
-The names of the variables are important here: a function that takes an
-(immutable) address and returns a different one is different from a function
-that takes a mutable address (and also returns it).
-
-These immutability checks can be annoying, but the benefit they provide is
-that you can always tell what a function modifies just by looking at its
-header. In combination with dependency-injected hardware, they provide all the
-benefits of [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency)
-that we typically associate with purely functional languages -- along with the
-option of imperatively modifying variables willy-nilly.
-
----
-
-You can append arbitrary properties to reagents besides types. Just separate
-them with slashes.
-
-  ```nim
-  x:array:number:3/uninitialized
-  y:string/tainted:yes
-  z:number/assign-once:true/assigned:false
-  ```
-
-Most properties are meaningless to Mu, and it'll silently skip them when
-running, but they are fodder for *meta-programs* to check or modify your
-programs, a task other languages typically hide from their programmers. For
-example, where other programmers are restricted to the checks their type
-system permits and forces them to use, you'll learn to create new checks that
-make sense for your specific program. If it makes sense to perform different
-checks in different parts of your program, you'll be able to do that.
-
-You can imagine each reagent as a table, rows separated by slashes, columns
-within a row separated by colons. So the last example above would become
-something like this:
-
-  ```
-  z           : number   /
-  assign-once : true     /
-  assigned    : false
-  ```
-
----
-
-An alternative way to define factorial is by inserting labels and later
-inserting code at them.
-
-<img alt='literate programming' src='https://github.com/akkartik/mu/html/archive/2.vm/tangle.png'>
-
-(You'll find this version in `tangle.mu`.)
-
-By convention we use the prefix '+' to indicate function-local label names you
-can jump to, and surround in '<>' global label names for inserting code at.
-
----
-
-Another example, this time with concurrency:
-
-<img alt='forking concurrent routines' src='https://github.com/akkartik/mu/html/archive/2.vm/fork.png'>
-
-  ```shell
-  $ ./mu fork.mu
-  ```
-
-Notice that it repeatedly prints either '34' or '35' at random. Hit ctrl-c to
-stop.
-
-[Yet another example](https://github.com/akkartik/mu/blob/master/archive/2.vm/channel.mu) forks
-two 'routines' that communicate over a channel:
-
-  ```shell
-  $ ./mu channel.mu
-  produce: 0
-  produce: 1
-  produce: 2
-  produce: 3
-  consume: 0
-  consume: 1
-  consume: 2
-  produce: 4
-  consume: 3
-  consume: 4
-
-  # The exact order above might shift over time, but you'll never see a number
-  # consumed before it's produced.
-  ```
-
-Channels are the unit of synchronization in Mu. Blocking on a channel is the
-only way for the OS to put a task to sleep. The plan is to do all I/O over
-channels.
-
-Routines are expected to communicate purely by message passing, though nothing
-stops them from sharing memory since all routines share a common address
-space. However, idiomatic Mu will make it hard to accidentally read or
-clobber random memory locations. Bounds checking is baked deeply into
-the semantics, and using pointers after freeing them immediately fails.
-
----
-
-Mu has a programming environment:
-
-  ```shell
-  $ ./mu edit
-  ```
-
-Screenshot:
-
-<img alt='programming environment' src='https://github.com/akkartik/mu/html/archive/2.vm/edit.png'>
-
-You write functions on the left and try them out in *sandboxes* on the right.
-Hit F4 to rerun all sandboxes with the latest version of the code. More
-details: http://akkartik.name/post/mu. Beware, it won't save your edits by
-default. But if you create a sub-directory called `lesson/` under `mu/` it
-will. If you turn that directory into a git repo with `git init`, it will also
-back up your changes each time you hit F4. Use the provided `new_lesson`
-script to take care of these details.
-
-Once you have a sandbox you can click on its result to mark it as expected:
-
-<img alt='expected result' src='https://github.com/akkartik/mu/html/archive/2.vm/expected-result.png'>
-
-Later if the result changes it'll be flagged in red to draw your attention to
-it. Thus, manually tested sandboxes become reproducible automated tests.
-
-<img alt='unexpected result' src='https://github.com/akkartik/mu/html/archive/2.vm/unexpected-result.png'>
-
-Another feature: Clicking on the code in a sandbox expands its trace for you
-to browse. To add to the trace, use `stash`. For example:
-
-  ```nim
-  stash [first ingredient is], x
-  ```
-
-Invaluable at times for understanding program behavior, but it won't clutter
-up your screen by default.
-
----
-
-If you're still reading, here are some more things to check out:
-
-a) Look at the [chessboard program](https://github.com/akkartik/mu/blob/master/archive/2.vm/chessboard.mu)
-for a more complex example with tests of blocking reads from the keyboard and
-what gets printed to the screen -- things we don't typically associate with
-automated tests.
-
-b) Try running the tests:
-
-  ```shell
-  $ ./mu test
-  ```
-
-c) Check out [the programming environment](https://github.com/akkartik/mu/tree/master/edit#readme),
-the largest app built so far in Mu.
-
-d) Check out the tracing infrastructure which gives you a maps-like zoomable
-UI for browsing Mu's traces:
-
-  ```shell
-  $ ./mu --trace nqueens.mu  # just an example
-  saving trace to 'last_run'
-  $ ./browse_trace/browse_trace last_run
-  # hit 'q' to exit
-  ```
-
-For more details see the [Readme](browse_trace/Readme.md).
-
-e) Look at the `build` scripts. Mu's compilation process is itself designed to
-support staged learning. Each of the scripts (`build0`, `build1`, `build2`,
-etc.) is self-contained and can compile the project by itself. Successive
-versions add new features and configurability -- and complexity -- to the
-compilation process.
-
-f) Try skimming the source code. You should be able to get a pretty good sense
-for how things work just by skimming the files in order, skimming the top of
-each file and ignoring details lower down.
-[Some details on my unconventional approach to organizing projects.](http://akkartik.name/post/four-repos)
-
-**Credits**
-
-Mu builds on many ideas that have come before, especially:
-
-- [Peter Naur](http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22)
-  for articulating the paramount problem of programming: communicating a
-  codebase to others;
-- [Christopher Alexander](http://www.amazon.com/Notes-Synthesis-Form-Harvard-Paperbacks/dp/0674627512)
-  and [Richard Gabriel](http://dreamsongs.net/Files/PatternsOfSoftware.pdf) for
-  the intellectual tools for reasoning about the higher order design of a
-  codebase;
-- Unix and C for showing us how to co-evolve language and OS, and for teaching
-  the (much maligned, misunderstood and underestimated) value of concise
-  *implementation* in addition to a clean interface;
-- Donald Knuth's [literate programming](http://www.literateprogramming.com/knuthweb.pdf)
-  for liberating "code for humans to read" from the tyranny of compiler order;
-- [David Parnas](http://www.cs.umd.edu/class/spring2003/cmsc838p/Design/criteria.pdf)
-  and others for highlighting the value of separating concerns and stepwise
-  refinement;
-- [Lisp](http://www.paulgraham.com/rootsoflisp.html) for showing the power of
-  dynamic languages, late binding and providing the right primitives *a la
-  carte*, especially lisp macros;
-- The folklore of debugging by print and the trace facility in many lisp
-  systems;
-- Automated tests for showing the value of developing programs inside an
-  elaborate harness;
-- [Python doctest](http://docs.python.org/2/library/doctest.html) for
-  exemplifying interactive documentation that doubles as tests;
-- [ReStructuredText](https://en.wikipedia.org/wiki/ReStructuredText)
-  and [its antecedents](https://en.wikipedia.org/wiki/Setext) for showing that
-  markup can be clean;
-- BDD for challenging us all to write tests at a higher level;
-- JavaScript and CSS for demonstrating the power of a DOM for complex
-  structured documents.
-- Rust for demonstrating that a system-programming language can be safe.
diff --git a/archive/2.vm/args.mu b/archive/2.vm/args.mu
deleted file mode 100644
index 3726f097..00000000
--- a/archive/2.vm/args.mu
+++ /dev/null
@@ -1,8 +0,0 @@
-# To provide commandline args to a Mu program, use '--'. In this case:
-#   $ ./mu args.mu -- abc
-#   abc
-def main text:text [
-  local-scope
-  load-inputs
-  $print text 10/newline
-]
diff --git a/archive/2.vm/build0 b/archive/2.vm/build0
deleted file mode 100755
index f45a72d2..00000000
--- a/archive/2.vm/build0
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-# Compile mu from scratch.
-
-set -v
-set -e  # stop immediately on error
-
-cd ../../tangle
-  # auto-generate various lists (ending in '_list' by convention) {
-  # list of types
-  {
-    grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
-    grep -h "^typedef " [0-9]*.cc
-  }  > type_list
-  # list of function declarations, so I can define them in any order
-  grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  > function_list
-  # list of code files to compile
-  ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  > file_list
-  # list of test files to compile
-  ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  > test_file_list
-  # list of tests to run
-  grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  > test_list
-  grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
-  # }
-  # Now that we have all the _lists, compile 'tangle'
-  g++ -std=c++98 -g -O2 boot.cc -o tangle
-  ./tangle test
-cd ../archive/2.vm
-
-cd termbox
-  gcc -g -O2 -c termbox.c
-  gcc -g -O2 -c utf8.c
-  ar rcs libtermbox.a *.o
-cd ..
-
-../../tangle/tangle [0-9]*.cc > mu.cc
-# auto-generate function declarations, so I can define them in any order
-# functions start out unindented, have all args on the same line, and end in ') {'
-#
-#                                      \/ ignore struct/class methods
-grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  > function_list
-# auto-generate list of tests to run
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  > test_list
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
-g++ -std=c++98 -g -O2 mu.cc termbox/libtermbox.a -o mu_bin
-
-cat [0-9]*.mu > core.mu
diff --git a/archive/2.vm/build1 b/archive/2.vm/build1
deleted file mode 100755
index 66bdb003..00000000
--- a/archive/2.vm/build1
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/sh
-# Alternative to build0 that supports a --until flag to include only a subset
-# of layers.
-#   $ ./build1 --until 050
-UNTIL_LAYER=${2:-zzz}
-
-set -v
-set -e  # stop immediately on error
-
-# Some environment variables that can be passed in. For example, to turn off
-# optimization:
-#   $ CFLAGS=-g ./build1
-test "$CXX" || export CXX=c++
-test "$CC" || export CC=cc
-test "$CFLAGS" || export CFLAGS="-g -O2"
-export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing"
-export CXXFLAGS="-std=c++98 $CFLAGS"  # CI has an ancient version; don't expect recent dialects
-
-# Outline:
-# [0-9]*.cc -> mu.cc -> mu_bin
-# (layers)   |        |
-#          tangle   $CXX
-
-$CXX $CFLAGS ../../enumerate/enumerate.cc -o ../../enumerate/enumerate
-
-cd ../../tangle
-  # auto-generate various lists (ending in '_list' by convention) {
-  # list of types
-  {
-    grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
-    grep -h "^typedef " [0-9]*.cc
-  }  > type_list
-  # list of function declarations, so I can define them in any order
-  grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  > function_list
-  # list of code files to compile
-  ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  > file_list
-  # list of test files to compile
-  ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  > test_file_list
-  # list of tests to run
-  grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  > test_list
-  grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
-  # }
-  # Now that we have all the _lists, compile 'tangle'
-  $CXX $CXXFLAGS boot.cc -o tangle
-  ./tangle test
-cd ../archive/2.vm
-
-cd termbox
-  $CC $CFLAGS -c termbox.c
-  $CC $CFLAGS -c utf8.c
-  ar rcs libtermbox.a *.o
-cd ..
-
-LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
-../../tangle/tangle $LAYERS  > mu.cc
-# auto-generate function declarations, so I can define them in any order
-# functions start out unindented, have all args on the same line, and end in ') {'
-#
-#                                      \/ ignore struct/class methods
-grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  > function_list
-# auto-generate list of tests to run
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  > test_list
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
-$CXX $CXXFLAGS mu.cc termbox/libtermbox.a -o mu_bin
-
-## [0-9]*.mu -> core.mu
-
-MU_LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.mu$') || exit 0  # ok if no .mu files
-cat $MU_LAYERS  > core.mu
diff --git a/archive/2.vm/build2 b/archive/2.vm/build2
deleted file mode 100755
index c6d5ef76..00000000
--- a/archive/2.vm/build2
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/bin/sh
-# Alternative to build1 that tries to avoid redoing redundant work.
-# Also splits compilation into multiple .cc files (see 'cleave' below).
-# Faster than build1 for recompiling after small changes.
-#
-# For details on the basic form of this script, see https://notabug.org/akkartik/basic-build.
-
-set -e  # stop immediately on error
-
-# Some environment variables that can be passed in. For example, to turn off
-# optimization:
-#   $ CFLAGS=-g ./build2
-test "$CXX" || export CXX=c++
-test "$CC" || export CC=cc
-test "$CFLAGS" || export CFLAGS="-g -O2"
-export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing"
-export CXXFLAGS="-std=c++98 $CFLAGS"  # CI has an ancient version; don't expect recent dialects
-
-# Outline:
-# [0-9]*.cc -> mu.cc -> .build/*.cc -> .build/*.o -> .build/mu_bin
-# (layers)   |        |              |             |
-#          tangle  cleave          $CXX          $CXX
-
-# can also be called with a layer to only build until
-#   $ ./build2 --until 050
-UNTIL_LAYER=${2:-zzz}
-
-# there's two mechanisms for fast builds here:
-# - if a command is quick to run, always run it but update the result only on any change
-# - otherwise run it only if the output is 'older_than' the inputs
-#
-# avoid combining both mechanisms for a single file
-# otherwise you'll see spurious messages about files being updated
-# risk: a file may unnecessarily update without changes, causing unnecessary work downstream
-
-# return 1 if $1 is older than _any_ of the remaining args
-older_than() {
-  local target=$1
-  shift
-  if [ ! -e $target ]
-  then
-#?     echo "$target doesn't exist"
-    echo "updating $target" >&2
-    return 0  # success
-  fi
-  local f
-  for f in $*
-  do
-    if [ $f -nt $target ]
-    then
-      echo "updating $target" >&2
-      return 0  # success
-    fi
-  done
-  return 1  # failure
-}
-
-# redirect to $1, unless it's already identical
-update() {
-  if [ ! -e $1 ]
-  then
-    cat > $1
-  else
-    cat > $1.tmp
-    diff -q $1 $1.tmp >/dev/null  &&  rm $1.tmp  ||  mv $1.tmp $1
-  fi
-}
-
-update_cp() {
-  if [ ! -e $2/$1 ]
-  then
-    cp $1 $2
-  elif [ $1 -nt $2/$1 ]
-  then
-    cp $1 $2
-  fi
-}
-
-noisy_cd() {
-  cd $1
-  echo "-- `pwd`" >&2
-}
-
-older_than ../../enumerate/enumerate ../../enumerate/enumerate.cc && {
-  $CXX $CXXFLAGS ../../enumerate/enumerate.cc -o ../../enumerate/enumerate
-}
-
-older_than ../../tangle/tangle tangle/*.cc && {
-  noisy_cd ../../tangle
-    # auto-generate various lists (ending in '_list' by convention) {
-    # list of types
-    {
-      grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
-      grep -h "^typedef " [0-9]*.cc
-    }  |update type_list
-    # list of function declarations, so I can define them in any order
-    grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  |update function_list
-    # list of code files to compile
-    ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  |update file_list
-    # list of test files to compile
-    ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
-    # list of tests to run
-    grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
-    grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
-    # }
-    # Now that we have all the _lists, compile 'tangle'
-    $CXX $CXXFLAGS boot.cc -o tangle
-    ./tangle test
-  noisy_cd ../archive/2.vm  # no effect; just to show us returning to the parent directory
-}
-
-LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
-older_than mu.cc $LAYERS ../../enumerate/enumerate ../../tangle/tangle && {
-  # no update here; rely on 'update' calls downstream
-  ../../tangle/tangle $LAYERS  > mu.cc
-}
-
-older_than cleave/cleave cleave/cleave.cc && {
-  $CXX $CXXFLAGS cleave/cleave.cc -o cleave/cleave
-  rm -rf .build
-}
-
-mkdir -p .build
-# auto-generate function declarations, so I can define them in any order
-# functions start out unindented, have all args on the same line, and end in ') {'
-#
-#                                      \/ ignore struct/class methods
-grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
-# auto-generate list of tests to run
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
-mkdir -p .build/termbox
-update_cp termbox/termbox.h .build/termbox
-
-older_than mu_bin mu.cc *_list cleave/cleave termbox/* && {
-  cleave/cleave mu.cc .build
-  noisy_cd .build
-    # create the list of global variable declarations from the corresponding definitions
-    grep ';' global_definitions_list  |sed 's/[=(].*/;/'  |sed 's/^[^\/# ]/extern &/'  |sed 's/^extern extern /extern /'  |update global_declarations_list
-    for f in mu_*.cc
-    do
-      older_than `echo $f  |sed 's/\.cc$/.o/'` $f header global_declarations_list function_list test_list && {
-        $CXX $CXXFLAGS -c $f
-      }
-    done
-  noisy_cd ../termbox
-    older_than utf8.o utf8.c && {
-      $CC $CFLAGS -c utf8.c
-    }
-    older_than termbox.o termbox.c termbox.h input.inl output.inl bytebuffer.inl && {
-      $CC $CFLAGS -c termbox.c
-    }
-    older_than libtermbox.a *.o && {
-      ar rcs libtermbox.a *.o
-    }
-  noisy_cd ..
-  $CXX $CXXFLAGS .build/*.o termbox/libtermbox.a -o .build/mu_bin
-  cp .build/mu_bin .
-}
-
-## [0-9]*.mu -> core.mu
-
-MU_LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.mu$') || exit 0  # ok if no .mu files
-cat $MU_LAYERS  |update core.mu
-
-exit 0
-
-# scenarios considered:
-#   0 status when nothing needs updating
-#   no output when nothing needs updating
-#     no output for mu.cc when .mu files modified
-#     touch mu.cc but don't modify it; no output on second build
-#     touch a .cc layer but don't modify it; no output on second build
-#   only a single layer is recompiled when changing a C++ function
-#   stop immediately after failure in tangle
diff --git a/archive/2.vm/build3 b/archive/2.vm/build3
deleted file mode 100755
index 7bacfb62..00000000
--- a/archive/2.vm/build3
+++ /dev/null
@@ -1,201 +0,0 @@
-#!/bin/sh
-# Alternative to build2 that can stop after any step. For example:
-#   $ ./build3 mu.cc
-
-set -e  # stop immediately on error
-
-# Some environment variables that can be passed in. For example, to turn off
-# optimization:
-#   $ CFLAGS=-g ./build3
-test "$CXX" || export CXX=c++
-test "$CC" || export CC=cc
-test "$CFLAGS" || export CFLAGS="-g -O2"
-export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing"
-export CXXFLAGS="-std=c++98 $CFLAGS"  # CI has an ancient version; don't expect recent dialects
-
-# Outline:
-# [0-9]*.cc -> mu.cc -> .build/*.cc -> .build/*.o -> .build/mu_bin
-# (layers)   |        |              |             |
-#          tangle  cleave          $CXX          $CXX
-
-## arg parsing
-
-# can be called with a target to stop after a partial build
-#   $ ./build3 mu.cc
-# can also be called with a layer to only build until
-#   $ ./build3 --until 050
-# scenarios:
-#   ./build3              => TARGET=  UNTIL_LAYER=zzz
-#   ./build3 x            => TARGET=x UNTIL_LAYER=zzz
-#   ./build3 --until      => TARGET=  UNTIL_LAYER=zzz
-#   ./build3 --until 050  => TARGET=  UNTIL_LAYER=050
-TARGET=
-UNTIL_LAYER=zzz
-if [ $# -ge 1 ] && [ $1 != "--until" ]
-then
-  TARGET=$1
-fi
-if [ $# -ge 2 ] && [ $1 = "--until" ]
-then
-  UNTIL_LAYER=$2
-fi
-
-##
-
-# there's two mechanisms for fast builds here:
-# - if a command is quick to run, always run it but update the result only on any change
-# - otherwise run it only if the output is 'older_than' the inputs
-#
-# avoid combining both mechanisms for a single file
-# otherwise you'll see spurious messages about files being updated
-# risk: a file may unnecessarily update without changes, causing unnecessary work downstream
-
-# return 1 if $1 is older than _any_ of the remaining args
-# also exit the entire script if previous invocation was to update $TARGET
-older_than() {
-  test $TARGET  &&  test "$last_target" = "$TARGET"  &&  exit 0
-  local target=$1
-  shift
-  last_target=$target
-  if [ ! -e $target ]
-  then
-#?     echo "$target doesn't exist"
-    echo "updating $target" >&2
-    return 0  # success
-  fi
-  local f
-  for f in $*
-  do
-    if [ $f -nt $target ]
-    then
-      echo "updating $target" >&2
-      return 0  # success
-    fi
-  done
-  return 1  # failure
-}
-
-# redirect to $1, unless it's already identical
-# no point checking for an early exit, because this usually runs in a pipeline/subshell
-update() {
-  if [ ! -e $1 ]
-  then
-    cat > $1
-  else
-    cat > $1.tmp
-    diff -q $1 $1.tmp >/dev/null  &&  rm $1.tmp  ||  mv $1.tmp $1
-  fi
-}
-
-# cp file $1 to directory $2, unless it's already identical
-# also exit the entire script if previous invocation was to update $TARGET
-update_cp() {
-  test $TARGET  &&  test "$last_target" = "$TARGET"  &&  exit 0
-  last_target=$2/$1
-  if [ ! -e $2/$1 ]
-  then
-    cp $1 $2
-  elif [ $1 -nt $2/$1 ]
-  then
-    cp $1 $2
-  fi
-}
-
-noisy_cd() {
-  cd $1
-  echo "-- `pwd`" >&2
-}
-
-older_than ../../enumerate/enumerate ../../enumerate/enumerate.cc && {
-  $CXX $CXXFLAGS ../../enumerate/enumerate.cc -o ../../enumerate/enumerate
-}
-
-older_than ../../tangle/tangle ../../tangle/*.cc && {
-  noisy_cd ../../tangle
-    # auto-generate various lists (ending in '_list' by convention) {
-    # list of types
-    {
-      grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
-      grep -h "^typedef " [0-9]*.cc
-    }  |update type_list
-    # list of function declarations, so I can define them in any order
-    grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  |update function_list
-    # list of code files to compile
-    ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  |update file_list
-    # list of test files to compile
-    ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
-    # list of tests to run
-    grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
-    grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
-    # }
-    # Now that we have all the _lists, compile 'tangle'
-    $CXX $CXXFLAGS boot.cc -o tangle
-    ./tangle test
-  noisy_cd ../archive/2.vm  # no effect; just to show us returning to the parent directory
-}
-
-LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
-older_than mu.cc $LAYERS ../../enumerate/enumerate ../../tangle/tangle && {
-  # no update here; rely on 'update' calls downstream
-  ../../tangle/tangle $LAYERS  > mu.cc
-}
-
-older_than cleave/cleave cleave/cleave.cc && {
-  $CXX $CXXFLAGS cleave/cleave.cc -o cleave/cleave
-  rm -rf .build
-}
-
-mkdir -p .build
-# auto-generate function declarations, so I can define them in any order
-# functions start out unindented, have all args on the same line, and end in ') {'
-#
-#                                      \/ ignore struct/class methods
-grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
-# auto-generate list of tests to run
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
-mkdir -p .build/termbox
-update_cp termbox/termbox.h .build/termbox
-
-older_than mu_bin mu.cc *_list cleave/cleave termbox/* && {
-  cleave/cleave mu.cc .build
-  noisy_cd .build
-    # create the list of global variable declarations from the corresponding definitions
-    grep ';' global_definitions_list  |sed 's/[=(].*/;/'  |sed 's/^[^\/# ]/extern &/'  |sed 's/^extern extern /extern /'  |update global_declarations_list
-    for f in mu_*.cc
-    do
-      older_than `echo $f  |sed 's/\.cc$/.o/'` $f header global_declarations_list function_list test_list && {
-        $CXX $CXXFLAGS -c $f
-      }
-    done
-  noisy_cd ../termbox
-    older_than utf8.o utf8.c && {
-      $CC $CFLAGS -c utf8.c
-    }
-    older_than termbox.o termbox.c termbox.h input.inl output.inl bytebuffer.inl && {
-      $CC $CFLAGS -c termbox.c
-    }
-    older_than libtermbox.a *.o && {
-      ar rcs libtermbox.a *.o
-    }
-  noisy_cd ..
-  $CXX $CXXFLAGS .build/*.o termbox/libtermbox.a -o .build/mu_bin
-  cp .build/mu_bin .
-}
-
-## [0-9]*.mu -> core.mu
-
-MU_LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.mu$') || exit 0  # ok if no .mu files
-cat $MU_LAYERS  |update core.mu
-
-exit 0
-
-# scenarios considered:
-#   0 status when nothing needs updating
-#   no output when nothing needs updating
-#     no output for mu.cc when .mu files modified
-#     touch mu.cc but don't modify it; no output on second build
-#     touch a .cc layer but don't modify it; no output on second build
-#   only a single layer is recompiled when changing a C++ function
-#   stop immediately after failure in tangle
-#   stop immediately after target provided at commandline
diff --git a/archive/2.vm/build4 b/archive/2.vm/build4
deleted file mode 100755
index 08752831..00000000
--- a/archive/2.vm/build4
+++ /dev/null
@@ -1,297 +0,0 @@
-#!/bin/sh
-# Experimental alternative to build2 that can run steps in parallel if their
-# dependencies are met. Caveats:
-#
-#   1. We rely on the OS to schedule steps, so thousands of independent tasks
-#      will likely be counter-productive.
-#   2. Can run out of virtual memory if you spawn too many say $CC processes.
-#   3. Compilation errors can cause the script to hang. We tag the most common
-#      suspects with '|| quit', but can't eliminate the possibility entirely.
-#   4. Ugly as heck! This version really benefits from comparisons with its
-#      'upstream', build2. And even then, diff gets confused.
-#   5. There's a mechanical difficulty: we use mktemp to reliably create
-#      temporary filenames, which has the side effect of also creating the
-#      files. So zero-size files are considered equivalent to non-existent
-#      files. When some commands have trouble with this (e.g. ar) we need to
-#      delete the empty file, which can expose us to a race condition wrt
-#      mktemp.
-
-set -e  # stop immediately on error
-
-# Some environment variables that can be passed in. For example, to turn off
-# optimization:
-#   $ CFLAGS=-g ./build4
-test "$CXX" || export CXX=c++
-test "$CC" || export CC=cc
-test "$CFLAGS" || export CFLAGS="-g -O2"
-export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing"
-export CXXFLAGS="-std=c++98 $CFLAGS"  # CI has an ancient version; don't expect recent dialects
-
-# Outline:
-# [0-9]*.cc -> mu.cc -> .build/*.cc -> .build/*.o -> .build/mu_bin
-# (layers)   |        |              |             |
-#          tangle  cleave          $CXX          $CXX
-
-# can also be called with a layer to only build until
-#   $ ./build4 --until 050
-UNTIL_LAYER=${2:-zzz}
-
-# there's two mechanisms for fast builds here:
-# - if a command is quick to run, always run it but update the result only on any change
-# - otherwise run it only if the output is 'older_than' the inputs
-#
-# avoid combining both mechanisms for a single file
-# otherwise you'll see spurious messages about files being updated
-# risk: a file may unnecessarily update without changes, causing unnecessary work downstream
-
-# return 1 if $1 is older than _any_ of the remaining args
-older_than() {
-  local target=$1
-  shift
-  if [ ! -s $target ]
-  then
-#?     echo "$target has size zero"
-#?     echo "updating $target" >&2
-    return 0  # success
-  fi
-  local f
-  for f in $*
-  do
-    if [ $f -nt $target ]
-    then
-#?       echo "updating $target" >&2
-      return 0  # success
-    fi
-  done
-  return 1  # failure
-}
-
-# redirect to $1, unless it's already identical
-update() {
-  if [ ! -e $1 ]
-  then
-    cat > $1
-  else
-    cat > $1.tmp
-    diff -q $1 $1.tmp >/dev/null  &&  rm $1.tmp  ||  mv $1.tmp $1
-  fi
-}
-
-update_cp() {
-  if [ ! -e $2/$1 ]
-  then
-    cp $1 $2
-  elif [ $1 -nt $2/$1 ]
-  then
-    cp $1 $2
-  fi
-}
-
-noisy_cd() {
-  cd $1
-  echo "-- `pwd`" >&2
-}
-
-mv_if_exists() {
-  test -e $1  &&  mv $1 $2
-  return 0
-}
-
-# wait for all the given filenames to exist
-# exit immediately if a special file called '.quit' exists
-QUITFILE=`pwd`/.quit
-rm -f $QUITFILE
-wait_for_all() {
-  # could use inotify on Linux
-  while ! all_exist "$@"
-  do
-#?     echo waiting: $*
-    test -e $QUITFILE  &&  return 1  # some step had an error; stop all waiting steps using errexit
-    sleep 1
-  done
-  return 0
-}
-quit() {
-  touch $QUITFILE
-  exit 1
-}
-
-all_exist() {
-  for f in "$@"
-  do
-    test -e $f  ||  return 1
-  done
-  return 0
-}
-
-TMP=`mktemp`
-mv_if_exists ../../enumerate/enumerate $TMP
-(
-  wait_for_all ../../enumerate/enumerate.cc
-  older_than $TMP ../../enumerate/enumerate.cc && {
-    echo "building enumerate"
-    $CXX $CXXFLAGS ../../enumerate/enumerate.cc -o $TMP  ||  quit
-    echo "done building enumerate"
-  }
-  mv $TMP ../../enumerate/enumerate
-) &
-
-TMP=`mktemp`
-mv_if_exists ../../tangle/tangle $TMP
-(
-  wait_for_all ../../tangle/*.cc
-  older_than $TMP ../../tangle/*.cc && {
-    echo "building tangle"
-    cd ../../tangle
-      # auto-generate various lists (ending in '_list' by convention) {
-      # list of types
-      {
-        grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
-        grep -h "^typedef " [0-9]*.cc
-      }  |update type_list
-      # list of function declarations, so I can define them in any order
-      grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  |update function_list
-      # list of code files to compile
-      ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  |update file_list
-      # list of test files to compile
-      ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
-      # list of tests to run
-      grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
-      grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
-      # }
-      # Now that we have all the _lists, compile 'tangle'
-      $CXX $CXXFLAGS boot.cc -o $TMP  ||  quit
-      $TMP test
-    cd ../archive/2.vm
-    echo "done building tangle"
-  }
-  mv $TMP ../../tangle/tangle
-) &
-
-wait_for_all ../../enumerate/enumerate
-echo "enumerating layers"
-LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
-echo "done enumerating layers"
-
-TMP=`mktemp`
-mv_if_exists mu.cc $TMP
-(
-  wait_for_all $LAYERS ../../enumerate/enumerate ../../tangle/tangle
-  older_than $TMP $LAYERS ../../enumerate/enumerate ../../tangle/tangle && {
-    echo "running tangle"
-    # no update here; rely on 'update' calls downstream
-    ../../tangle/tangle $LAYERS >$TMP  ||  quit
-    echo "done running tangle"
-  }
-  mv $TMP mu.cc
-) &
-
-TMP=`mktemp`
-mv_if_exists cleave/cleave $TMP
-(
-  wait_for_all cleave/cleave.cc
-  older_than $TMP cleave/cleave.cc && {
-    echo "building cleave"
-    $CXX $CXXFLAGS cleave/cleave.cc -o $TMP  ||  quit
-    rm -rf .build
-    echo "done building cleave"
-  }
-  mv $TMP cleave/cleave
-) &
-
-wait_for_all mu.cc cleave/cleave  # cleave/cleave just for the .build cleanup
-mkdir -p .build
-# auto-generate function declarations, so I can define them in any order
-# functions start out unindented, have all args on the same line, and end in ') {'
-#
-#                                      \/ ignore struct/class methods
-grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
-# auto-generate list of tests to run
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
-grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
-mkdir -p .build/termbox
-update_cp termbox/termbox.h .build/termbox
-
-TMP=`mktemp`
-mv_if_exists mu_bin $TMP
-(
-  wait_for_all mu.cc cleave/cleave termbox/*.c termbox/*.h termbox/*.inl
-  older_than $TMP mu.cc *_list cleave/cleave termbox/* && {
-    echo "building mu_bin"
-    cleave/cleave mu.cc .build  ||  quit
-    cd .build
-      # create the list of global variable declarations from the corresponding definitions
-      grep ';' global_definitions_list  |sed 's/[=(].*/;/'  |sed 's/^[^\/# ]/extern &/'  |sed 's/^extern extern /extern /'  |update global_declarations_list
-      for f in mu_*.cc
-      do
-        OBJ=`echo $f |sed 's/\.cc$/.o/'`
-        TMP=`mktemp`
-        mv_if_exists $OBJ $TMP
-        (
-          older_than $TMP $f header global_declarations_list function_list test_list && {
-            echo "building $OBJ"
-            $CXX $CXXFLAGS -c $f -o $TMP  ||  quit
-            echo "done building $OBJ"
-          }
-          mv $TMP $OBJ
-        ) &
-      done
-    cd ../termbox
-      TMP=`mktemp`
-      mv_if_exists utf8.o $TMP
-      (
-        older_than $TMP utf8.c && {
-          echo "building termbox/utf8.o"
-          $CC $CFLAGS -c utf8.c -o $TMP  ||  quit
-          echo "done building termbox/utf8.o"
-        }
-        mv $TMP utf8.o
-      ) &
-      TMP=`mktemp`
-      mv_if_exists termbox.o $TMP
-      (
-        older_than $TMP termbox.c termbox.h input.inl output.inl bytebuffer.inl && {
-          echo "building termbox/termbox.o"
-          $CC $CFLAGS -c termbox.c -o $TMP  ||  quit
-          echo "done building termbox/termbox.o"
-        }
-        mv $TMP termbox.o
-      ) &
-      TMP=`mktemp`
-      mv_if_exists libtermbox.a $TMP
-      (
-        wait_for_all termbox.o utf8.o
-        older_than $TMP termbox.o utf8.o && {
-          echo "building termbox/libtermbox.a"
-          rm $TMP;  ar rcs $TMP termbox.o utf8.o  ||  quit  # race condition; later mktemp may end up reusing this file
-          echo "done building termbox/libtermbox.a"
-        }
-        mv $TMP libtermbox.a
-      ) &
-    cd ..
-    MU_OBJS=`echo .build/mu_*.cc |sed 's/\.cc/.o/g'`
-    echo wait_for_all $MU_OBJS termbox/libtermbox.a
-    wait_for_all $MU_OBJS termbox/libtermbox.a
-    echo "building .build/mu_bin"
-    $CXX $CXXFLAGS $MU_OBJS termbox/libtermbox.a -o $TMP  ||  quit
-    echo "done building .build/mu_bin"
-    echo "done building mu_bin"
-  }
-  mv $TMP mu_bin
-) &
-
-## [0-9]*.mu -> core.mu
-
-wait_for_all ../../enumerate/enumerate
-echo "building core.mu"
-MU_LAYERS=$(../../enumerate/enumerate --until $UNTIL_LAYER  |grep '\.mu$') || exit 0  # ok if no .mu files
-cat $MU_LAYERS  |update core.mu
-echo "done building core.mu"
-
-wait_for_all mu_bin
-exit 0
-
-# scenarios considered:
-#   0 status when nothing needs updating
-#   only a single layer is recompiled when changing a C++ function
-#   stop immediately after any failure
diff --git a/archive/2.vm/build_and_test_until b/archive/2.vm/build_and_test_until
deleted file mode 100755
index ed560e36..00000000
--- a/archive/2.vm/build_and_test_until
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# Run tests for just a subset of layers.
-#
-# Usage:
-#   build_and_test_until [file prefix] [test name]
-# Provide the second arg to run just a single test.
-set -e
-
-# clean previous builds if they were building until a different layer
-touch .until
-PREV_UNTIL=`cat .until`
-if [ "$PREV_UNTIL" != $1 ]
-then
-  ./clean top-level
-  echo $1 > .until
-fi
-
-./build3 --until $1  &&  ./mu_bin test $2
diff --git a/archive/2.vm/cannot_write_tests_for b/archive/2.vm/cannot_write_tests_for
deleted file mode 100644
index 444aafd5..00000000
--- a/archive/2.vm/cannot_write_tests_for
+++ /dev/null
@@ -1,17 +0,0 @@
-0. main's ingredients
-1. assertion failures or errors inside scenarios
-2. screen background color
-3. has-more-events?
-4. hide/show screen
-5. more touch event types
-6. sandbox isolation
-7. errors in reading/writing files (missing directory, others?)
-
-termbox issues are implementation-specific and not worth testing:
-  whether we clear junk from other processes
-  latency in interpreting low-level escape characters
-
-calls to update-cursor are currently duplicated:
-  render-all calls update-cursor to simplify testing
-  event-loop needs to call update-cursor explicitly to backstop branches doing their own minimal rendering
-  solution: update-cursor after minimal rendering
diff --git a/archive/2.vm/channel.mu b/archive/2.vm/channel.mu
deleted file mode 100644
index 4a553148..00000000
--- a/archive/2.vm/channel.mu
+++ /dev/null
@@ -1,45 +0,0 @@
-# example program: communicating between routines using channels
-
-def producer sink:&:sink:char -> sink:&:sink:char [
-  # produce characters 1 to 5 on a channel
-  local-scope
-  load-inputs
-  # n = 0
-  n:char <- copy 0
-  {
-    done?:bool <- lesser-than n, 5
-    break-unless done?
-    # other threads might get between these prints
-    $print [produce: ], n, [ 
-]
-    sink <- write sink, n
-    n <- add n, 1
-    loop
-  }
-  close sink
-]
-
-def consumer source:&:source:char -> source:&:source:char [
-  # consume and print integers from a channel
-  local-scope
-  load-inputs
-  {
-    # read an integer from the channel
-    n:char, eof?:bool, source <- read source
-    break-if eof?
-    # other threads might get between these prints
-    $print [consume: ], n:char, [ 
-]
-    loop
-  }
-]
-
-def main [
-  local-scope
-  source:&:source:char, sink:&:sink:char <- new-channel 3/capacity
-  # create two background 'routines' that communicate by a channel
-  routine1:num <- start-running producer, sink
-  routine2:num <- start-running consumer, source
-  wait-for-routine routine1
-  wait-for-routine routine2
-]
diff --git a/archive/2.vm/chessboard.mu b/archive/2.vm/chessboard.mu
deleted file mode 100644
index 09c85188..00000000
--- a/archive/2.vm/chessboard.mu
+++ /dev/null
@@ -1,572 +0,0 @@
-# Chessboard program: you type in moves in algebraic notation, and it'll
-# display the position after each move.
-
-def main [
-  local-scope
-  open-console  # take control of screen, keyboard and mouse
-  clear-screen null/screen  # non-scrolling app
-
-  # The chessboard function takes keyboard and screen objects as inputs.
-  #
-  # In Mu it is good form (though not required) to explicitly state what
-  # hardware a function needs.
-  #
-  # Here the console and screen are both null, which usually indicates real
-  # hardware rather than a fake for testing as you'll see below.
-  chessboard null/screen, null/console
-
-  close-console  # clean up screen, keyboard and mouse
-]
-
-## But enough about Mu. Here's what it looks like to run the chessboard program.
-
-scenario print-board-and-read-move [
-  local-scope
-  trace-until 100/app
-  # we'll make the screen really wide because the program currently prints out a long line
-  assume-screen 120/width, 20/height
-  # initialize keyboard to type in a move
-  assume-console [
-    type [a2-a4
-]
-  ]
-  run [
-    screen, console <- chessboard screen, console
-    # icon for the cursor
-    cursor-icon:char <- copy 9251/␣
-    screen <- print screen, cursor-icon
-  ]
-  screen-should-contain [
-  #            1         2         3         4         5         6         7         8         9         10        11
-  #  012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-    .Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.         .
-    .                                                                                                                        .
-    .8 | r n b q k b n r                                                                                                     .
-    .7 | p p p p p p p p                                                                                                     .
-    .6 |                                                                                                                     .
-    .5 |                                                                                                                     .
-    .4 | P                                                                                                                   .
-    .3 |                                                                                                                     .
-    .2 |   P P P P P P P                                                                                                     .
-    .1 | R N B Q K B N R                                                                                                     .
-    .  +----------------                                                                                                     .
-    .    a b c d e f g h                                                                                                     .
-    .                                                                                                                        .
-    .Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.                               .
-    .                                                                                                                        .
-    .Hit 'q' to exit.                                                                                                        .
-    .                                                                                                                        .
-    .move: ␣                                                                                                                 .
-    .                                                                                                                        .
-    .                                                                                                                        .
-  ]
-]
-
-## Here's how 'chessboard' is implemented.
-
-type board = &:@:&:@:char  # a 2-D array of arrays of characters
-
-def chessboard screen:&:screen, console:&:console -> screen:&:screen, console:&:console [
-  local-scope
-  load-inputs
-  board:board <- initial-position
-  # hook up stdin
-  stdin-in:&:source:char, stdin-out:&:sink:char <- new-channel 10/capacity
-  start-running send-keys-to-channel, console, stdin-out, screen
-  # buffer lines in stdin
-  buffered-stdin-in:&:source:char, buffered-stdin-out:&:sink:char <- new-channel 10/capacity
-  start-running buffer-lines, stdin-in, buffered-stdin-out
-  {
-    print screen, [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.
-]
-    cursor-to-next-line screen
-    print screen, board
-    cursor-to-next-line screen
-    print screen, [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
-]
-    cursor-to-next-line screen
-    print screen [Hit 'q' to exit.
-]
-    {
-      cursor-to-next-line screen
-      screen <- print screen, [move: ]
-      m:&:move, quit:bool, error:bool <- read-move buffered-stdin-in, screen
-      break-if quit, +quit
-      buffered-stdin-in <- clear buffered-stdin-in  # cleanup after error. todo: test this?
-      loop-if error
-    }
-    board <- make-move board, m
-    screen <- clear-screen screen
-    loop
-  }
-  +quit
-]
-
-## a board is an array of files, a file is an array of characters (squares)
-
-def new-board initial-position:&:@:char -> board:board [
-  local-scope
-  load-inputs
-  # assert(length(initial-position) == 64)
-  len:num <- length *initial-position
-  correct-length?:bool <- equal len, 64
-  assert correct-length?, [chessboard had incorrect size]
-  # board is an array of pointers to files; file is an array of characters
-  board <- new {(address array character): type}, 8
-  col:num <- copy 0
-  {
-    done?:bool <- equal col, 8
-    break-if done?
-    file:&:@:char <- new-file initial-position, col
-    *board <- put-index *board, col, file
-    col <- add col, 1
-    loop
-  }
-]
-
-def new-file position:&:@:char, index:num -> result:&:@:char [
-  local-scope
-  load-inputs
-  index <- multiply index, 8
-  result <- new character:type, 8
-  row:num <- copy 0
-  {
-    done?:bool <- equal row, 8
-    break-if done?
-    square:char <- index *position, index
-    *result <- put-index *result, row, square
-    row <- add row, 1
-    index <- add index, 1
-    loop
-  }
-]
-
-def print screen:&:screen, board:board -> screen:&:screen [
-  local-scope
-  load-inputs
-  row:num <- copy 7  # start printing from the top of the board
-  space:char <- copy 32/space
-  # print each row
-  {
-    done?:bool <- lesser-than row, 0
-    break-if done?
-    # print rank number as a legend
-    rank:num <- add row, 1
-    print screen, rank
-    print screen, [ | ]
-    # print each square in the row
-    col:num <- copy 0
-    {
-      done?:bool <- equal col:num, 8
-      break-if done?
-      f:&:@:char <- index *board, col
-      c:char <- index *f, row
-      bg:num <- square-color row, col
-      print screen, c, 7/white, bg
-      print screen, space
-      col <- add col, 1
-      loop
-    }
-    row <- subtract row, 1
-    cursor-to-next-line screen
-    loop
-  }
-  # print file letters as legend
-  print screen, [  +----------------]
-  cursor-to-next-line screen
-  print screen, [    a b c d e f g h]
-  cursor-to-next-line screen
-]
-
-def square-color row:num, col:num -> result:num [
-  local-scope
-  load-inputs
-  result <- copy 0/black
-  x:num <- add row, col
-  _, rem:num <- divide-with-remainder x, 2
-  return-if rem, 238
-]
-
-def initial-position -> board:board [
-  local-scope
-  # layout in memory (in raster order):
-  #   R P _ _ _ _ p r
-  #   N P _ _ _ _ p n
-  #   B P _ _ _ _ p b
-  #   Q P _ _ _ _ p q
-  #   K P _ _ _ _ p k
-  #   B P _ _ _ _ p B
-  #   N P _ _ _ _ p n
-  #   R P _ _ _ _ p r
-  initial-position:&:@:char <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r
-#?       82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r,
-#?       78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,
-#?       66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 
-#?       81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q,
-#?       75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k,
-#?       66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b,
-#?       78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,
-#?       82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r
-  board <- new-board initial-position
-]
-
-scenario printing-the-board [
-  local-scope
-  board:board <- initial-position
-  assume-screen 30/width, 12/height
-  run [
-    screen <- print screen, board
-  ]
-  screen-should-contain [
-  #  012345678901234567890123456789
-    .8 | r n b q k b n r           .
-    .7 | p p p p p p p p           .
-    .6 |                           .
-    .5 |                           .
-    .4 |                           .
-    .3 |                           .
-    .2 | P P P P P P P P           .
-    .1 | R N B Q K B N R           .
-    .  +----------------           .
-    .    a b c d e f g h           .
-    .                              .
-    .                              .
-  ]
-]
-
-## data structure: move
-
-container move [
-  # valid range: 0-7
-  from-file:num
-  from-rank:num
-  to-file:num
-  to-rank:num
-]
-
-# prints only error messages to screen
-def read-move stdin:&:source:char, screen:&:screen -> result:&:move, quit?:bool, error?:bool, stdin:&:source:char, screen:&:screen [
-  local-scope
-  load-inputs
-  from-file:num, quit?:bool, error?:bool <- read-file stdin, screen
-  return-if quit?, null/dummy
-  return-if error?, null/dummy
-  # construct the move object
-  result:&:move <- new move:type
-  *result <- put *result, from-file:offset, from-file
-  from-rank:num, quit?, error? <- read-rank stdin, screen
-  return-if quit?, null/dummy
-  return-if error?, null/dummy
-  *result <- put *result, from-rank:offset, from-rank
-  error? <- expect-from-channel stdin, 45/dash, screen
-  return-if error?, null/dummy, false/quit
-  to-file:num, quit?, error? <- read-file stdin, screen
-  return-if quit?, null/dummy
-  return-if error?, null/dummy
-  *result <- put *result, to-file:offset, to-file
-  to-rank:num, quit?, error? <- read-rank stdin, screen
-  return-if quit?, null/dummy
-  return-if error?, null/dummy
-  *result <- put *result, to-rank:offset, to-rank
-  error? <- expect-from-channel stdin, 10/newline, screen
-  return-if error?, null/dummy, false/quit
-]
-
-# valid values for file: 0-7
-def read-file stdin:&:source:char, screen:&:screen -> file:num, quit:bool, error:bool, stdin:&:source:char, screen:&:screen [
-  local-scope
-  load-inputs
-  c:char, eof?:bool, stdin <- read stdin
-  return-if eof?, 0/dummy, true/quit, false/no-error
-  q-pressed?:bool <- equal c, 81/Q
-  return-if q-pressed?, 0/dummy, true/quit, false/no-error
-  q-pressed? <- equal c, 113/q
-  return-if q-pressed?, 0/dummy, true/quit, false/no-error
-  empty-fake-keyboard?:bool <- equal c, 0/eof
-  return-if empty-fake-keyboard?, 0/dummy, true/quit, false/no-error
-  {
-    newline?:bool <- equal c, 10/newline
-    break-unless newline?
-    print screen, [that's not enough]
-    return 0/dummy, false/don't-quit, true/error
-  }
-  file:num <- subtract c, 97/a
-  # 'a' <= file <= 'h'
-  {
-    above-min:bool <- greater-or-equal file, 0
-    break-if above-min
-    print screen, [file too low: ]
-    print screen, c
-    cursor-to-next-line screen
-    return 0/dummy, false/don't-quit, true/error
-  }
-  {
-    below-max:bool <- lesser-than file, 8
-    break-if below-max
-    print screen, [file too high: ]
-    print screen, c
-    return 0/dummy, false/don't-quit, true/error
-  }
-  return file, false/don't-quit, false/no-error
-]
-
-# valid values for rank: 0-7
-def read-rank stdin:&:source:char, screen:&:screen -> rank:num, quit?:bool, error?:bool, stdin:&:source:char, screen:&:screen [
-  local-scope
-  load-inputs
-  c:char, eof?:bool, stdin <- read stdin
-  return-if eof?, 0/dummy, true/quit, false/no-error
-  q-pressed?:bool <- equal c, 81/Q
-  return-if q-pressed?, 0/dummy, true/quit, false/no-error
-  q-pressed? <- equal c, 113/q
-  return-if q-pressed?, 0/dummy, true/quit, false/no-error
-  empty-fake-keyboard?:bool <- equal c, 0/eof
-  return-if empty-fake-keyboard?, 0/dummy, true/quit, false/no-error
-  {
-    newline?:bool <- equal c, 10  # newline
-    break-unless newline?
-    print screen, [that's not enough]
-    return 0/dummy, false/don't-quite, true/error
-  }
-  rank:num <- subtract c, 49/'1'
-  # assert'1' <= rank <= '8'
-  {
-    above-min:bool <- greater-or-equal rank, 0
-    break-if above-min
-    print screen, [rank too low: ]
-    print screen, c
-    return 0/dummy, false/don't-quite, true/error
-  }
-  {
-    below-max:bool <- lesser-or-equal rank, 7
-    break-if below-max
-    print screen, [rank too high: ]
-    print screen, c
-    return 0/dummy, false/don't-quite, true/error
-  }
-  return rank, false/don't-quite, false/no-error
-]
-
-# read a character from the given channel and check that it's what we expect
-# return true on error
-def expect-from-channel stdin:&:source:char, expected:char, screen:&:screen -> result:bool, stdin:&:source:char, screen:&:screen [
-  local-scope
-  load-inputs
-  c:char, eof?:bool, stdin <- read stdin
-  return-if eof? true
-  {
-    match?:bool <- equal c, expected
-    break-if match?
-    print screen, [expected character not found]
-  }
-  result <- not match?
-]
-
-scenario read-move-blocking [
-  local-scope
-  assume-screen 20/width, 2/height
-  source:&:source:char, sink:&:sink:char <- new-channel 2/capacity
-  read-move-routine:num/routine <- start-running read-move, source, screen
-  run [
-    # 'read-move' is waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state:num <- routine-state read-move-routine
-    waiting?:bool <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]
-    # press 'a'
-    sink <- write sink, 97/a
-    restart read-move-routine
-    # 'read-move' still waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    waiting? <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after rank 'a']
-    # press '2'
-    sink <- write sink, 50/'2'
-    restart read-move-routine
-    # 'read-move' still waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    waiting? <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after file 'a2']
-    # press '-'
-    sink <- write sink, 45/'-'
-    restart read-move-routine
-    # 'read-move' still waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    waiting? <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after hyphen 'a2-']
-    # press 'a'
-    sink <- write sink, 97/a
-    restart read-move-routine
-    # 'read-move' still waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    waiting? <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after rank 'a2-a']
-    # press '4'
-    sink <- write sink, 52/'4'
-    restart read-move-routine
-    # 'read-move' still waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    waiting? <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-blocking: routine failed to pause after file 'a2-a4']
-    # press 'newline'
-    sink <- write sink, 10  # newline
-    restart read-move-routine
-    # 'read-move' now completes
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    completed?:bool <- equal read-move-state, 1/completed
-    assert completed?, [ 
-F read-move-blocking: routine failed to terminate on newline]
-    trace 1, [test], [reached end]
-  ]
-  trace-should-contain [
-    test: reached end
-  ]
-]
-
-scenario read-move-quit [
-  local-scope
-  assume-screen 20/width, 2/height
-  source:&:source:char, sink:&:sink:char <- new-channel 2/capacity
-  read-move-routine:num <- start-running read-move, source, screen
-  run [
-    # 'read-move' is waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state:num <- routine-state read-move-routine
-    waiting?:bool <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-quit: routine failed to pause after coming up (before any keys were pressed)]
-    # press 'q'
-    sink <- write sink, 113/q
-    restart read-move-routine
-    # 'read-move' completes
-    wait-for-routine-to-block read-move-routine
-    read-move-state <- routine-state read-move-routine
-    completed?:bool <- equal read-move-state, 1/completed
-    assert completed?, [ 
-F read-move-quit: routine failed to terminate on 'q']
-    trace 1, [test], [reached end]
-  ]
-  trace-should-contain [
-    test: reached end
-  ]
-]
-
-scenario read-move-illegal-file [
-  local-scope
-  assume-screen 20/width, 2/height
-  source:&:source:char, sink:&:sink:char <- new-channel 2/capacity
-  read-move-routine:num <- start-running read-move, source, screen
-  run [
-    # 'read-move' is waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state:num <- routine-state read-move-routine
-    waiting?:bool <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-illegal-file: routine failed to pause after coming up (before any keys were pressed)]
-    sink <- write sink, 50/'2'
-    restart read-move-routine
-    wait-for-routine-to-block read-move-routine
-  ]
-  screen-should-contain [
-    .file too low: 2     .
-    .                    .
-  ]
-]
-
-scenario read-move-illegal-rank [
-  local-scope
-  assume-screen 20/width, 2/height
-  source:&:source:char, sink:&:sink:char <- new-channel 2/capacity
-  read-move-routine:num <- start-running read-move, source, screen
-  run [
-    # 'read-move' is waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state:num <- routine-state read-move-routine
-    waiting?:bool <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-illegal-rank: routine failed to pause after coming up (before any keys were pressed)]
-    sink <- write sink, 97/a
-    sink <- write sink, 97/a
-    restart read-move-routine
-    wait-for-routine-to-block read-move-routine
-  ]
-  screen-should-contain [
-    .rank too high: a    .
-    .                    .
-  ]
-]
-
-scenario read-move-empty [
-  local-scope
-  assume-screen 20/width, 2/height
-  source:&:source:char, sink:&:sink:char <- new-channel 2/capacity
-  read-move-routine:num <- start-running read-move, source, screen
-  run [
-    # 'read-move' is waiting for keypress
-    wait-for-routine-to-block read-move-routine
-    read-move-state:num <- routine-state read-move-routine
-    waiting?:bool <- not-equal read-move-state, 2/discontinued
-    assert waiting?, [ 
-F read-move-empty: routine failed to pause after coming up (before any keys were pressed)]
-    sink <- write sink, 10/newline
-    sink <- write sink, 97/a
-    restart read-move-routine
-    wait-for-routine-to-block read-move-routine
-  ]
-  screen-should-contain [
-    .that's not enough   .
-    .                    .
-  ]
-]
-
-def make-move board:board, m:&:move -> board:board [
-  local-scope
-  load-inputs
-  from-file:num <- get *m, from-file:offset
-  from-rank:num <- get *m, from-rank:offset
-  to-file:num <- get *m, to-file:offset
-  to-rank:num <- get *m, to-rank:offset
-  from-f:&:@:char <- index *board, from-file
-  to-f:&:@:char <- index *board, to-file
-  src:char/square <- index *from-f, from-rank
-  *to-f <- put-index *to-f, to-rank, src
-  *from-f <- put-index *from-f, from-rank, 32/space
-]
-
-scenario making-a-move [
-  local-scope
-  assume-screen 30/width, 12/height
-  board:board <- initial-position
-  move:&:move <- new move:type
-  *move <- merge 6/g, 1/'2', 6/g, 3/'4'
-  run [
-    board <- make-move board, move
-    screen <- print screen, board
-  ]
-  screen-should-contain [
-  #  012345678901234567890123456789
-    .8 | r n b q k b n r           .
-    .7 | p p p p p p p p           .
-    .6 |                           .
-    .5 |                           .
-    .4 |             P             .
-    .3 |                           .
-    .2 | P P P P P P   P           .
-    .1 | R N B Q K B N R           .
-    .  +----------------           .
-    .    a b c d e f g h           .
-    .                              .
-  ]
-]
diff --git a/archive/2.vm/clean b/archive/2.vm/clean
deleted file mode 100755
index e3678430..00000000
--- a/archive/2.vm/clean
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-set -e
-
-set -v
-rm -rf mu.cc core.mu mu_bin* *_list .build
-rm -rf termbox/*.o termbox/libtermbox.a
-rm -rf .until .quit
-test $# -gt 0 && exit 0  # convenience: 'clean top-level' to leave subsidiary tools alone
-rm -rf ../../enumerate/enumerate ../../tangle/tangle ../../tangle/*_list cleave/cleave cleave/cleave.dSYM ../../*/*.dSYM
diff --git a/archive/2.vm/cleave/Readme b/archive/2.vm/cleave/Readme
deleted file mode 100644
index 038b6c98..00000000
--- a/archive/2.vm/cleave/Readme
+++ /dev/null
@@ -1 +0,0 @@
-Tool to construct compilation units out of Mu's layers.
diff --git a/archive/2.vm/cleave/cleave.cc b/archive/2.vm/cleave/cleave.cc
deleted file mode 100644
index a3637e81..00000000
--- a/archive/2.vm/cleave/cleave.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-// Read a single-file C++ program having a very specific structure, and split
-// it up into multiple separate compilation units to reduce the work needed to
-// rebuild after a small change. Write each compilation unit only if it has
-// changed from what was on disk before.
-//
-// This tool is tightly coupled with the build system for this project. The
-// makefile already auto-generates various things; we only do here what
-// standard unix tools can't easily do.
-//
-// Usage:
-//  cleave [input C++ file] [existing output directory]
-//
-// The input C++ file has the following structure:
-//   [#includes]
-//   [type definitions]
-//   // Globals
-//   [global variable definitions]
-//   // End Globals
-//   [function definitions]
-//
-// Afterwards, the output directory contains:
-//   header -- everything before the '// Globals' delimiter
-//   global_definitions_list -- everything between '// Globals' and '// End Globals' delimiters
-//   [.cc files partitioning function definitions]
-//
-// Each output function definition file contains:
-//   #include "header"
-//   #include "global_declarations_list"
-//   [function definitions]
-//
-// To preserve the original layer-based line numbers in error messages and the
-// debugger, we'll chunk the files only at boundaries where we encounter a
-// '#line ' directive (generated by the previous tangle/ stage) between
-// functions.
-//
-// One exception: the first file emitted #includes "global_definitions_list" instead
-// of "global_declarations_list"
-
-// Tune this parameter to balance time for initial vs incremental build.
-//
-//   decrease value -> faster initial build
-//   increase value -> faster incremental build
-int Num_compilation_units = 3;
-
-#include<assert.h>
-#include<cstdlib>
-#include<cstring>
-
-#include<vector>
-using std::vector;
-#include<list>
-using std::list;
-#include<utility>
-using std::pair;
-
-#include<string>
-using std::string;
-
-#include<iostream>
-using std::istream;
-using std::ostream;
-using std::cin;
-using std::cout;
-using std::cerr;
-
-#include<sstream>
-using std::istringstream;
-using std::ostringstream;
-
-#include<fstream>
-using std::ifstream;
-using std::ofstream;
-
-#include <locale>
-using std::isspace;  // unicode-aware
-
-string trim(const string& s) {
-  string::const_iterator first = s.begin();
-  while (first != s.end() && isspace(*first))
-    ++first;
-  if (first == s.end()) return "";
-
-  string::const_iterator last = --s.end();
-  while (last != s.begin() && isspace(*last))
-    --last;
-  ++last;
-  return string(first, last);
-}
-
-bool starts_with(const string& s, const string& pat) {
-  string::const_iterator a=s.begin(), b=pat.begin();
-  for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b)
-    if (*a != *b) return false;
-  return b == pat.end();
-}
-
-bool has_data(istream& in) {
-  return in && !in.eof();
-}
-
-void slurp(const string& filename, vector<string>& lines) {
-  lines.clear();
-  ifstream in(filename.c_str());
-  while (has_data(in)) {
-    string curr_line;
-    getline(in, curr_line);
-    lines.push_back(curr_line);
-  }
-}
-
-size_t slurp_some_functions(const vector<string>& in, size_t start, vector<string>& out, bool first) {
-  out.clear();
-  if (start >= in.size()) return start;
-  out.push_back("#include \"header\"");
-  if (first)
-    out.push_back("#include \"global_definitions_list\"");
-  else
-    out.push_back("#include \"global_declarations_list\"");
-  out.push_back("");
-  size_t curr = start;
-  while (true) {
-    if (curr >= in.size()) break;
-    if (out.size() >= in.size()/Num_compilation_units) break;
-    while (curr < in.size()) {
-      // read functions -- lines until unindented '}'
-      while (curr < in.size()) {
-        const string& line = in.at(curr);
-//?         cerr << curr << ": adding to function: " << line << '\n';
-        out.push_back(line);  ++curr;
-        if (!line.empty() && line.at(0) == '}') break;
-      }
-      // now look for a '#line' directive before the next non-comment non-empty
-      // line
-      while (curr < in.size()) {
-        const string& line = in.at(curr);
-        if (starts_with(line, "#line ")) goto try_return;
-        out.push_back(line);   ++curr;
-        if (trim(line).empty()) continue;
-        if (starts_with(trim(line), "//")) continue;
-        break;
-      }
-    }
-    try_return:;
-  }
-  return curr;
-}
-
-// compare contents of a file with a list of lines, ignoring #line directives
-// on both sides
-bool no_change(const vector<string>& lines, const string& output_filename) {
-  vector<string> old_lines;
-  slurp(output_filename, old_lines);
-  size_t l=0, o=0;
-  while (true) {
-    while (l < lines.size() &&
-            (lines.at(l).empty() || starts_with(lines.at(l), "#line "))) {
-      ++l;
-    }
-    while (o < old_lines.size() &&
-            (old_lines.at(o).empty() || starts_with(old_lines.at(o), "#line "))) {
-      ++o;
-    }
-    if (l >= lines.size() && o >= old_lines.size()) return true;  // no change
-    if (l >= lines.size() || o >= old_lines.size()) return false;  // contents changed
-//?     cerr << "comparing\n";
-//?     cerr << o << ": " << old_lines.at(o) << '\n';
-//?     cerr << l << ": " << lines.at(l) << '\n';
-    if (lines.at(l) != old_lines.at(o)) return false;  // contents changed
-    ++l;  ++o;
-  }
-  assert(false);
-}
-
-string next_output_filename(const string& output_directory) {
-  static int file_count = 0;
-  ostringstream out;
-  out << output_directory << "/mu_" << file_count << ".cc";
-  file_count++;
-  return out.str();
-}
-
-void emit_file(const vector<string>& lines, const string& output_filename) {
-  if (no_change(lines, output_filename)) return;
-  cerr << "  updating " << output_filename << '\n';
-  ofstream out(output_filename.c_str());
-  for (size_t i = 0; i < lines.size(); ++i)
-    out << lines.at(i) << '\n';
-}
-
-void emit_compilation_unit(const vector<string>& lines, const string& output_directory) {
-  string output_filename = next_output_filename(output_directory);
-  emit_file(lines, output_filename);
-}
-
-int main(int argc, const char* argv[]) {
-  if (argc != 3) {
-    cerr << "usage: cleave [input .cc file] [output directory]\n";
-    exit(0);
-  }
-
-  // read input
-  vector<string> lines;
-  slurp(argv[1], lines);
-
-  // write header until but excluding '// Global' delimiter
-  string output_directory = argv[2];
-  size_t line_num = 0;
-  {
-    vector<string> out;
-    while (line_num < lines.size()) {
-      const string& line = lines.at(line_num);
-      if (trim(line) == "// Globals") break;  // todo: #line directive for delimiters
-      out.push_back(line);
-      ++line_num;
-    }
-    emit_file(out, output_directory+"/header");
-  }
-
-  // write global_definitions_list (including delimiters)
-  {
-    vector<string> out;
-    while (line_num < lines.size()) {
-      const string& line = lines.at(line_num);
-      out.push_back(line);
-      ++line_num;
-      if (trim(line) == "// End Globals") break;
-    }
-    emit_file(out, output_directory+"/global_definitions_list");
-  }
-
-  // segment functions
-  // first one is special
-  if (line_num < lines.size()) {
-    vector<string> function;
-    line_num = slurp_some_functions(lines, line_num, function, true);
-    emit_compilation_unit(function, output_directory);
-  }
-  while (line_num < lines.size()) {
-    vector<string> function;
-    line_num = slurp_some_functions(lines, line_num, function, false);
-    emit_compilation_unit(function, output_directory);
-  }
-}
diff --git a/archive/2.vm/console.mu b/archive/2.vm/console.mu
deleted file mode 100644
index cc81c232..00000000
--- a/archive/2.vm/console.mu
+++ /dev/null
@@ -1,16 +0,0 @@
-# example program: reading events from keyboard or mouse
-#
-# Keeps printing 'a' until you press a key or click on the mouse.
-
-def main [
-  local-scope
-  open-console
-  {
-    e:event, found?:bool <- check-for-interaction
-    break-if found?
-    print-character-to-display 97, 7/white
-    loop
-  }
-  close-console
-  $print e, 10/newline
-]
diff --git a/archive/2.vm/continuation1.mu b/archive/2.vm/continuation1.mu
deleted file mode 100644
index 8276e188..00000000
--- a/archive/2.vm/continuation1.mu
+++ /dev/null
@@ -1,25 +0,0 @@
-# Example program showing that 'return-continuation-until-mark' can 'pause' a
-# function call, returning a continuation, and that calling the continuation
-# can 'resume' the paused function call.
-#
-# To run:
-#   $ git clone https://github.com/akkartik/mu
-#   $ cd mu
-#   $ ./mu continuation1.mu
-#
-# Expected output:
-#   1
-
-def main [
-  local-scope
-  k:continuation <- call-with-continuation-mark 100/mark, create-yielder
-  x:num <- call k  # should return 1
-  $print x 10/newline
-]
-
-def create-yielder -> n:num [
-  local-scope
-  load-inputs
-  return-continuation-until-mark 100/mark
-  return 1
-]
diff --git a/archive/2.vm/continuation2.mu b/archive/2.vm/continuation2.mu
deleted file mode 100644
index 45a65e9f..00000000
--- a/archive/2.vm/continuation2.mu
+++ /dev/null
@@ -1,37 +0,0 @@
-# Example program showing that a 'paused' continuation can be 'resumed'
-# multiple times from the same point (but with changes to data).
-#
-# To run:
-#   $ git clone https://github.com/akkartik/mu
-#   $ cd mu
-#   $ ./mu continuation2.mu
-#
-# Expected output:
-#   1
-#   2
-#   3
-
-def main [
-  local-scope
-  l:&:list:num <- copy null
-  l <- push 3, l
-  l <- push 2, l
-  l <- push 1, l
-  k:continuation <- call-with-continuation-mark 100/mark, create-yielder, l
-  {
-    x:num, done?:bool <- call k
-    break-if done?
-    $print x 10/newline
-    loop
-  }
-]
-
-def create-yielder l:&:list:num -> n:num, done?:bool [
-  local-scope
-  load-inputs
-  return-continuation-until-mark 100/mark
-  done? <- equal l, null
-  return-if done?, 0/dummy
-  n <- first l
-  l <- rest l
-]
diff --git a/archive/2.vm/continuation3.mu b/archive/2.vm/continuation3.mu
deleted file mode 100644
index cde60958..00000000
--- a/archive/2.vm/continuation3.mu
+++ /dev/null
@@ -1,34 +0,0 @@
-# Example program showing that a function call can be 'paused' multiple times,
-# creating different continuation values.
-#
-# To run:
-#   $ git clone https://github.com/akkartik/mu
-#   $ cd mu
-#   $ ./mu continuation3.mu
-#
-# Expected output:
-#   caller 0
-#   callee 0
-#   caller 1
-#   callee 1
-#   caller 2
-#   callee 2
-
-def main [
-  local-scope
-  $print [caller 0] 10/newline
-  k:continuation <- call-with-continuation-mark 100/mark, f
-  $print [caller 1] 10/newline
-  k <- call k
-  $print [caller 2] 10/newline
-  call k
-]
-
-def f [
-  local-scope
-  $print [callee 0] 10/newline
-  return-continuation-until-mark 100/mark
-  $print [callee 1] 10/newline
-  return-continuation-until-mark 100/mark
-  $print [callee 2] 10/newline
-]
diff --git a/archive/2.vm/continuation4.mu b/archive/2.vm/continuation4.mu
deleted file mode 100644
index 1a523fe9..00000000
--- a/archive/2.vm/continuation4.mu
+++ /dev/null
@@ -1,47 +0,0 @@
-# Example program showing 'return-continuation-until-mark' return other values
-# alongside continuations.
-#
-# Print out a given list of numbers.
-#
-# To run:
-#   $ git clone https://github.com/akkartik/mu
-#   $ cd mu
-#   $ ./mu continuation4.mu
-#
-# Expected output:
-#   1
-#   2
-#   3
-
-def main [
-  local-scope
-  l:&:list:num <- copy null
-  l <- push 3, l
-  l <- push 2, l
-  l <- push 1, l
-  k:continuation, x:num, done?:bool <- call-with-continuation-mark 100/mark, create-yielder, l
-  {
-    break-if done?
-    $print x 10/newline
-    k, x:num, done?:bool <- call k
-    loop
-  }
-]
-
-def create-yielder l:&:list:num -> n:num, done?:bool [
-  local-scope
-  load-inputs
-  {
-    done? <- equal l, null
-    break-if done?
-    n <- first l
-    l <- rest l
-    return-continuation-until-mark 100/mark, n, done?
-    loop
-  }
-  # A function that returns continuations shouldn't get the opportunity to
-  # return. Calling functions should stop calling its continuation after this
-  # point.
-  return-continuation-until-mark 100/mark, -1, done?
-  assert false, [called too many times, ran out of continuations to return]
-]
diff --git a/archive/2.vm/continuation5.mu b/archive/2.vm/continuation5.mu
deleted file mode 100644
index 295cb9c9..00000000
--- a/archive/2.vm/continuation5.mu
+++ /dev/null
@@ -1,49 +0,0 @@
-# Example program showing that a 'paused' continuation can be 'resumed' with
-# inputs.
-#
-# Print out a list of numbers, first adding 0 to the first, 1 to the second, 2
-# to the third, and so on.
-#
-# To run:
-#   $ git clone https://github.com/akkartik/mu
-#   $ cd mu
-#   $ ./mu continuation5.mu
-#
-# Expected output:
-#   1
-#   3
-#   5
-
-def main [
-  local-scope
-  l:&:list:num <- copy null
-  l <- push 3, l
-  l <- push 2, l
-  l <- push 1, l
-  k:continuation, x:num, done?:bool <- call-with-continuation-mark 100/mark, create-yielder, l
-  a:num <- copy 1
-  {
-    break-if done?
-    $print x 10/newline
-    k, x:num, done?:bool <- call k, a  # resume; x = a + next l value
-    a <- add a, 1
-    loop
-  }
-]
-
-def create-yielder l:&:list:num -> n:num, done?:bool [
-  local-scope
-  load-inputs
-  a:num <- copy 0
-  {
-    done? <- equal l, null
-    break-if done?
-    n <- first l
-    l <- rest l
-    n <- add n, a
-    a <- return-continuation-until-mark 100/mark, n, done?  # pause/resume
-    loop
-  }
-  return-continuation-until-mark 100/mark, -1, done?
-  assert false, [called too many times, ran out of continuations to return]
-]
diff --git a/archive/2.vm/copy_mu b/archive/2.vm/copy_mu
deleted file mode 100755
index cd4da455..00000000
--- a/archive/2.vm/copy_mu
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env zsh
-# Copy binaries across mu directories for different students on a single
-# server, so we only need to build them once.
-
-cp -r $1/enumerate/enumerate $2/enumerate
-cp -r $1/cleave/cleave $2/cleave
-rm -rf $2/.build
-cp -r $1/.build $2
-cp -r $1/mu_bin $2
-cd $2
-./mu  # couple of things still get recompiled, but should now be quick
diff --git a/archive/2.vm/counters.mu b/archive/2.vm/counters.mu
deleted file mode 100644
index ea2fa77d..00000000
--- a/archive/2.vm/counters.mu
+++ /dev/null
@@ -1,29 +0,0 @@
-# example program: maintain multiple counters with isolated lexical scopes
-# (spaces)
-
-def new-counter n:num -> default-space:space [
-  default-space <- new location:type, 30
-  load-inputs  # initialize n
-]
-
-def increment-counter outer:space/names:new-counter, x:num -> n:num/space:1 [
-  local-scope
-  load-inputs
-  0:space/names:new-counter <- copy outer  # setup outer space; it *must* come from 'new-counter'
-  n/space:1 <- add n/space:1, x
-]
-
-def main [
-  local-scope
-  # counter A
-  a:space/names:new-counter <- new-counter 34
-  # counter B
-  b:space/names:new-counter <- new-counter 23
-  # increment both by 2 but in different ways
-  increment-counter a, 1
-  b-value:num <- increment-counter b, 2
-  a-value:num <- increment-counter a, 1
-  # check results
-  $print [Contents of counters], 10/newline
-  $print [a: ], a-value, [ b: ], b-value, 10/newline
-]
diff --git a/archive/2.vm/display.mu b/archive/2.vm/display.mu
deleted file mode 100644
index c3844c4b..00000000
--- a/archive/2.vm/display.mu
+++ /dev/null
@@ -1,25 +0,0 @@
-# example program: managing the display
-
-def main [
-  open-console
-  clear-display
-  print-character-to-display 97, 1/red, 2/green
-  1:num/raw, 2:num/raw <- cursor-position-on-display
-  wait-for-some-interaction
-  clear-line-on-display
-  move-cursor-on-display 0, 4
-  print-character-to-display 98
-  wait-for-some-interaction
-  move-cursor-on-display 0, 0
-  clear-line-on-display
-  wait-for-some-interaction
-  move-cursor-down-on-display
-  wait-for-some-interaction
-  move-cursor-right-on-display
-  wait-for-some-interaction
-  move-cursor-left-on-display
-  wait-for-some-interaction
-  move-cursor-up-on-display
-  wait-for-some-interaction
-  close-console
-]
diff --git a/archive/2.vm/edit/001-editor.mu b/archive/2.vm/edit/001-editor.mu
deleted file mode 100644
index b3399dbb..00000000
--- a/archive/2.vm/edit/001-editor.mu
+++ /dev/null
@@ -1,464 +0,0 @@
-## the basic editor data structure, and how it displays text to the screen
-
-# temporary main for this layer: just render the given text at the given
-# screen dimensions, then stop
-def main text:text [
-  local-scope
-  load-inputs
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  e:&:editor <- new-editor text, 0/left, 5/right
-  render null/screen, e
-  wait-for-event null/console
-  close-console
-]
-
-scenario editor-renders-text-to-screen [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    # top line of screen reserved for menu
-    .          .
-    .abc       .
-    .          .
-  ]
-]
-
-container editor [
-  # editable text: doubly linked list of characters (head contains a special sentinel)
-  data:&:duplex-list:char
-  top-of-screen:&:duplex-list:char
-  bottom-of-screen:&:duplex-list:char
-  # location before cursor inside data
-  before-cursor:&:duplex-list:char
-
-  # raw bounds of display area on screen
-  # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen
-  left:num
-  right:num
-  bottom:num
-  # raw screen coordinates of cursor
-  cursor-row:num
-  cursor-column:num
-]
-
-# creates a new editor widget
-#   right is exclusive
-def new-editor s:text, left:num, right:num -> result:&:editor [
-  local-scope
-  load-inputs
-  # no clipping of bounds
-  right <- subtract right, 1
-  result <- new editor:type
-  # initialize screen-related fields
-  *result <- put *result, left:offset, left
-  *result <- put *result, right:offset, right
-  # initialize cursor coordinates
-  *result <- put *result, cursor-row:offset, 1/top
-  *result <- put *result, cursor-column:offset, left
-  # initialize empty contents
-  init:&:duplex-list:char <- push 167/§, null
-  *result <- put *result, data:offset, init
-  *result <- put *result, top-of-screen:offset, init
-  *result <- put *result, before-cursor:offset, init
-  result <- insert-text result, s
-  <editor-initialization>
-]
-
-def insert-text editor:&:editor, text:text -> editor:&:editor [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- get *editor, data:offset
-  insert curr, text
-]
-
-scenario editor-initializes-without-data [
-  local-scope
-  assume-screen 5/width, 3/height
-  run [
-    e:&:editor <- new-editor null/data, 2/left, 5/right
-    1:editor/raw <- copy *e
-  ]
-  memory-should-contain [
-    # 1,2 (data) <- just the § sentinel
-    # 3,4 (top of screen) <- the § sentinel
-    # 5 (bottom of screen) <- null since text fits on screen
-    5 <- 0
-    6 <- 0
-    # 7,8 (before cursor) <- the § sentinel
-    9 <- 2  # left
-    10 <- 4  # right  (inclusive)
-    11 <- 0  # bottom (not set until render)
-    12 <- 1  # cursor row
-    13 <- 2  # cursor column
-  ]
-  screen-should-contain [
-    .     .
-    .     .
-    .     .
-  ]
-]
-
-# Assumes cursor should be at coordinates (cursor-row, cursor-column) and
-# updates before-cursor to match. Might also move coordinates if they're
-# outside text.
-def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, 1/top, 0/left
-  left:num <- get *editor, left:offset
-  screen-height:num <- screen-height screen
-  right:num <- get *editor, right:offset
-  # traversing editor
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  # traversing screen
-  color:num <- copy 7/white
-  row:num <- copy 1/top
-  column:num <- copy left
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  screen <- move-cursor screen, row, column
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # update editor.before-cursor
-    # Doing so at the start of each iteration ensures it stays one step behind
-    # the current character.
-    {
-      at-cursor-row?:bool <- equal row, cursor-row
-      break-unless at-cursor-row?
-      at-cursor?:bool <- equal column, cursor-column
-      break-unless at-cursor?
-      before-cursor <- copy prev
-    }
-    c:char <- get *curr, value:offset
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # adjust cursor if necessary
-      {
-        at-cursor-row?:bool <- equal row, cursor-row
-        break-unless at-cursor-row?
-        left-of-cursor?:bool <- lesser-than column, cursor-column
-        break-unless left-of-cursor?
-        cursor-column <- copy column
-        before-cursor <- prev curr
-      }
-      # clear rest of line in this window
-      clear-line-until screen, right
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment curr
-      loop +next-character
-    }
-    print screen, c, color
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # save first character off-screen
-  *editor <- put *editor, bottom-of-screen:offset, curr
-  # is cursor to the right of the last line? move to end
-  {
-    at-cursor-row?:bool <- equal row, cursor-row
-    cursor-outside-line?:bool <- lesser-or-equal column, cursor-column
-    before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line?
-    above-cursor-row?:bool <- lesser-than row, cursor-row
-    before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row?
-    break-unless before-cursor?
-    cursor-row <- copy row
-    cursor-column <- copy column
-    before-cursor <- copy prev
-  }
-  *editor <- put *editor, bottom:offset, row
-  *editor <- put *editor, cursor-row:offset, cursor-row
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  clear-line-until screen, right
-  row <- add row, 1
-  return row, left/column
-]
-
-def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  # if it's the real screen, use the optimized primitive
-  {
-    break-if screen
-    clear-display-from row, column, left, right
-    return
-  }
-  # if not, go the slower route
-  screen <- move-cursor screen, row, column
-  clear-line-until screen, right
-  clear-rest-of-screen screen, row, left, right
-]
-
-def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  row <- add row, 1
-  # if it's the real screen, use the optimized primitive
-  {
-    break-if screen
-    clear-display-from row, left, left, right
-    return
-  }
-  screen <- move-cursor screen, row, left
-  screen-height:num <- screen-height screen
-  {
-    at-bottom-of-screen?:bool <- greater-or-equal row, screen-height
-    break-if at-bottom-of-screen?
-    screen <- move-cursor screen, row, left
-    clear-line-until screen, right
-    row <- add row, 1
-    loop
-  }
-]
-
-scenario editor-prints-multiple-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc  .
-    .def  .
-    .     .
-  ]
-]
-
-scenario editor-handles-offsets [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc], 1/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    . abc .
-    .     .
-  ]
-]
-
-scenario editor-prints-multiple-lines-at-offset [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 1/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    . abc .
-    . def .
-    .     .
-  ]
-]
-
-scenario editor-wraps-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc def], 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc ↩.
-    .def  .
-    .     .
-  ]
-  screen-should-contain-in-color 245/grey [
-    .     .
-    .    ↩.
-    .     .
-    .     .
-  ]
-]
-
-scenario editor-wraps-barely-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  # still wrap, even though the line would fit. We need room to click on the
-  # end of the line
-  screen-should-contain [
-    .     .
-    .abcd↩.
-    .e    .
-    .     .
-  ]
-  screen-should-contain-in-color 245/grey [
-    .     .
-    .    ↩.
-    .     .
-    .     .
-  ]
-]
-
-scenario editor-with-empty-text [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  run [
-    render screen, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .     .
-    .     .
-    .     .
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 0  # cursor column
-  ]
-]
-
-# just a little color for Mu code
-
-scenario render-colors-comments [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-# de
-f]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc  .
-    .# de .
-    .f    .
-    .     .
-  ]
-  screen-should-contain-in-color 12/lightblue, [
-    .     .
-    .     .
-    .# de .
-    .     .
-    .     .
-  ]
-  screen-should-contain-in-color 7/white, [
-    .     .
-    .abc  .
-    .     .
-    .f    .
-    .     .
-  ]
-]
-
-after <character-c-received> [
-  color <- get-color color, c
-]
-
-# so far the previous color is all the information we need; that may change
-def get-color color:num, c:char -> color:num [
-  local-scope
-  load-inputs
-  color-is-white?:bool <- equal color, 7/white
-  # if color is white and next character is '#', switch color to blue
-  {
-    break-unless color-is-white?
-    starting-comment?:bool <- equal c, 35/#
-    break-unless starting-comment?
-    trace 90, [app], [switch color back to blue]
-    return 12/lightblue
-  }
-  # if color is blue and next character is newline, switch color to white
-  {
-    color-is-blue?:bool <- equal color, 12/lightblue
-    break-unless color-is-blue?
-    ending-comment?:bool <- equal c, 10/newline
-    break-unless ending-comment?
-    trace 90, [app], [switch color back to white]
-    return 7/white
-  }
-  # if color is white (no comments) and next character is '<', switch color to red
-  {
-    break-unless color-is-white?
-    starting-assignment?:bool <- equal c, 60/<
-    break-unless starting-assignment?
-    return 1/red
-  }
-  # if color is red and next character is space, switch color to white
-  {
-    color-is-red?:bool <- equal color, 1/red
-    break-unless color-is-red?
-    ending-assignment?:bool <- equal c, 32/space
-    break-unless ending-assignment?
-    return 7/white
-  }
-  # otherwise no change
-  return color
-]
-
-scenario render-colors-assignment [
-  local-scope
-  assume-screen 8/width, 5/height
-  s:text <- new [abc
-d <- e
-f]
-  e:&:editor <- new-editor s, 0/left, 8/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .        .
-    .abc     .
-    .d <- e  .
-    .f       .
-    .        .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .        .
-    .        .
-    .  <-    .
-    .        .
-    .        .
-  ]
-]
diff --git a/archive/2.vm/edit/002-typing.mu b/archive/2.vm/edit/002-typing.mu
deleted file mode 100644
index ef3f25d2..00000000
--- a/archive/2.vm/edit/002-typing.mu
+++ /dev/null
@@ -1,1144 +0,0 @@
-## handling events from the keyboard, mouse, touch screen, ...
-
-# temporary main: interactive editor
-# hit ctrl-c to exit
-def! main text:text [
-  local-scope
-  load-inputs
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  editor:&:editor <- new-editor text, 5/left, 45/right
-  editor-render null/screen, editor
-  editor-event-loop null/screen, null/console, editor
-  close-console
-]
-
-def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [
-  local-scope
-  load-inputs
-  {
-    # looping over each (keyboard or touch) event as it occurs
-    +next-event
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    screen <- move-cursor screen, cursor-row, cursor-column
-    e:event, found?:bool, quit?:bool, console <- read-event console
-    loop-unless found?
-    break-if quit?  # only in tests
-    trace 10, [app], [next-event]
-    # 'touch' event
-    t:touch-event, is-touch?:bool <- maybe-convert e, touch:variant
-    {
-      break-unless is-touch?
-      move-cursor editor, screen, t
-      loop +next-event
-    }
-    # keyboard events
-    {
-      break-if is-touch?
-      go-render?:bool <- handle-keyboard-event screen, editor, e
-      {
-        break-unless go-render?
-        screen <- editor-render screen, editor
-      }
-    }
-    loop
-  }
-]
-
-# process click, return if it was on current editor
-def move-cursor editor:&:editor, screen:&:screen, t:touch-event -> in-focus?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, false
-  click-row:num <- get t, row:offset
-  return-unless click-row, false  # ignore clicks on 'menu'
-  click-column:num <- get t, column:offset
-  left:num <- get *editor, left:offset
-  too-far-left?:bool <- lesser-than click-column, left
-  return-if too-far-left?, false
-  right:num <- get *editor, right:offset
-  too-far-right?:bool <- greater-than click-column, right
-  return-if too-far-right?, false
-  # position cursor
-  <begin-move-cursor>
-  editor <- snap-cursor editor, screen, click-row, click-column
-  undo-coalesce-tag:num <- copy 0/never
-  <end-move-cursor>
-  # gain focus
-  return true
-]
-
-# Variant of 'render' that only moves the cursor (coordinates and
-# before-cursor). If it's past the end of a line, it 'slides' it left. If it's
-# past the last line it positions at end of last line.
-def snap-cursor editor:&:editor, screen:&:screen, target-row:num, target-column:num -> editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  screen-height:num <- screen-height screen
-  # count newlines until screen row
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  row:num <- copy 1/top
-  column:num <- copy left
-  *editor <- put *editor, cursor-row:offset, target-row
-  cursor-row:num <- copy target-row
-  *editor <- put *editor, cursor-column:offset, target-column
-  cursor-column:num <- copy target-column
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # update editor.before-cursor
-    # Doing so at the start of each iteration ensures it stays one step behind
-    # the current character.
-    {
-      at-cursor-row?:bool <- equal row, cursor-row
-      break-unless at-cursor-row?
-      at-cursor?:bool <- equal column, cursor-column
-      break-unless at-cursor?
-      before-cursor <- copy prev
-      *editor <- put *editor, before-cursor:offset, before-cursor
-    }
-    c:char <- get *curr, value:offset
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # adjust cursor if necessary
-      {
-        at-cursor-row?:bool <- equal row, cursor-row
-        break-unless at-cursor-row?
-        left-of-cursor?:bool <- lesser-than column, cursor-column
-        break-unless left-of-cursor?
-        cursor-column <- copy column
-        *editor <- put *editor, cursor-column:offset, cursor-column
-        before-cursor <- copy prev
-        *editor <- put *editor, before-cursor:offset, before-cursor
-      }
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      column <- copy left
-      row <- add row, 1
-      # don't increment curr/prev
-      loop +next-character
-    }
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # is cursor to the right of the last line? move to end
-  {
-    at-cursor-row?:bool <- equal row, cursor-row
-    cursor-outside-line?:bool <- lesser-or-equal column, cursor-column
-    before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line?
-    above-cursor-row?:bool <- lesser-than row, cursor-row
-    before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row?
-    break-unless before-cursor?
-    cursor-row <- copy row
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy column
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    before-cursor <- copy prev
-    *editor <- put *editor, before-cursor:offset, before-cursor
-  }
-]
-
-# Process an event 'e' and try to minimally update the screen.
-# Set 'go-render?' to true to indicate the caller must perform a non-minimal update.
-def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render?:bool, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, false/don't-render
-  screen-width:num <- screen-width screen
-  screen-height:num <- screen-height screen
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  save-row:num <- copy cursor-row
-  save-column:num <- copy cursor-column
-  # character
-  {
-    c:char, is-unicode?:bool <- maybe-convert e, text:variant
-    break-unless is-unicode?
-    trace 10, [app], [handle-keyboard-event: special character]
-    # exceptions for special characters go here
-    <handle-special-character>
-    # ignore any other special characters
-    regular-character?:bool <- greater-or-equal c, 32/space
-    return-unless regular-character?, false/don't-render
-    # otherwise type it in
-    <begin-insert-character>
-    go-render? <- insert-at-cursor editor, c, screen
-    <end-insert-character>
-    return
-  }
-  # special key to modify the text or move the cursor
-  k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant
-  assert is-keycode?, [event was of unknown type; neither keyboard nor mouse]
-  # handlers for each special key will go here
-  <handle-special-key>
-  return true/go-render
-]
-
-def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  insert c, before-cursor
-  before-cursor <- next before-cursor
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  save-row:num <- copy cursor-row
-  save-column:num <- copy cursor-column
-  screen-width:num <- screen-width screen
-  screen-height:num <- screen-height screen
-  # occasionally we'll need to mess with the cursor
-  <insert-character-special-case>
-  # but mostly we'll just move the cursor right
-  cursor-column <- add cursor-column, 1
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  next:&:duplex-list:char <- next before-cursor
-  {
-    # at end of all text? no need to scroll? just print the character and leave
-    at-end?:bool <- equal next, null
-    break-unless at-end?
-    bottom:num <- subtract screen-height, 1
-    at-bottom?:bool <- equal save-row, bottom
-    at-right?:bool <- equal save-column, right
-    overflow?:bool <- and at-bottom?, at-right?
-    break-if overflow?
-    move-cursor screen, save-row, save-column
-    print screen, c
-    return false/don't-render
-  }
-  {
-    # not at right margin? print the character and rest of line
-    break-unless next
-    at-right?:bool <- greater-or-equal cursor-column, screen-width
-    break-if at-right?
-    curr:&:duplex-list:char <- copy before-cursor
-    move-cursor screen, save-row, save-column
-    curr-column:num <- copy save-column
-    {
-      # hit right margin? give up and let caller render
-      at-right?:bool <- greater-than curr-column, right
-      return-if at-right?, true/go-render
-      break-unless curr
-      # newline? done.
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      print screen, currc
-      curr-column <- add curr-column, 1
-      curr <- next curr
-      loop
-    }
-    return false/don't-render
-  }
-  return true/go-render
-]
-
-# helper for tests
-def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  old-top-idx:num <- save-top-idx screen
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  row:num, column:num <- render screen, editor
-  draw-horizontal screen, row, left, right, 9480/horizontal-dotted
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-  assert-no-scroll screen, old-top-idx
-]
-
-scenario editor-handles-empty-event-queue [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  assume-console []
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-handles-mouse-clicks [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 1  # on the 'b'
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor is at row 0..
-    4 <- 1  # ..and column 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 1, 7  # last line, to the right of text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 1, 7  # interior line, to the right of text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 3, 7  # below text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-column [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor occupies only left half of screen
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    # click on right half of screen
-    left-click 3, 8
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1  # no change to cursor row
-    4 <- 0  # ..or column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-in-menu-area [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    # click on first, 'menu' row
-    left-click 0, 3
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # no change to cursor
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-]
-
-scenario editor-inserts-characters-into-empty-editor [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    type [abc]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # type two letters at different places
-  assume-console [
-    type [0]
-    left-click 1, 2
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0adbc     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 7, [print-character]  # 4 for first letter, 3 for second
-]
-
-scenario editor-inserts-characters-at-cursor-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 5  # right of last line
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-5 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 5  # right of non-last line
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abce      .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .de        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-6 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [ef]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]
-]
-
-scenario editor-moves-cursor-after-inserting-characters [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 5/right
-  editor-render screen, e
-  assume-console [
-    type [01]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .01ab      .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-# if the cursor reaches the right margin, wrap the line
-
-scenario editor-wraps-line-on-insert [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  # type a letter
-  assume-console [
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # no wrap yet
-  screen-should-contain [
-    .     .
-    .eabc .
-    .┈┈┈┈┈.
-    .     .
-    .     .
-  ]
-  # type a second letter
-  assume-console [
-    type [f]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # now wrap
-  screen-should-contain [
-    .     .
-    .efab↩.
-    .c    .
-    .┈┈┈┈┈.
-    .     .
-  ]
-]
-
-scenario editor-wraps-line-on-insert-2 [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  s:text <- new [abcdefg
-defg]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # type more text at the start
-  assume-console [
-    left-click 3, 0
-    type [abc]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor is not wrapped
-  memory-should-contain [
-    3 <- 3
-    4 <- 3
-  ]
-  # but line is wrapped
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .efg       .
-    .abcd↩     .
-    .efg       .
-  ]
-]
-
-after <insert-character-special-case> [
-  # if the line wraps at the cursor, move cursor to start of next row
-  {
-    # if either:
-    # a) we're at the end of the line and at the column of the wrap indicator, or
-    # b) we're not at end of line and just before the column of the wrap indicator
-    wrap-column:num <- copy right
-    before-wrap-column:num <- subtract wrap-column, 1
-    at-wrap?:bool <- greater-or-equal cursor-column, wrap-column
-    just-before-wrap?:bool <- greater-or-equal cursor-column, before-wrap-column
-    next:&:duplex-list:char <- next before-cursor
-    # at end of line? next == 0 || next.value == 10/newline
-    at-end-of-line?:bool <- equal next, null
-    {
-      break-if at-end-of-line?
-      next-character:char <- get *next, value:offset
-      at-end-of-line? <- equal next-character, 10/newline
-    }
-    # break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?))
-    move-cursor-to-next-line?:bool <- copy false
-    {
-      break-if at-end-of-line?
-      move-cursor-to-next-line? <- copy just-before-wrap?
-      # if we're moving the cursor because it's in the middle of a wrapping
-      # line, adjust it to left-most column
-      potential-new-cursor-column:num <- copy left
-    }
-    {
-      break-unless at-end-of-line?
-      move-cursor-to-next-line? <- copy at-wrap?
-      # if we're moving the cursor because it's at the end of a wrapping line,
-      # adjust it to one past the left-most column to make room for the
-      # newly-inserted wrap-indicator
-      potential-new-cursor-column:num <- add left, 1/make-room-for-wrap-indicator
-    }
-    break-unless move-cursor-to-next-line?
-    cursor-column <- copy potential-new-cursor-column
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    # if we're out of the screen, scroll down
-    {
-      below-screen?:bool <- greater-or-equal cursor-row, screen-height
-      break-unless below-screen?
-      <scroll-down>
-    }
-    return true/go-render
-  }
-]
-
-scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  assume-console [
-    left-click 1, 3  # right before the wrap icon
-    type [f]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcf↩     .
-    .de        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 0  # cursor column
-  ]
-]
-
-scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # create an editor containing two lines
-  s:text <- new [abc
-xyz]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .xyz       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 1, 4  # at end of first line
-    type [de]  # trigger wrap
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .xyz       .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-wraps-cursor-to-left-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 2/left, 7/right
-  assume-console [
-    left-click 1, 5  # line is full; no wrap icon yet
-    type [01]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .  abc0↩   .
-    .  1de     .
-    .  ┈┈┈┈┈   .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 3  # cursor column
-  ]
-]
-
-# if newline, move cursor to start of next line, and maybe align indent with previous line
-
-container editor [
-  indent?:bool
-]
-
-after <editor-initialization> [
-  *result <- put *result, indent?:offset, true
-]
-
-scenario editor-moves-cursor-down-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  assume-console [
-    type [0
-1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0         .
-    .1abc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-character> [
-  {
-    newline?:bool <- equal c, 10/newline
-    break-unless newline?
-    <begin-insert-enter>
-    insert-new-line-and-indent editor, screen
-    <end-insert-enter>
-    return true/go-render
-  }
-]
-
-def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  screen-height:num <- screen-height screen
-  # update cursor coordinates
-  at-start-of-wrapped-line?:bool <- at-start-of-wrapped-line? editor
-  {
-    break-if at-start-of-wrapped-line?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  cursor-column <- copy left
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  # maybe scroll
-  {
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal, never greater
-    break-unless below-screen?
-    <scroll-down2>
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  # insert newline
-  insert 10/newline, before-cursor
-  before-cursor <- next before-cursor
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  # indent if necessary
-  indent?:bool <- get *editor, indent?:offset
-  return-unless indent?
-  d:&:duplex-list:char <- get *editor, data:offset
-  end-of-previous-line:&:duplex-list:char <- prev before-cursor
-  indent:num <- line-indent end-of-previous-line, d
-  i:num <- copy 0
-  {
-    indent-done?:bool <- greater-or-equal i, indent
-    break-if indent-done?
-    insert-at-cursor editor, 32/space, screen
-    i <- add i, 1
-    loop
-  }
-]
-
-def at-start-of-wrapped-line? editor:&:editor -> result:bool [
-  local-scope
-  load-inputs
-  left:num <- get *editor, left:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  cursor-at-left?:bool <- equal cursor-column, left
-  return-unless cursor-at-left?, false
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  before-before-cursor:&:duplex-list:char <- prev before-cursor
-  return-unless before-before-cursor, false  # cursor is at start of editor
-  char-before-cursor:char <- get *before-cursor, value:offset
-  cursor-after-newline?:bool <- equal char-before-cursor, 10/newline
-  return-if cursor-after-newline?, false
-  # if cursor is at left margin and not at start, but previous character is not a newline,
-  # then we're at start of a wrapped line
-  return true
-]
-
-# takes a pointer 'curr' into the doubly-linked list and its sentinel, counts
-# the number of spaces at the start of the line containing 'curr'.
-def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [
-  local-scope
-  load-inputs
-  result:num <- copy 0
-  return-unless curr
-  at-start?:bool <- equal curr, start
-  return-if at-start?
-  {
-    curr <- prev curr
-    break-unless curr
-    at-start?:bool <- equal curr, start
-    break-if at-start?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    # if c is a space, increment result
-    is-space?:bool <- equal c, 32/space
-    {
-      break-unless is-space?
-      result <- add result, 1
-    }
-    # if c is not a space, reset result
-    {
-      break-if is-space?
-      result <- copy 0
-    }
-    loop
-  }
-]
-
-scenario editor-moves-cursor-down-after-inserting-newline-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 1/left, 10/right
-  assume-console [
-    type [0
-1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . 0        .
-    . 1abc     .
-    . ┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-clears-previous-line-completely-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    press enter
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # line should be fully cleared
-  screen-should-contain [
-    .          .
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-splits-wrapped-line-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 2, 0
-    press enter
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .ef        .
-    .┈┈┈┈┈     .
-  ]
-  memory-should-contain [
-    10 <- 2  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-scenario editor-inserts-indent-after-newline [
-  local-scope
-  assume-screen 10/width, 10/height
-  s:text <- new [ab
-  cd
-ef]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  # position cursor after 'cd' and hit 'newline'
-  assume-console [
-    left-click 2, 8
-    type [
-]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor should be below start of previous line
-  memory-should-contain [
-    3 <- 3  # cursor row
-    4 <- 2  # cursor column (indented)
-  ]
-]
-
-scenario editor-skips-indent-around-paste [
-  local-scope
-  assume-screen 10/width, 10/height
-  s:text <- new [ab
-  cd
-ef]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  # position cursor after 'cd' and hit 'newline' surrounded by paste markers
-  assume-console [
-    left-click 2, 8
-    press 65507  # start paste
-    press enter
-    press 65506  # end paste
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor should be below start of previous line
-  memory-should-contain [
-    3 <- 3  # cursor row
-    4 <- 0  # cursor column (not indented)
-  ]
-]
-
-after <handle-special-key> [
-  {
-    paste-start?:bool <- equal k, 65507/paste-start
-    break-unless paste-start?
-    *editor <- put *editor, indent?:offset, false
-    return true/go-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    paste-end?:bool <- equal k, 65506/paste-end
-    break-unless paste-end?
-    *editor <- put *editor, indent?:offset, true
-    return true/go-render
-  }
-]
-
-## helpers
-
-def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  height:num <- screen-height screen
-  past-bottom?:bool <- greater-or-equal row, height
-  return-if past-bottom?
-  style:char, style-found?:bool <- next-input
-  {
-    break-if style-found?
-    style <- copy 9472/horizontal
-  }
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 245/grey
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  screen <- move-cursor screen, row, x
-  {
-    continue?:bool <- lesser-or-equal x, right  # right is inclusive, to match editor semantics
-    break-unless continue?
-    print screen, style, color, bg-color
-    x <- add x, 1
-    loop
-  }
-]
diff --git a/archive/2.vm/edit/003-shortcuts.mu b/archive/2.vm/edit/003-shortcuts.mu
deleted file mode 100644
index 872dfcea..00000000
--- a/archive/2.vm/edit/003-shortcuts.mu
+++ /dev/null
@@ -1,4462 +0,0 @@
-## special shortcuts for manipulating the editor
-# Some keys on the keyboard generate unicode characters, others generate
-# terminfo key codes. We need to modify different places in the two cases.
-
-# tab - insert two spaces
-
-scenario editor-inserts-two-spaces-on-tab [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-cd]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press tab
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  ab      .
-    .cd        .
-  ]
-  # we render at most two editor rows worth (one row for each space)
-  check-trace-count-for-label-lesser-than 10, [print-character]
-]
-
-scenario editor-inserts-two-spaces-and-wraps-line-on-tab [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcd], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press tab
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  ab↩     .
-    .cd        .
-  ]
-  # we re-render the whole editor
-  check-trace-count-for-label-greater-than 10, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    tab?:bool <- equal c, 9/tab
-    break-unless tab?
-    <begin-insert-character>
-    # todo: decompose insert-at-cursor into editor update and screen update,
-    # so that 'tab' doesn't render the current line multiple times
-    insert-at-cursor editor, 32/space, screen
-    go-render? <- insert-at-cursor editor, 32/space, screen
-    <end-insert-character>
-    return
-  }
-]
-
-# backspace - delete character before cursor
-
-scenario editor-handles-backspace-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 1
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .bc        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 0
-  ]
-  check-trace-count-for-label 3, [print-character]  # length of original line to overwrite
-]
-
-after <handle-special-character> [
-  {
-    delete-previous-character?:bool <- equal c, 8/backspace
-    break-unless delete-previous-character?
-    <begin-backspace-character>
-    go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen
-    <end-backspace-character>
-    return
-  }
-]
-
-# return values:
-#   go-render? - whether caller needs to update the screen
-#   backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc.
-def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  data:&:duplex-list:char <- get *editor, data:offset
-  # if at start of text (before-cursor at § sentinel), return
-  prev:&:duplex-list:char <- prev before-cursor
-  return-unless prev, false/no-more-render, null/nothing-deleted
-  trace 10, [app], [delete-before-cursor]
-  original-row:num <- get *editor, cursor-row:offset
-  scroll?:bool <- move-cursor-coordinates-left editor
-  backspaced-cell:&:duplex-list:char <- copy before-cursor
-  data <- remove before-cursor, data  # will also neatly trim next/prev pointers in backspaced-cell/before-cursor
-  before-cursor <- copy prev
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  return-if scroll?, true/go-render
-  screen-width:num <- screen-width screen
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  # did we just backspace over a newline?
-  same-row?:bool <- equal cursor-row, original-row
-  return-unless same-row?, true/go-render
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  curr:&:duplex-list:char <- next before-cursor
-  screen <- move-cursor screen, cursor-row, cursor-column
-  curr-column:num <- copy cursor-column
-  {
-    # hit right margin? give up and let caller render
-    at-right?:bool <- greater-or-equal curr-column, right
-    return-if at-right?, true/go-render
-    break-unless curr
-    # newline? done.
-    currc:char <- get *curr, value:offset
-    at-newline?:bool <- equal currc, 10/newline
-    break-if at-newline?
-    screen <- print screen, currc
-    curr-column <- add curr-column, 1
-    curr <- next curr
-    loop
-  }
-  # we're guaranteed not to be at the right margin
-  space:char <- copy 32/space
-  screen <- print screen, space
-  go-render? <- copy false
-]
-
-def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  go-render?:bool <- copy false
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  # if not at left margin, move one character left
-  {
-    at-left-margin?:bool <- equal cursor-column, left
-    break-if at-left-margin?
-    trace 10, [app], [decrementing cursor column]
-    cursor-column <- subtract cursor-column, 1
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    return
-  }
-  # if at left margin, we must move to previous row:
-  top-of-screen?:bool <- equal cursor-row, 1  # exclude menu bar
-  {
-    break-if top-of-screen?
-    cursor-row <- subtract cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  {
-    break-unless top-of-screen?
-    <scroll-up>
-    go-render? <- copy true
-  }
-  {
-    # case 1: if previous character was newline, figure out how long the previous line is
-    previous-character:char <- get *before-cursor, value:offset
-    previous-character-is-newline?:bool <- equal previous-character, 10/newline
-    break-unless previous-character-is-newline?
-    # compute length of previous line
-    trace 10, [app], [switching to previous line]
-    d:&:duplex-list:char <- get *editor, data:offset
-    end-of-line:num <- previous-line-length before-cursor, d
-    right:num <- get *editor, right:offset
-    width:num <- subtract right, left
-    wrap?:bool <- greater-than end-of-line, width
-    {
-      break-unless wrap?
-      _, column-offset:num <- divide-with-remainder end-of-line, width
-      cursor-column <- add left, column-offset
-      *editor <- put *editor, cursor-column:offset, cursor-column
-    }
-    {
-      break-if wrap?
-      cursor-column <- add left, end-of-line
-      *editor <- put *editor, cursor-column:offset, cursor-column
-    }
-    return
-  }
-  # case 2: if previous-character was not newline, we're just at a wrapped line
-  trace 10, [app], [wrapping to previous line]
-  right:num <- get *editor, right:offset
-  cursor-column <- subtract right, 1  # leave room for wrap icon
-  *editor <- put *editor, cursor-column:offset, cursor-column
-]
-
-# takes a pointer 'curr' into the doubly-linked list and its sentinel, counts
-# the length of the previous line before the 'curr' pointer.
-def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [
-  local-scope
-  load-inputs
-  result:num <- copy 0
-  return-unless curr
-  at-start?:bool <- equal curr, start
-  return-if at-start?
-  {
-    curr <- prev curr
-    break-unless curr
-    at-start?:bool <- equal curr, start
-    break-if at-start?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    result <- add result, 1
-    loop
-  }
-]
-
-scenario editor-clears-last-line-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-cd]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  assume-console [
-    left-click 2, 0
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 2
-  ]
-]
-
-scenario editor-joins-and-wraps-lines-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with two long-ish but non-wrapping lines
-  s:text <- new [abc def
-ghi jkl]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position the cursor at the start of the second and hit backspace
-  assume-console [
-    left-click 2, 0
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # resulting single line should wrap correctly
-  screen-should-contain [
-    .          .
-    .abc defgh↩.
-    .i jkl     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-wraps-long-lines-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor in part of the screen with a long line
-  e:&:editor <- new-editor [abc def ghij], 0/left, 8/right
-  editor-render screen, e
-  # confirm that it wraps
-  screen-should-contain [
-    .          .
-    .abc def↩  .
-    . ghij     .
-    .┈┈┈┈┈┈┈┈  .
-  ]
-  $clear-trace
-  # position the cursor somewhere in the middle of the top screen line and hit backspace
-  assume-console [
-    left-click 1, 4
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # resulting single line should wrap correctly and not overflow its bounds
-  screen-should-contain [
-    .          .
-    .abcdef ↩  .
-    .ghij      .
-    .┈┈┈┈┈┈┈┈  .
-    .          .
-  ]
-]
-
-# delete - delete character at cursor
-
-scenario editor-handles-delete-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press delete
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .bc        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]  # length of original line to overwrite
-  $clear-trace
-  assume-console [
-    press delete
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .c         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]  # new length to overwrite
-]
-
-after <handle-special-key> [
-  {
-    delete-next-character?:bool <- equal k, 65522/delete
-    break-unless delete-next-character?
-    <begin-delete-character>
-    go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen
-    <end-delete-character>
-    return
-  }
-]
-
-def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  data:&:duplex-list:char <- get *editor, data:offset
-  deleted-cell:&:duplex-list:char <- next before-cursor
-  return-unless deleted-cell, false/don't-render
-  currc:char <- get *deleted-cell, value:offset
-  data <- remove deleted-cell, data
-  deleted-newline?:bool <- equal currc, 10/newline
-  return-if deleted-newline?, true/go-render
-  # wasn't a newline? render rest of line
-  curr:&:duplex-list:char <- next before-cursor  # refresh after remove above
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  screen <- move-cursor screen, cursor-row, cursor-column
-  curr-column:num <- copy cursor-column
-  screen-width:num <- screen-width screen
-  {
-    # hit right margin? give up and let caller render
-    at-right?:bool <- greater-or-equal curr-column, screen-width
-    return-if at-right?, true/go-render
-    break-unless curr
-    currc:char <- get *curr, value:offset
-    at-newline?:bool <- equal currc, 10/newline
-    break-if at-newline?
-    screen <- print screen, currc
-    curr-column <- add curr-column, 1
-    curr <- next curr
-    loop
-  }
-  # we're guaranteed not to be at the right margin
-  space:char <- copy 32/space
-  screen <- print screen, space
-  go-render? <- copy false
-]
-
-# right arrow
-
-scenario editor-moves-cursor-right-with-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press right-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]  # 0 and following characters
-]
-
-after <handle-special-key> [
-  {
-    move-to-next-character?:bool <- equal k, 65514/right-arrow
-    break-unless move-to-next-character?
-    # if not at end of text
-    next-cursor:&:duplex-list:char <- next before-cursor
-    break-unless next-cursor
-    # scan to next character
-    <begin-move-cursor>
-    before-cursor <- copy next-cursor
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    go-render?:bool <- move-cursor-coordinates-right editor, screen-height
-    screen <- move-cursor screen, cursor-row, cursor-column
-    undo-coalesce-tag:num <- copy 2/right-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  # if crossed a newline, move cursor to start of next row
-  {
-    old-cursor-character:char <- get *before-cursor, value:offset
-    was-at-newline?:bool <- equal old-cursor-character, 10/newline
-    break-unless was-at-newline?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal
-    return-unless below-screen?, false/don't-render
-    <scroll-down>
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    return true/go-render
-  }
-  # if the line wraps, move cursor to start of next row
-  {
-    # if we're at the column just before the wrap indicator
-    wrap-column:num <- subtract right, 1
-    at-wrap?:bool <- equal cursor-column, wrap-column
-    break-unless at-wrap?
-    # and if next character isn't newline
-    next:&:duplex-list:char <- next before-cursor
-    break-unless next
-    next-character:char <- get *next, value:offset
-    newline?:bool <- equal next-character, 10/newline
-    break-if newline?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal
-    return-unless below-screen?, false/no-more-render
-    <scroll-down>
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    return true/go-render
-  }
-  # otherwise move cursor one character right
-  cursor-column <- add cursor-column, 1
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  go-render? <- copy false
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # type right-arrow a few times to get to start of second line
-  assume-console [
-    press right-arrow
-    press right-arrow
-    press right-arrow
-    press right-arrow  # next line
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # type something and ensure it goes where it should
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0d        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]  # new length of second line
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 1/left, 10/right
-  editor-render screen, e
-  assume-console [
-    press right-arrow
-    press right-arrow
-    press right-arrow
-    press right-arrow  # next line
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . abc      .
-    . 0d       .
-    . ┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # line just barely wrapping
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at last character before wrap and hit right-arrow
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  # now hit right arrow again
-  assume-console [
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 1/left, 6/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 4
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    . abcd↩    .
-    . ef       .
-    . ┈┈┈┈┈    .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # move to end of line, press right-arrow, type a character
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # new character should be in next line
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0d        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]
-]
-
-# todo: ctrl-right: next word-end
-
-# left arrow
-
-scenario editor-moves-cursor-left-with-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 2
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]
-]
-
-after <handle-special-key> [
-  {
-    move-to-previous-character?:bool <- equal k, 65515/left-arrow
-    break-unless move-to-previous-character?
-    trace 10, [app], [left arrow]
-    # if not at start of text (before-cursor at § sentinel)
-    prev:&:duplex-list:char <- prev before-cursor
-    return-unless prev, false/don't-render
-    <begin-move-cursor>
-    go-render? <- move-cursor-coordinates-left editor
-    before-cursor <- copy prev
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    undo-coalesce-tag:num <- copy 1/left-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with two lines
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at start of second line (so there's no previous newline)
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with three lines
-  s:text <- new [abc
-def
-g]
-  e:&:editor <- new-editor s:text, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor further down (so there's a newline before the character at
-  # the cursor)
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def0      .
-    .g         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 1, [print-character]  # just the '0'
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def
-g]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at start of text, press left-arrow, then type a character
-  assume-console [
-    left-click 1, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # left-arrow should have had no effect
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .g         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 4, [print-character]  # length of first line
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with text containing an empty line
-  s:text <- new [abc
-
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e:&:editor
-  $clear-trace
-  # position cursor right after empty line
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0         .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 1, [print-character]  # just the '0'
-]
-
-scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a wrapping line
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # previous row
-    4 <- 3  # right margin except wrap icon
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a wrapping line followed by a second line
-  s:text <- new [abcdef
-g]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .g         .
-    .┈┈┈┈┈     .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2  # previous row
-    4 <- 2  # end of wrapped line
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a line on the verge of wrapping, followed by a second line
-  s:text <- new [abcd
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # previous row
-    4 <- 4  # end of wrapped line
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-# todo: ctrl-left: previous word-start
-
-# up arrow
-
-scenario editor-moves-to-previous-line-with-up-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 1
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-key> [
-  {
-    move-to-previous-line?:bool <- equal k, 65517/up-arrow
-    break-unless move-to-previous-line?
-    <begin-move-cursor>
-    go-render? <- move-to-previous-line editor
-    undo-coalesce-tag:num <- copy 3/up-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  go-render?:bool <- copy false
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  already-at-top?:bool <- lesser-or-equal cursor-row, 1/top
-  {
-    # if cursor not at top, move it
-    break-if already-at-top?
-    # if not at start of screen line, move to start of screen line (previous newline)
-    # then scan back another line
-    # if either step fails, give up without modifying cursor or coordinates
-    curr:&:duplex-list:char <- copy before-cursor
-    old:&:duplex-list:char <- copy curr
-    {
-      at-left?:bool <- equal cursor-column, left
-      break-if at-left?
-      curr <- before-previous-screen-line curr, editor
-      no-motion?:bool <- equal curr, old
-      return-if no-motion?
-    }
-    {
-      curr <- before-previous-screen-line curr, editor
-      no-motion?:bool <- equal curr, old
-      return-if no-motion?
-    }
-    before-cursor <- copy curr
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    cursor-row <- subtract cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    # scan ahead to right column or until end of line
-    target-column:num <- copy cursor-column
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    {
-      done?:bool <- greater-or-equal cursor-column, target-column
-      break-if done?
-      curr:&:duplex-list:char <- next before-cursor
-      break-unless curr
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      #
-      before-cursor <- copy curr
-      *editor <- put *editor, before-cursor:offset, before-cursor
-      cursor-column <- add cursor-column, 1
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      loop
-    }
-    return
-  }
-  {
-    # if cursor already at top, scroll up
-    break-unless already-at-top?
-    <scroll-up>
-    return true/go-render
-  }
-]
-
-# Takes a pointer into the doubly-linked list, scans back to before start of
-# previous *wrapped* line.
-# Returns original if no next newline.
-# Beware: never return null pointer.
-def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- copy in
-  c:char <- get *curr, value:offset
-  # compute max, number of characters to skip
-  #   1 + len%(width-1)
-  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
-  sentinel:&:duplex-list:char <- get *editor, data:offset
-  len:num <- previous-line-length curr, sentinel
-  {
-    break-if len
-    # empty line; just skip this newline
-    prev:&:duplex-list:char <- prev curr
-    return-unless prev, curr
-    return prev
-  }
-  _, max:num <- divide-with-remainder len, max-line-length
-  # remainder 0 => scan one width-worth
-  {
-    break-if max
-    max <- copy max-line-length
-  }
-  max <- add max, 1
-  count:num <- copy 0
-  # skip 'max' characters
-  {
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    prev:&:duplex-list:char <- prev curr
-    break-unless prev
-    curr <- copy prev
-    count <- add count, 1
-    loop
-  }
-  return curr
-]
-
-scenario editor-adjusts-column-at-previous-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 3
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .ab0       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-adjusts-column-at-empty-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 3
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-moves-to-previous-line-from-zero-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  # start out with three lines
-  s:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # click on the third line and hit up-arrow, so you end up just after a newline
-  assume-console [
-    left-click 3, 0
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0def      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-moves-to-previous-line-from-left-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  # start out with three lines
-  s:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor s, 1/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # click on the third line and hit up-arrow, so you end up just after a newline
-  assume-console [
-    left-click 3, 1
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . abc      .
-    . 0def     .
-    . ghi      .
-    . ┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-moves-to-top-line-in-presence-of-wrapped-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-  ]
-  $clear-trace
-  assume-console [
-    left-click 2, 0
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0abc↩     .
-    .de        .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-moves-to-top-line-in-presence-of-wrapped-line-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-defgh]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .defg↩     .
-    .h         .
-    .┈┈┈┈┈     .
-  ]
-  $clear-trace
-  assume-console [
-    left-click 3, 0
-    press up-arrow
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .defg↩     .
-    .h         .
-    .┈┈┈┈┈     .
-  ]
-]
-
-# down arrow
-
-scenario editor-moves-to-next-line-with-down-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # cursor starts out at (1, 0)
-  assume-console [
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # ..and ends at (2, 0)
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0def      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-key> [
-  {
-    move-to-next-line?:bool <- equal k, 65516/down-arrow
-    break-unless move-to-next-line?
-    <begin-move-cursor>
-    go-render? <- move-to-next-line editor, screen-height
-    undo-coalesce-tag:num <- copy 4/down-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  last-line:num <- subtract screen-height, 1
-  bottom:num <- get *editor, bottom:offset
-  at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line
-  {
-    break-if before-cursor
-    {
-      break-if at-bottom-of-screen?
-      return false/don't-render
-    }
-    {
-      break-unless at-bottom-of-screen?
-      jump +try-to-scroll
-    }
-  }
-  next:&:duplex-list:char <- next before-cursor
-  {
-    break-if next
-    {
-      break-if at-bottom-of-screen?
-      return false/don't-render
-    }
-    {
-      break-unless at-bottom-of-screen?
-      jump +try-to-scroll
-    }
-  }
-  already-at-bottom?:bool <- greater-or-equal cursor-row, last-line
-  {
-    # if cursor not at bottom, move it
-    break-if already-at-bottom?
-    target-column:num <- copy cursor-column
-    # scan to start of next line
-    {
-      next:&:duplex-list:char <- next before-cursor
-      break-unless next
-      done?:bool <- greater-or-equal cursor-column, right
-      break-if done?
-      cursor-column <- add cursor-column, 1
-      before-cursor <- copy next
-      c:char <- get *next, value:offset
-      at-newline?:bool <- equal c, 10/newline
-      break-if at-newline?
-      loop
-    }
-    {
-      break-if next
-      {
-        break-if at-bottom-of-screen?
-        return false/don't-render
-      }
-      {
-        break-unless at-bottom-of-screen?
-        jump +try-to-scroll
-      }
-    }
-    cursor-row <- add cursor-row, 1
-    cursor-column <- copy left
-    {
-      next:&:duplex-list:char <- next before-cursor
-      break-unless next
-      c:char <- get *next, value:offset
-      at-newline?:bool <- equal c, 10/newline
-      break-if at-newline?
-      done?:bool <- greater-or-equal cursor-column, target-column
-      break-if done?
-      cursor-column <- add cursor-column, 1
-      before-cursor <- copy next
-      loop
-    }
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    return false/don't-render
-  }
-  +try-to-scroll
-  <scroll-down>
-  go-render? <- copy true
-]
-
-scenario editor-adjusts-column-at-next-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # second line is shorter than first
-  s:text <- new [abcde
-fg
-hi]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # move to end of first line, then press down
-  assume-console [
-    left-click 1, 8
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor doesn't go vertically down, it goes to end of shorter line
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcde     .
-    .fg0       .
-    .hi        .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-moves-down-within-wrapped-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdefghijklmno], 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcdefghi↩.
-    .jklmno    .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # position cursor on first screen line, but past end of second screen line
-  assume-console [
-    left-click 1, 8
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor should be at end of second screen line
-  memory-should-contain [
-    3 <- 2
-    4 <- 6
-  ]
-]
-
-# ctrl-a/home - move cursor to start of line
-
-scenario editor-moves-to-start-of-line-with-ctrl-a [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line, press ctrl-a
-  assume-console [
-    left-click 2, 3
-    press ctrl-a
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    4 <- 2
-    5 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    move-to-start-of-line?:bool <- equal c, 1/ctrl-a
-    break-unless move-to-start-of-line?
-    <begin-move-cursor>
-    move-to-start-of-screen-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    move-to-start-of-line?:bool <- equal k, 65521/home
-    break-unless move-to-start-of-line?
-    <begin-move-cursor>
-    move-to-start-of-screen-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-# handles wrapped lines
-# precondition: cursor-column should be in a consistent state
-def move-to-start-of-screen-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  # update cursor column
-  left:num <- get *editor, left:offset
-  col:num <- get *editor, cursor-column:offset
-  # update before-cursor
-  curr:&:duplex-list:char <- get *editor, before-cursor:offset
-  # while not at start of line, move
-  {
-    done?:bool <- equal col, left
-    break-if done?
-    assert curr, [move-to-start-of-line tried to move before start of text]
-    curr <- prev curr
-    col <- subtract col, 1
-    loop
-  }
-  *editor <- put *editor, cursor-column:offset, col
-  *editor <- put *editor, before-cursor:offset, curr
-]
-
-scenario editor-moves-to-start-of-line-with-ctrl-a-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press ctrl-a
-  assume-console [
-    left-click 1, 3
-    press ctrl-a
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    4 <- 1
-    5 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-line-with-home [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  # start on second line, press 'home'
-  assume-console [
-    left-click 2, 3
-    press home
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-line-with-home-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press 'home'
-  assume-console [
-    left-click 1, 3
-    press home
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-screen-line-with-ctrl-a [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [123456], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1234↩     .
-    .56        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # start on second line, press ctrl-a then up
-  assume-console [
-    left-click 2, 1
-    press ctrl-a
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of first line
-  memory-should-contain [
-    4 <- 1  # cursor-row
-    5 <- 0  # cursor-column
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # make sure before-cursor is in sync
-  assume-console [
-    type [a]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .a123↩     .
-    .456       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1  # cursor-row
-    5 <- 1  # cursor-column
-  ]
-]
-
-# ctrl-e/end - move cursor to end of line
-
-scenario editor-moves-to-end-of-line-with-ctrl-e [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press ctrl-e
-  assume-console [
-    left-click 1, 1
-    press ctrl-e
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # editor inserts future characters at cursor
-  assume-console [
-    type [z]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 4
-  ]
-  screen-should-contain [
-    .          .
-    .123z      .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    move-to-end-of-line?:bool <- equal c, 5/ctrl-e
-    break-unless move-to-end-of-line?
-    <begin-move-cursor>
-    move-to-end-of-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    move-to-end-of-line?:bool <- equal k, 65520/end
-    break-unless move-to-end-of-line?
-    <begin-move-cursor>
-    move-to-end-of-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-def move-to-end-of-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  right:num <- get *editor, right:offset
-  # while not at end of line, move
-  {
-    next:&:duplex-list:char <- next before-cursor
-    break-unless next  # end of text
-    nextc:char <- get *next, value:offset
-    at-end-of-line?:bool <- equal nextc, 10/newline
-    break-if at-end-of-line?
-    cursor-column <- add cursor-column, 1
-    at-right?:bool <- equal cursor-column, right
-    break-if at-right?
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    before-cursor <- copy next
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    loop
-  }
-]
-
-scenario editor-moves-to-end-of-line-with-ctrl-e-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press ctrl-e
-  assume-console [
-    left-click 2, 1
-    press ctrl-e
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    4 <- 2
-    5 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-line-with-end [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press 'end'
-  assume-console [
-    left-click 1, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-line-with-end-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press 'end'
-  assume-console [
-    left-click 2, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    3 <- 2
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-wrapped-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123456
-789]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press 'end'
-  assume-console [
-    left-click 1, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    10 <- 1
-    11 <- 3
-  ]
-  # no prints
-  check-trace-count-for-label 0, [print-character]
-  # before-cursor is also consistent
-  assume-console [
-    type [a]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .123a↩     .
-    .456       .
-    .789       .
-    .┈┈┈┈┈     .
-  ]
-]
-
-# ctrl-u - delete text from start of line until (but not at) cursor
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line, press ctrl-u
-  assume-console [
-    left-click 2, 2
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .6         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    delete-to-start-of-line?:bool <- equal c, 21/ctrl-u
-    break-unless delete-to-start-of-line?
-    <begin-delete-to-start-of-line>
-    deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor
-    <end-delete-to-start-of-line>
-    go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells
-    return
-  }
-]
-
-def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  curr-column:num <- get *editor, cursor-column:offset
-  # accumulate the current line as text and render it
-  buf:&:buffer:char <- new-buffer 30  # accumulator for the text we need to render
-  curr:&:duplex-list:char <- get *editor, before-cursor:offset
-  i:num <- copy curr-column
-  right:num <- get *editor, right:offset
-  {
-    # if we have a wrapped line, give up and render the whole screen
-    wrap?:bool <- greater-or-equal i, right
-    return-if wrap?, true/go-render
-    curr <- next curr
-    break-unless curr
-    c:char <- get *curr, value:offset
-    b:bool <- equal c, 10
-    break-if b
-    buf <- append buf, c
-    i <- add i, 1
-    loop
-  }
-  # if the line used to be wrapped, give up and render the whole screen
-  num-deleted-cells:num <- length deleted-cells
-  old-row-len:num <- add i, num-deleted-cells
-  left:num <- get *editor, left:offset
-  end:num <- subtract right, left
-  wrap?:bool <- greater-or-equal old-row-len, end
-  return-if wrap?, true/go-render
-  curr-line:text <- buffer-to-array buf
-  curr-row:num <- get *editor, cursor-row:offset
-  render-code screen, curr-line, curr-column, right, curr-row
-  return false/dont-render
-]
-
-def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [
-  local-scope
-  load-inputs
-  # compute range to delete
-  init:&:duplex-list:char <- get *editor, data:offset
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  update-top-of-screen?:bool <- copy false
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  start:&:duplex-list:char <- copy before-cursor
-  end:&:duplex-list:char <- next before-cursor
-  {
-    at-start-of-text?:bool <- equal start, init
-    break-if at-start-of-text?
-    curr:char <- get *start, value:offset
-    at-start-of-line?:bool <- equal curr, 10/newline
-    break-if at-start-of-line?
-    # if we went past top-of-screen, make a note to update it as well
-    at-top-of-screen?:bool <- equal start, top-of-screen
-    update-top-of-screen?:bool <- or update-top-of-screen?, at-top-of-screen?
-    start <- prev start
-    assert start, [delete-to-start-of-line tried to move before start of text]
-    loop
-  }
-  # snip it out
-  result:&:duplex-list:char <- next start
-  remove-between start, end
-  # update top-of-screen if it's just been invalidated
-  {
-    break-unless update-top-of-screen?
-    put *editor, top-of-screen:offset, start
-  }
-  # adjust cursor
-  before-cursor <- copy start
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  left:num <- get *editor, left:offset
-  *editor <- put *editor, cursor-column:offset, left
-  # if the line wrapped before, we may need to adjust cursor-row as well
-  right:num <- get *editor, right:offset
-  width:num <- subtract right, left
-  num-deleted:num <- length result
-  cursor-row-adjustment:num <- divide-with-remainder num-deleted, width
-  return-unless cursor-row-adjustment
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-row-in-editor:num <- subtract cursor-row, 1  # ignore menubar
-  at-top?:bool <- lesser-or-equal cursor-row-in-editor, cursor-row-adjustment
-  {
-    break-unless at-top?
-    cursor-row <- copy 1  # top of editor, below menubar
-  }
-  {
-    break-if at-top?
-    cursor-row <- subtract cursor-row, cursor-row-adjustment
-  }
-  put *editor, cursor-row:offset, cursor-row
-]
-
-def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless s
-  color:num <- copy 7/white
-  column:num <- copy left
-  screen <- move-cursor screen, row, column
-  screen-height:num <- screen-height screen
-  i:num <- copy 0
-  len:num <- length *s
-  {
-    +next-character
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    c:char <- index *s, i
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      {
-        done?:bool <- greater-than column, right
-        break-if done?
-        space:char <- copy 32/space
-        print screen, space
-        column <- add column, 1
-        loop
-      }
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      i <- add i, 1
-      loop +next-character
-    }
-    {
-      # at right? wrap.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment i
-      loop +next-character
-    }
-    i <- add i, 1
-    print screen, c, color
-    column <- add column, 1
-    loop
-  }
-  was-at-left?:bool <- equal column, left
-  clear-line-until screen, right
-  {
-    break-if was-at-left?
-    row <- add row, 1
-  }
-  move-cursor screen, row, left
-]
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press ctrl-u
-  assume-console [
-    left-click 1, 2
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .3         .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of line, press ctrl-u
-  assume-console [
-    left-click 1, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .          .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-final-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of final line, press ctrl-u
-  assume-console [
-    left-click 2, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 10/height
-  # first line starts out wrapping
-  s:text <- new [123456
-789]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1234↩     .
-    .56        .
-    .789       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # ctrl-u enough of the first line that it's no longer wrapping
-  assume-console [
-    left-click 1, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # entire screen needs to be refreshed
-  screen-should-contain [
-    .          .
-    .456       .
-    .789       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  check-trace-count-for-label 45, [print-character]
-]
-
-# sometimes hitting ctrl-u needs to adjust the cursor row
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-2 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-345678
-9]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .3456↩     .
-    .78        .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor on screen line after the wrap and hit ctrl-u
-  assume-console [
-    left-click 4, 1  # on '8'
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .8         .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # cursor moves up one screen line
-  memory-should-contain [
-    10 <- 3  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-# line wrapping twice (taking up 3 screen lines)
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-3 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-3456789abcd
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  assume-console [
-    left-click 4, 1  # on '8'
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .3456↩     .
-    .789a↩     .
-    .bcd       .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 5, 1
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .cd        .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # make sure we adjusted cursor-row
-  memory-should-contain [
-    10 <- 3  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-# adjusting cursor row at the top of the screen
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-4 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # first line starts out wrapping
-  s:text <- new [1234567
-89]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1234↩     .
-    .567       .
-    .89        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor on second screen line (after the wrap) and hit ctrl-u
-  assume-console [
-    left-click 2, 1
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .67        .
-    .89        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # cursor moves up to screen line 1
-  memory-should-contain [
-    10 <- 1  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-# screen begins part-way through a wrapping line
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-5 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-345678
-9]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # position the '78' line at the top of the screen
-  assume-console [
-    left-click 4, 1  # on '8'
-    press ctrl-t
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .78        .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 1, 1
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  # make sure we updated top-of-screen correctly
-  screen-should-contain [
-    .          .
-    .8         .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    10 <- 1  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-  # the entire line is deleted, even the part not shown on screen
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .2         .
-    .8         .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-# screen begins part-way through a line wrapping twice (taking up 3 screen lines)
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-6 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-3456789abcd
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # position the 'bcd' line at the top of the screen
-  assume-console [
-    left-click 4, 1  # on '8'
-    press ctrl-t
-    press ctrl-s  # now on 'c'
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .bcd       .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 1, 1
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  # make sure we updated top-of-screen correctly
-  screen-should-contain [
-    .          .
-    .cd        .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    10 <- 1  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-  # the entire line is deleted, even the part not shown on screen
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .2         .
-    .cd        .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-# ctrl-k - delete text from cursor to end of line (but not the newline)
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press ctrl-k
-  assume-console [
-    left-click 1, 1
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to end of line
-  screen-should-contain [
-    .          .
-    .1         .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 9, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    delete-to-end-of-line?:bool <- equal c, 11/ctrl-k
-    break-unless delete-to-end-of-line?
-    <begin-delete-to-end-of-line>
-    deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor
-    <end-delete-to-end-of-line>
-    # checks if we can do a minimal render and if we can it will do a minimal render
-    go-render?:bool <- minimal-render-for-ctrl-k screen, editor, deleted-cells
-    return
-  }
-]
-
-def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  # if we deleted nothing, there's nothing to render
-  return-unless deleted-cells, false/dont-render
-  # if the line used to wrap before, give up and render the whole screen
-  curr-column:num <- get *editor, cursor-column:offset
-  num-deleted-cells:num <- length deleted-cells
-  old-row-len:num <- add curr-column, num-deleted-cells
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  end:num <- subtract right, left
-  wrap?:bool <- greater-or-equal old-row-len, end
-  return-if wrap?, true/go-render
-  clear-line-until screen, right
-  return false/dont-render
-]
-
-def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [
-  local-scope
-  load-inputs
-  # compute range to delete
-  start:&:duplex-list:char <- get *editor, before-cursor:offset
-  end:&:duplex-list:char <- next start
-  {
-    at-end-of-text?:bool <- equal end, null
-    break-if at-end-of-text?
-    curr:char <- get *end, value:offset
-    at-end-of-line?:bool <- equal curr, 10/newline
-    break-if at-end-of-line?
-    end <- next end
-    loop
-  }
-  # snip it out
-  result <- next start
-  remove-between start, end
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press ctrl-k
-  assume-console [
-    left-click 2, 1
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to end of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .4         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 9, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start at end of line
-  assume-console [
-    left-click 1, 2
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes just last character
-  screen-should-contain [
-    .          .
-    .12        .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 8, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of line
-  assume-console [
-    left-click 1, 3
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes nothing
-  screen-should-contain [
-    .          .
-    .123       .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 7, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start at end of text
-  assume-console [
-    left-click 2, 2
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes just the final character
-  screen-should-contain [
-    .          .
-    .123       .
-    .45        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 8, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of text
-  assume-console [
-    left-click 2, 3
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes nothing
-  screen-should-contain [
-    .          .
-    .123       .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # no prints necessary
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-deletes-to-end-of-wrapped-line-with-ctrl-k [
-  local-scope
-  assume-screen 10/width, 5/height
-  # create an editor with the first line wrapping to a second screen row
-  s:text <- new [1234
-567]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  $clear-trace
-  # delete all of the first wrapped line
-  assume-console [
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows an empty unwrapped first line
-  screen-should-contain [
-    .          .
-    .          .
-    .567       .
-    .┈┈┈┈      .
-    .          .
-  ]
-  # entire screen is refreshed
-  check-trace-count-for-label 16, [print-character]
-]
-
-# scroll down if necessary
-
-scenario editor-can-scroll-down-using-arrow-keys [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with >3 lines
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # position cursor at last line, then try to move further down
-  assume-console [
-    left-click 3, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen slides by one line
-  screen-should-contain [
-    .          .
-    .b         .
-    .c         .
-    .d         .
-  ]
-]
-
-after <scroll-down> [
-  trace 10, [app], [scroll down]
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max:num <- subtract right, left
-  old-top:&:duplex-list:char <- copy top-of-screen
-  top-of-screen <- before-start-of-next-line top-of-screen, max
-  *editor <- put *editor, top-of-screen:offset, top-of-screen
-  no-movement?:bool <- equal old-top, top-of-screen
-  return-if no-movement?, false/don't-render
-]
-
-after <scroll-down2> [
-  trace 10, [app], [scroll down]
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max:num <- subtract right, left
-  old-top:&:duplex-list:char <- copy top-of-screen
-  top-of-screen <- before-start-of-next-line top-of-screen, max
-  *editor <- put *editor, top-of-screen:offset, top-of-screen
-  no-movement?:bool <- equal old-top, top-of-screen
-  return-if no-movement?
-]
-
-# Takes a pointer into the doubly-linked list, scans ahead at most 'max'
-# positions until the next newline.
-# Returns original if no next newline.
-# Beware: never return null pointer.
-def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [
-  local-scope
-  load-inputs
-  count:num <- copy 0
-  curr:&:duplex-list:char <- copy original
-  # skip the initial newline if it exists
-  {
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-unless at-newline?
-    curr <- next curr
-    count <- add count, 1
-  }
-  {
-    return-unless curr, original
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    curr <- next curr
-    count <- add count, 1
-    loop
-  }
-  return-unless curr, original
-  return curr
-]
-
-scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with a long, wrapped line and more than a screen of
-  # other lines
-  s:text <- new [abcdef
-g
-h
-i]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .g         .
-  ]
-  # position cursor at last line, then try to move further down
-  assume-console [
-    left-click 3, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .ef        .
-    .g         .
-    .h         .
-  ]
-]
-
-scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # editor starts with a long line wrapping twice
-  s:text <- new [abcdefghij
-k
-l
-m]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  # position cursor at last line, then try to move further down
-  assume-console [
-    left-click 3, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line containing a wrap icon
-  screen-should-contain [
-    .          .
-    .efgh↩     .
-    .ij        .
-    .k         .
-  ]
-  # scroll down again
-  assume-console [
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .ij        .
-    .k         .
-    .l         .
-  ]
-]
-
-scenario editor-scrolls-down-when-line-wraps [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 5/width, 4/height
-  # editor contains a long line in the third line
-  s:text <- new [a
-b
-cdef]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  # position cursor at end, type a character
-  assume-console [
-    left-click 3, 4
-    type [g]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .cdef↩.
-    .g    .
-  ]
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-]
-
-scenario editor-stops-scrolling-once-bottom-is-visible [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with 2 lines
-  s:text <- new [a
-b]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  # position cursor at last line, then try to move further down
-  assume-console [
-    left-click 3, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # no change since the bottom border was already visible
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-scrolls-down-on-newline [
-  local-scope
-  assume-screen 5/width, 4/height
-  # position cursor after last line and type newline
-  s:text <- new [a
-b
-c]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  assume-console [
-    left-click 3, 4
-    type [
-]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .c    .
-    .     .
-  ]
-  memory-should-contain [
-    3 <- 3
-    4 <- 0
-  ]
-]
-
-scenario editor-scrolls-down-on-right-arrow [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 5/width, 4/height
-  # editor contains a wrapped line
-  s:text <- new [a
-b
-cdefgh]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  # position cursor at end of screen and try to move right
-  assume-console [
-    left-click 3, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .cdef↩.
-    .gh   .
-  ]
-  memory-should-contain [
-    3 <- 3
-    4 <- 0
-  ]
-]
-
-scenario editor-scrolls-down-on-right-arrow-2 [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 5/width, 4/height
-  # editor contains more lines than can fit on screen
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  # position cursor at end of screen and try to move right
-  assume-console [
-    left-click 3, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .c    .
-    .d    .
-  ]
-  memory-should-contain [
-    3 <- 3
-    4 <- 0
-  ]
-]
-
-scenario editor-scrolls-at-end-on-down-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-de]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # try to move down past end of text
-  assume-console [
-    left-click 2, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # no change
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-]
-
-scenario editor-combines-page-and-line-scroll [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with a few pages of lines
-  s:text <- new [a
-b
-c
-d
-e
-f
-g]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # scroll down one page and one line
-  assume-console [
-    press page-down
-    left-click 3, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen scrolls down 3 lines
-  screen-should-contain [
-    .          .
-    .d         .
-    .e         .
-    .f         .
-  ]
-]
-
-# scroll up if necessary
-
-scenario editor-can-scroll-up-using-arrow-keys [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with >3 lines
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # position cursor at top of second page, then try to move up
-  assume-console [
-    press page-down
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen slides by one line
-  screen-should-contain [
-    .          .
-    .b         .
-    .c         .
-    .d         .
-  ]
-]
-
-after <scroll-up> [
-  trace 10, [app], [scroll up]
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  old-top:&:duplex-list:char <- copy top-of-screen
-  top-of-screen <- before-previous-screen-line top-of-screen, editor
-  *editor <- put *editor, top-of-screen:offset, top-of-screen
-  no-movement?:bool <- equal old-top, top-of-screen
-  return-if no-movement?, false/don't-render
-]
-
-scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with a long, wrapped line and more than a screen of
-  # other lines
-  s:text <- new [abcdef
-g
-h
-i]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .g         .
-  ]
-  # position cursor at top of second page, just below wrapped line
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .g         .
-    .h         .
-    .i         .
-  ]
-  # now move up one line
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .ef        .
-    .g         .
-    .h         .
-  ]
-]
-
-scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [
-  local-scope
-  # screen has 1 line for menu + 4 lines
-  assume-screen 10/width, 5/height
-  # editor starts with a long line wrapping twice, occupying 3 of the 4 lines
-  s:text <- new [abcdefghij
-k
-l
-m]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # position cursor at top of second page
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .k         .
-    .l         .
-    .m         .
-    .┈┈┈┈┈     .
-  ]
-  # move up one line
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .ij        .
-    .k         .
-    .l         .
-    .m         .
-  ]
-  # move up a second line
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .efgh↩     .
-    .ij        .
-    .k         .
-    .l         .
-  ]
-  # move up a third line
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .efgh↩     .
-    .ij        .
-    .k         .
-  ]
-]
-
-# same as editor-scrolls-up-past-wrapped-line-using-arrow-keys but length
-# slightly off, just to prevent over-training
-scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with a long, wrapped line and more than a screen of
-  # other lines
-  s:text <- new [abcdef
-g
-h
-i]
-  e:&:editor <- new-editor s, 0/left, 6/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcde↩    .
-    .f         .
-    .g         .
-  ]
-  # position cursor at top of second page, just below wrapped line
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .g         .
-    .h         .
-    .i         .
-  ]
-  # now move up one line
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows partial wrapped line
-  screen-should-contain [
-    .          .
-    .f         .
-    .g         .
-    .h         .
-  ]
-]
-
-# check empty lines
-scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [
-  local-scope
-  assume-screen 10/width, 4/height
-  # initialize editor with some lines around an empty line
-  s:text <- new [a
-b
-
-c
-d
-e]
-  e:&:editor <- new-editor s, 0/left, 6/right
-  editor-render screen, e
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .          .
-    .c         .
-    .d         .
-  ]
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .d         .
-    .e         .
-    .┈┈┈┈┈┈    .
-  ]
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .          .
-    .c         .
-    .d         .
-  ]
-]
-
-scenario editor-scrolls-up-on-left-arrow [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 5/width, 4/height
-  # editor contains >3 lines
-  s:text <- new [a
-b
-c
-d
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # position cursor at top of second page
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .     .
-    .c    .
-    .d    .
-    .e    .
-  ]
-  # now try to move left
-  assume-console [
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .c    .
-    .d    .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-]
-
-scenario editor-can-scroll-up-to-start-of-file [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with >3 lines
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # position cursor at top of second page, then try to move up to start of
-  # text
-  assume-console [
-    press page-down
-    press up-arrow
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen slides by one line
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # try to move up again
-  assume-console [
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen remains unchanged
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-]
-
-# ctrl-f/page-down - render next page if it exists
-
-scenario editor-can-scroll [
-  local-scope
-  assume-screen 10/width, 4/height
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows next page
-  screen-should-contain [
-    .          .
-    .c         .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-after <handle-special-character> [
-  {
-    page-down?:bool <- equal c, 6/ctrl-f
-    break-unless page-down?
-    old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-    <begin-move-cursor>
-    page-down editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-    movement?:bool <- not-equal top-of-screen, old-top
-    return movement?/go-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    page-down?:bool <- equal k, 65518/page-down
-    break-unless page-down?
-    old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-    <begin-move-cursor>
-    page-down editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-    movement?:bool <- not-equal top-of-screen, old-top
-    return movement?/go-render
-  }
-]
-
-# page-down skips entire wrapped lines, so it can't scroll past lines
-# taking up the entire screen
-def page-down editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  # if editor contents don't overflow screen, do nothing
-  bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset
-  return-unless bottom-of-screen
-  # if not, position cursor at final character
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  before-cursor:&:duplex-list:char <- prev bottom-of-screen
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  # keep one line in common with previous page
-  {
-    last:char <- get *before-cursor, value:offset
-    newline?:bool <- equal last, 10/newline
-    break-unless newline?:bool
-    before-cursor <- prev before-cursor
-    *editor <- put *editor, before-cursor:offset, before-cursor
-  }
-  # move cursor and top-of-screen to start of that line
-  move-to-start-of-line editor
-  before-cursor <- get *editor, before-cursor:offset
-  *editor <- put *editor, top-of-screen:offset, before-cursor
-]
-
-# jump to previous newline
-def move-to-start-of-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  # update cursor column
-  left:num <- get *editor, left:offset
-  cursor-column:num <- copy left
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  # update before-cursor
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  init:&:duplex-list:char <- get *editor, data:offset
-  # while not at start of line, move
-  {
-    at-start-of-text?:bool <- equal before-cursor, init
-    break-if at-start-of-text?
-    prev:char <- get *before-cursor, value:offset
-    at-start-of-line?:bool <- equal prev, 10/newline
-    break-if at-start-of-line?
-    before-cursor <- prev before-cursor
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    assert before-cursor, [move-to-start-of-line tried to move before start of text]
-    loop
-  }
-]
-
-scenario editor-does-not-scroll-past-end [
-  local-scope
-  assume-screen 10/width, 4/height
-  s:text <- new [a
-b]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen remains unmodified
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-starts-next-page-at-start-of-wrapped-line [
-  local-scope
-  # screen has 1 line for menu + 3 lines for text
-  assume-screen 10/width, 4/height
-  # editor contains a long last line
-  s:text <- new [a
-b
-cdefgh]
-  # editor screen triggers wrap of last line
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  # some part of last line is not displayed
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .cde↩      .
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows entire wrapped line
-  screen-should-contain [
-    .          .
-    .cde↩      .
-    .fgh       .
-    .┈┈┈┈      .
-  ]
-]
-
-scenario editor-starts-next-page-at-start-of-wrapped-line-2 [
-  local-scope
-  # screen has 1 line for menu + 3 lines for text
-  assume-screen 10/width, 4/height
-  # editor contains a very long line that occupies last two lines of screen
-  # and still has something left over
-  s:text <- new [a
-bcdefgh]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  # some part of last line is not displayed
-  screen-should-contain [
-    .          .
-    .a         .
-    .bcd↩      .
-    .efg↩      .
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows entire wrapped line
-  screen-should-contain [
-    .          .
-    .bcd↩      .
-    .efg↩      .
-    .h         .
-  ]
-]
-
-# ctrl-b/page-up - render previous page if it exists
-
-scenario editor-can-scroll-up [
-  local-scope
-  assume-screen 10/width, 4/height
-  s:text <- new [a
-b
-c
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows next page
-  screen-should-contain [
-    .          .
-    .c         .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  # scroll back up
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows original page again
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-]
-
-after <handle-special-character> [
-  {
-    page-up?:bool <- equal c, 2/ctrl-b
-    break-unless page-up?
-    old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-    <begin-move-cursor>
-    editor <- page-up editor, screen-height
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-    movement?:bool <- not-equal top-of-screen, old-top
-    return movement?/go-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    page-up?:bool <- equal k, 65519/page-up
-    break-unless page-up?
-    old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-    <begin-move-cursor>
-    editor <- page-up editor, screen-height
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-    movement?:bool <- not-equal top-of-screen, old-top
-    # don't bother re-rendering if nothing changed. todo: test this
-    return movement?/go-render
-  }
-]
-
-def page-up editor:&:editor, screen-height:num -> editor:&:editor [
-  local-scope
-  load-inputs
-  max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line
-  count:num <- copy 0
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  {
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    prev:&:duplex-list:char <- before-previous-screen-line top-of-screen, editor
-    break-unless prev
-    top-of-screen <- copy prev
-    *editor <- put *editor, top-of-screen:offset, top-of-screen
-    count <- add count, 1
-    loop
-  }
-]
-
-scenario editor-can-scroll-up-multiple-pages [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 10/width, 4/height
-  # initialize editor with 8 lines
-  s:text <- new [a
-b
-c
-d
-e
-f
-g
-h]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-  # scroll down two pages
-  assume-console [
-    press page-down
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows third page
-  screen-should-contain [
-    .          .
-    .e         .
-    .f         .
-    .g         .
-  ]
-  # scroll up
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows second page
-  screen-should-contain [
-    .          .
-    .c         .
-    .d         .
-    .e         .
-  ]
-  # scroll up again
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows original page again
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-  ]
-]
-
-scenario editor-can-scroll-up-wrapped-lines [
-  local-scope
-  # screen has 1 line for menu + 5 lines for text
-  assume-screen 10/width, 6/height
-  # editor contains a long line in the first page
-  s:text <- new [a
-b
-cdefgh
-i
-j
-k
-l
-m
-n
-o]
-  # editor screen triggers wrap of last line
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  # some part of last line is not displayed
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .cde↩      .
-    .fgh       .
-    .i         .
-  ]
-  # scroll down a page and a line
-  assume-console [
-    press page-down
-    left-click 5, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows entire wrapped line
-  screen-should-contain [
-    .          .
-    .j         .
-    .k         .
-    .l         .
-    .m         .
-    .n         .
-  ]
-  # now scroll up one page
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen resets
-  screen-should-contain [
-    .          .
-    .b         .
-    .cde↩      .
-    .fgh       .
-    .i         .
-    .j         .
-  ]
-]
-
-scenario editor-can-scroll-up-wrapped-lines-2 [
-  local-scope
-  # screen has 1 line for menu + 3 lines for text
-  assume-screen 10/width, 4/height
-  # editor contains a very long line that occupies last two lines of screen
-  # and still has something left over
-  s:text <- new [a
-bcdefgh]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  # some part of last line is not displayed
-  screen-should-contain [
-    .          .
-    .a         .
-    .bcd↩      .
-    .efg↩      .
-  ]
-  # scroll down
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows entire wrapped line
-  screen-should-contain [
-    .          .
-    .bcd↩      .
-    .efg↩      .
-    .h         .
-  ]
-  # scroll back up
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen resets
-  screen-should-contain [
-    .          .
-    .a         .
-    .bcd↩      .
-    .efg↩      .
-  ]
-]
-
-scenario editor-can-scroll-up-past-nonempty-lines [
-  local-scope
-  assume-screen 10/width, 4/height
-  # text with empty line in second screen
-  s:text <- new [axx
-bxx
-cxx
-dxx
-exx
-fxx
-gxx
-hxx
-]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .axx       .
-    .bxx       .
-    .cxx       .
-  ]
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .cxx       .
-    .dxx       .
-    .exx       .
-  ]
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .exx       .
-    .fxx       .
-    .gxx       .
-  ]
-  # scroll back up past empty line
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .cxx       .
-    .dxx       .
-    .exx       .
-  ]
-]
-
-scenario editor-can-scroll-up-past-empty-lines [
-  local-scope
-  assume-screen 10/width, 4/height
-  # text with empty line in second screen
-  s:text <- new [axy
-bxy
-cxy
-
-dxy
-exy
-fxy
-gxy
-]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .axy       .
-    .bxy       .
-    .cxy       .
-  ]
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .cxy       .
-    .          .
-    .dxy       .
-  ]
-  assume-console [
-    press page-down
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .dxy       .
-    .exy       .
-    .fxy       .
-  ]
-  # scroll back up past empty line
-  assume-console [
-    press page-up
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .cxy       .
-    .          .
-    .dxy       .
-  ]
-]
-
-# ctrl-s - scroll up by one line
-# todo: scenarios
-
-after <handle-special-character> [
-  {
-    scroll-up?:bool <- equal c, 19/ctrl-s
-    break-unless scroll-up?
-    <begin-move-cursor>
-    go-render?:bool, editor <- line-up editor, screen-height
-    undo-coalesce-tag:num <- copy 5/line-up
-    <end-move-cursor>
-    return go-render?
-  }
-]
-
-def line-up editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max:num <- subtract right, left
-  old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-  new-top:&:duplex-list:char <- before-start-of-next-line old-top, max
-  movement?:bool <- not-equal old-top, new-top
-  {
-    break-unless movement?
-    *editor <- put *editor, top-of-screen:offset, new-top
-  }
-  return movement?
-]
-
-# ctrl-x - scroll down by one line
-# todo: scenarios
-
-after <handle-special-character> [
-  {
-    scroll-down?:bool <- equal c, 24/ctrl-x
-    break-unless scroll-down?
-    <begin-move-cursor>
-    go-render?:bool, editor <- line-down editor, screen-height
-    undo-coalesce-tag:num <- copy 6/line-down
-    <end-move-cursor>
-    return go-render?
-  }
-]
-
-def line-down editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-  new-top:&:duplex-list:char <- before-previous-screen-line old-top, editor
-  movement?:bool <- not-equal old-top, new-top
-  {
-    break-unless movement?
-    *editor <- put *editor, top-of-screen:offset, new-top
-  }
-  return movement?
-]
-
-# ctrl-t - move current line to top of screen
-# todo: scenarios
-
-after <handle-special-character> [
-  {
-    scroll-down?:bool <- equal c, 20/ctrl-t
-    break-unless scroll-down?
-    <begin-move-cursor>
-    old-top:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    cursor <- next cursor
-    new-top:&:duplex-list:char <- before-previous-screen-line cursor, editor
-    *editor <- put *editor, top-of-screen:offset, new-top
-    *editor <- put *editor, cursor-row:offset, 1
-    go-render?:bool <- not-equal new-top, old-top
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return go-render?
-  }
-]
-
-# ctrl-/ - comment/uncomment current line
-
-after <handle-special-character> [
-  {
-    comment-toggle?:bool <- equal c, 31/ctrl-slash
-    break-unless comment-toggle?
-    cursor-column:num <- get *editor, cursor-column:offset
-    data:&:duplex-list:char <- get *editor, data:offset
-    <begin-insert-character>
-    before-line-start:&:duplex-list:char <- before-start-of-screen-line editor
-    line-start:&:duplex-list:char <- next before-line-start
-    commented-out?:bool <- match line-start, [#? ]  # comment prefix
-    {
-      break-unless commented-out?
-      # uncomment
-      data <- remove line-start, 3/length-comment-prefix, data
-      cursor-column <- subtract cursor-column, 3/length-comment-prefix
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      go-render? <- render-line-from-start screen, editor, 3/size-of-comment-leader
-    }
-    {
-      break-if commented-out?
-      # comment
-      insert before-line-start, [#? ]
-      cursor-column <- add cursor-column, 3/length-comment-prefix
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      go-render? <- render-line-from-start screen, editor, 0
-    }
-    <end-insert-character>
-    return
-  }
-]
-
-# Render just from the start of the current line, and only if it wasn't
-# wrapping before (include margin) and isn't wrapping now. Otherwise just tell
-# the caller to go-render? the entire screen.
-def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  before-line-start:&:duplex-list:char <- before-start-of-screen-line editor
-  line-start:&:duplex-list:char <- next before-line-start
-  color:num <- copy 7/white
-  left:num <- get *editor, left:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  screen <- move-cursor screen, cursor-row, left
-  right:num <- get *editor, right:offset
-  end:num <- subtract right, right-margin
-  i:num <- copy 0
-  curr:&:duplex-list:char <- copy line-start
-  {
-    render-all?:bool <- greater-or-equal i, end
-    return-if render-all?, true/go-render
-    break-unless curr
-    c:char <- get *curr, value:offset
-    newline?:bool <- equal c, 10/newline
-    break-if newline?
-    color <- get-color color, c
-    print screen, c, color
-    curr <- next curr
-    i <- add i, 1
-    loop
-  }
-  clear-line-until screen, right
-  return false/dont-render
-]
-
-def before-start-of-screen-line editor:&:editor -> result:&:duplex-list:char [
-  local-scope
-  load-inputs
-  cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  {
-    next:&:duplex-list:char <- next cursor
-    break-unless next
-    cursor <- copy next
-  }
-  result <- before-previous-screen-line cursor, editor
-]
-
-scenario editor-comments-empty-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#?        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 5, [print-character]
-]
-
-scenario editor-comments-at-start-of-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#? ab     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-comments-at-end-of-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#? ab     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 5
-  ]
-  check-trace-count-for-label 10, [print-character]
-  # toggle to uncomment
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .ab        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-comments-almost-wrapping-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor starts out with a non-wrapping line
-  e:&:editor <- new-editor [abcd], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # on commenting the line is now wrapped
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .#? a↩     .
-    .bcd       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-scenario editor-uncomments-just-wrapping-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor starts out with a comment that wraps the line
-  e:&:editor <- new-editor [#? ab], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .#? a↩     .
-    .b         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # on uncommenting the line is no longer wrapped
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .ab        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
diff --git a/archive/2.vm/edit/004-programming-environment.mu b/archive/2.vm/edit/004-programming-environment.mu
deleted file mode 100644
index dec8a2d5..00000000
--- a/archive/2.vm/edit/004-programming-environment.mu
+++ /dev/null
@@ -1,549 +0,0 @@
-## putting the environment together out of editors
-#
-# Consists of one editor on the left for recipes and one on the right for the
-# sandbox.
-
-def! main [
-  local-scope
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  env:&:environment <- new-programming-environment null/filesystem, null/screen
-  render-all null/screen, env, render
-  event-loop null/screen, null/console, env, null/filesystem
-]
-
-container environment [
-  recipes:&:editor
-  current-sandbox:&:editor
-  sandbox-in-focus?:bool  # false => cursor in recipes; true => cursor in current-sandbox
-]
-
-def new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text -> result:&:environment [
-  local-scope
-  load-inputs
-  width:num <- screen-width screen
-  result <- new environment:type
-  # recipe editor on the left
-  initial-recipe-contents:text <- slurp resources, [lesson/recipes.mu]  # ignore errors
-  divider:num, _ <- divide-with-remainder width, 2
-  recipes:&:editor <- new-editor initial-recipe-contents, 0/left, divider/right
-  # sandbox editor on the right
-  sandbox-left:num <- add divider, 1
-  current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, sandbox-left, width/right
-  *result <- put *result, recipes:offset, recipes
-  *result <- put *result, current-sandbox:offset, current-sandbox
-  *result <- put *result, sandbox-in-focus?:offset, false
-  <programming-environment-initialization>
-]
-
-def event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources -> screen:&:screen, console:&:console, env:&:environment, resources:&:resources [
-  local-scope
-  load-inputs
-  recipes:&:editor <- get *env, recipes:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset
-  # if we fall behind we'll stop updating the screen, but then we have to
-  # render the entire screen when we catch up.
-  # todo: test this
-  render-recipes-on-no-more-events?:bool <- copy false
-  render-sandboxes-on-no-more-events?:bool <- copy false
-  {
-    # looping over each (keyboard or touch) event as it occurs
-    +next-event
-    e:event, found?:bool, quit?:bool, console <- read-event console
-    loop-unless found?
-    break-if quit?  # only in tests
-    trace 10, [app], [next-event]
-    <handle-event>
-    # check for global events that will trigger regardless of which editor has focus
-    {
-      k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant
-      break-unless is-keycode?
-      <global-keypress>
-    }
-    {
-      c:char, is-unicode?:bool <- maybe-convert e:event, text:variant
-      break-unless is-unicode?
-      <global-type>
-    }
-    # 'touch' event - send to both sides, see what picks it up
-    {
-      t:touch-event, is-touch?:bool <- maybe-convert e:event, touch:variant
-      break-unless is-touch?
-      # ignore all but 'left-click' events for now
-      # todo: test this
-      touch-type:num <- get t, type:offset
-      is-left-click?:bool <- equal touch-type, 65513/mouse-left
-      loop-unless is-left-click?, +next-event
-      click-row:num <- get t, row:offset
-      click-column:num <- get t, column:offset
-      # later exceptions for non-editor touches will go here
-      <global-touch>
-      # send to both editors
-      _ <- move-cursor recipes, screen, t
-      sandbox-in-focus?:bool <- move-cursor current-sandbox, screen, t
-      *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus?
-      screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-      loop +next-event
-    }
-    # 'resize' event - redraw editor
-    # todo: test this after supporting resize in assume-console
-    {
-      r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant
-      break-unless is-resize?
-      env, screen <- resize screen, env
-      screen <- render-all screen, env, render-without-moving-cursor
-      loop +next-event
-    }
-    # if it's not global and not a touch event, send to appropriate editor
-    {
-      sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset
-      {
-        break-if sandbox-in-focus?
-        render?:bool <- handle-keyboard-event screen, recipes, e:event
-        render-recipes-on-no-more-events? <- or render?, render-recipes-on-no-more-events?
-      }
-      {
-        break-unless sandbox-in-focus?
-        render?:bool <- handle-keyboard-event screen, current-sandbox, e:event
-        render-sandboxes-on-no-more-events? <- or render?, render-sandboxes-on-no-more-events?
-      }
-      more-events?:bool <- has-more-events? console
-      {
-        break-if more-events?
-        {
-          break-unless render-recipes-on-no-more-events?
-          render-recipes-on-no-more-events? <- copy false
-          screen <- render-recipes screen, env, render
-        }
-        {
-          break-unless render-sandboxes-on-no-more-events?
-          render-sandboxes-on-no-more-events? <- copy false
-          screen <- render-sandbox-side screen, env, render
-        }
-      }
-      screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    }
-    loop
-  }
-]
-
-def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [
-  local-scope
-  load-inputs
-  clear-screen screen  # update screen dimensions
-  width:num <- screen-width screen
-  divider:num, _ <- divide-with-remainder width, 2
-  # update recipe editor
-  recipes:&:editor <- get *env, recipes:offset
-  right:num <- subtract divider, 1
-  *recipes <- put *recipes, right:offset, right
-  # reset cursor (later we'll try to preserve its position)
-  *recipes <- put *recipes, cursor-row:offset, 1
-  *recipes <- put *recipes, cursor-column:offset, 0
-  # update sandbox editor
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  left:num <- add divider, 1
-  *current-sandbox <- put *current-sandbox, left:offset, left
-  right:num <- subtract width, 1
-  *current-sandbox <- put *current-sandbox, right:offset, right
-  # reset cursor (later we'll try to preserve its position)
-  *current-sandbox <- put *current-sandbox, cursor-row:offset, 1
-  *current-sandbox <- put *current-sandbox, cursor-column:offset, left
-]
-
-# Variant of 'render' that updates cursor-row and cursor-column based on
-# before-cursor (rather than the other way around). If before-cursor moves
-# off-screen, it resets cursor-row and cursor-column.
-def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, 1/top, 0/left
-  left:num <- get *editor, left:offset
-  screen-height:num <- screen-height screen
-  right:num <- get *editor, right:offset
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  color:num <- copy 7/white
-  row:num <- copy 1/top
-  column:num <- copy left
-  # save before-cursor
-  old-before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  # initialze cursor-row/cursor-column/before-cursor to the top of the screen
-  # by default
-  *editor <- put *editor, cursor-row:offset, row
-  *editor <- put *editor, cursor-column:offset, column
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  *editor <- put *editor, before-cursor:offset, top-of-screen
-  screen <- move-cursor screen, row, column
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # if we find old-before-cursor still on the new resized screen, update
-    # editor.cursor-row and editor.cursor-column based on
-    # old-before-cursor
-    {
-      at-cursor?:bool <- equal old-before-cursor, prev
-      break-unless at-cursor?
-      *editor <- put *editor, cursor-row:offset, row
-      *editor <- put *editor, cursor-column:offset, column
-      *editor <- put *editor, before-cursor:offset, old-before-cursor
-    }
-    c:char <- get *curr, value:offset
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      clear-line-until screen, right
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment curr
-      loop +next-character
-    }
-    print screen, c, color
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # save first character off-screen
-  *editor <- put *editor, bottom-of-screen:offset, curr
-  *editor <- put *editor, bottom:offset, row
-  return row, column
-]
-
-scenario point-at-multiple-editors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 30/width, 5/height
-  # initialize both halves of screen
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |abc|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [def]  # contents of sandbox editor
-  # focus on both sides
-  assume-console [
-    left-click 1, 1
-    left-click 1, 17
-  ]
-  # check cursor column in each
-  run [
-    event-loop screen, console, env, resources
-    recipes:&:editor <- get *env, recipes:offset
-    5:num/raw <- get *recipes, cursor-column:offset
-    sandbox:&:editor <- get *env, current-sandbox:offset
-    7:num/raw <- get *sandbox, cursor-column:offset
-  ]
-  memory-should-contain [
-    5 <- 1
-    7 <- 17
-  ]
-]
-
-scenario edit-multiple-editors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 30/width, 5/height
-  # initialize both halves of screen
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |abc|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [def]  # contents of sandbox
-  render-all screen, env, render
-  # type one letter in each of them
-  assume-console [
-    left-click 1, 1
-    type [0]
-    left-click 1, 17
-    type [1]
-  ]
-  run [
-    event-loop screen, console, env, resources
-    recipes:&:editor <- get *env, recipes:offset
-    5:num/raw <- get *recipes, cursor-column:offset
-    sandbox:&:editor <- get *env, current-sandbox:offset
-    7:num/raw <- get *sandbox, cursor-column:offset
-  ]
-  screen-should-contain [
-    .           run (F4)           .  # this line has a different background, but we don't test that yet
-    .a0bc           ┊d1ef          .
-    .               ┊──────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊              .
-    .               ┊              .
-  ]
-  memory-should-contain [
-    5 <- 2  # cursor column of recipe editor
-    7 <- 18  # cursor column of sandbox editor
-  ]
-  # show the cursor at the right window
-  run [
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  screen-should-contain [
-    .           run (F4)           .
-    .a0bc           ┊d1␣f          .
-    .               ┊──────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊              .
-    .               ┊              .
-  ]
-]
-
-scenario editor-in-focus-keeps-cursor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 30/width, 5/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |abc|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [def]
-  render-all screen, env, render
-  # initialize programming environment and highlight cursor
-  assume-console []
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # is cursor at the right place?
-  screen-should-contain [
-    .           run (F4)           .
-    .␣bc            ┊def           .
-    .               ┊──────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊              .
-    .               ┊              .
-  ]
-  # now try typing a letter
-  assume-console [
-    type [z]
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # cursor should still be right
-  screen-should-contain [
-    .           run (F4)           .
-    .z␣bc           ┊def           .
-    .               ┊──────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊              .
-    .               ┊              .
-  ]
-]
-
-scenario backspace-in-sandbox-editor-joins-lines [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 30/width, 5/height
-  assume-resources [
-  ]
-  # initialize sandbox side with two lines
-  test-sandbox-editor-contents:text <- new [abc
-def]
-  env:&:environment <- new-programming-environment resources, screen, test-sandbox-editor-contents
-  render-all screen, env, render
-  screen-should-contain [
-    .           run (F4)           .
-    .               ┊abc           .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊def           .
-    .               ┊──────────────.
-    .               ┊              .
-  ]
-  # position cursor at start of second line and hit backspace
-  assume-console [
-    left-click 2, 16
-    press backspace
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # cursor moves to end of old line
-  screen-should-contain [
-    .           run (F4)           .
-    .               ┊abc␣ef        .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊──────────────.
-    .               ┊              .
-  ]
-]
-
-type render-recipe = (recipe (address screen) (address editor) -> number number (address screen) (address editor))
-
-def render-all screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 10, [app], [render all]
-  # top menu
-  trace 11, [app], [render top menu]
-  width:num <- screen-width screen
-  draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey
-  button-start:num <- subtract width, 20
-  button-on-screen?:bool <- greater-or-equal button-start, 0
-  assert button-on-screen?, [screen too narrow for menu]
-  screen <- move-cursor screen, 0/row, button-start
-  print screen, [ run (F4) ], 255/white, 161/reddish
-  # dotted line down the middle
-  trace 11, [app], [render divider]
-  divider:num, _ <- divide-with-remainder width, 2
-  height:num <- screen-height screen
-  draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted
-  #
-  screen <- render-recipes screen, env, render-editor
-  screen <- render-sandbox-side screen, env, render-editor
-  <end-render-components>  # no early returns permitted
-  #
-  recipes:&:editor <- get *env, recipes:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset
-  screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-]
-
-def render-recipes screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 11, [app], [render recipes]
-  old-top-idx:num <- save-top-idx screen
-  recipes:&:editor <- get *env, recipes:offset
-  # render recipes
-  left:num <- get *recipes, left:offset
-  right:num <- get *recipes, right:offset
-  row:num, column:num, screen <- call render-editor, screen, recipes
-  <end-render-recipe-components>
-  # draw dotted line after recipes
-  draw-horizontal screen, row, left, right, 9480/horizontal-dotted
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-  #
-  assert-no-scroll screen, old-top-idx
-]
-
-# replaced in a later layer
-def render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 11, [app], [render sandboxes]
-  old-top-idx:num <- save-top-idx screen
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  left:num <- get *current-sandbox, left:offset
-  right:num <- get *current-sandbox, right:offset
-  row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox
-  # draw solid line after code (you'll see why in later layers)
-  draw-horizontal screen, row, left, right
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-  #
-  assert-no-scroll screen, old-top-idx
-]
-
-def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [
-  local-scope
-  load-inputs
-  <update-cursor-special-cases>
-  {
-    break-if sandbox-in-focus?
-    cursor-row:num <- get *recipes, cursor-row:offset
-    cursor-column:num <- get *recipes, cursor-column:offset
-  }
-  {
-    break-unless sandbox-in-focus?
-    cursor-row:num <- get *current-sandbox, cursor-row:offset
-    cursor-column:num <- get *current-sandbox, cursor-column:offset
-  }
-  screen <- move-cursor screen, cursor-row, cursor-column
-]
-
-# ctrl-n - switch focus
-# todo: test this
-
-after <global-type> [
-  {
-    switch-side?:bool <- equal c, 14/ctrl-n
-    break-unless switch-side?
-    sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset
-    sandbox-in-focus? <- not sandbox-in-focus?
-    *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus?
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-## helpers
-
-def draw-vertical screen:&:screen, col:num, y:num, bottom:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  style:char, style-found?:bool <- next-input
-  {
-    break-if style-found?
-    style <- copy 9474/vertical
-  }
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 245/grey
-  }
-  {
-    continue?:bool <- lesser-than y, bottom
-    break-unless continue?
-    screen <- move-cursor screen, y, col
-    print screen, style, color
-    y <- add y, 1
-    loop
-  }
-]
-
-scenario backspace-over-text [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 15/height
-  # recipes.mu is empty
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, []
-  # run the code in the editors
-  assume-console [
-    type [a]
-    press backspace
-  ]
-  run [
-    event-loop screen, console, env, resources
-    10:num/raw <- get *screen, cursor-row:offset
-    11:num/raw <- get *screen, cursor-column:offset
-  ]
-  memory-should-contain [
-    10 <- 1
-    11 <- 0
-  ]
-]
diff --git a/archive/2.vm/edit/005-sandbox.mu b/archive/2.vm/edit/005-sandbox.mu
deleted file mode 100644
index 96ec804d..00000000
--- a/archive/2.vm/edit/005-sandbox.mu
+++ /dev/null
@@ -1,1193 +0,0 @@
-## running code from the editor and creating sandboxes
-#
-# Running code in the sandbox editor prepends its contents to a list of
-# (non-editable) sandboxes below the editor, showing the result and maybe a
-# few other things (later layers).
-#
-# This layer draws the menubar buttons in non-editable sandboxes but they
-# don't do anything yet. Later layers implement each button.
-
-def! main [
-  local-scope
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  env:&:environment <- new-programming-environment null/filesystem, null/screen
-  env <- restore-sandboxes env, null/filesystem
-  render-all null/screen, env, render
-  event-loop null/screen, null/console, env, null/filesystem
-]
-
-container environment [
-  sandbox:&:sandbox  # list of sandboxes, from top to bottom. TODO: switch to &:list:sandbox
-  render-from:num
-  number-of-sandboxes:num
-]
-
-after <programming-environment-initialization> [
-  *result <- put *result, render-from:offset, -1
-]
-
-container sandbox [
-  data:text
-  response:text
-  # coordinates to track clicks
-  # constraint: will be 0 for sandboxes at positions before env.render-from
-  starting-row-on-screen:num
-  code-ending-row-on-screen:num  # past end of code
-  screen:&:screen  # prints in the sandbox go here
-  next-sandbox:&:sandbox
-]
-
-scenario run-and-show-results [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # recipe editor is empty
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, [divide-with-remainder 11, 3]
-  render-all screen, env, render
-  # run the code in the editors
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints the results
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊divide-with-remainder 11, 3                      .
-    .                                                  ┊3                                                .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  screen-should-contain-in-color 7/white, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   divide-with-remainder 11, 3                      .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-  screen-should-contain-in-color 245/grey, [
-    .                                                                                                    .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-    .                                                  ┊3                                                .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # sandbox menu in reverse video
-  screen-should-contain-in-color 232/black, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   0   edit       copy       to recipe    delete    .
-  ]
-  # run another command
-  assume-console [
-    left-click 1, 80
-    type [add 2, 2]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints both sandboxes
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊divide-with-remainder 11, 3                      .
-    .                                                  ┊3                                                .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-after <global-keypress> [
-  # F4? load all code and run all sandboxes.
-  {
-    do-run?:bool <- equal k, 65532/F4
-    break-unless do-run?
-    screen <- update-status screen, [running...       ], 245/grey
-    <begin-run-sandboxes-on-F4>
-    error?:bool <- run-sandboxes env, resources, screen
-    # we could just render-all, but we do some work to minimize the number of prints to screen
-    <end-run-sandboxes-on-F4>
-    screen <- render-sandbox-side screen, env, render
-    {
-      break-if error?
-      screen <- update-status screen, [                 ], 245/grey
-    }
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [
-  local-scope
-  load-inputs
-  errors-found?:bool <- update-recipes env, resources, screen
-  jump-if errors-found?, +return
-  # check contents of right editor (sandbox)
-  <begin-run-sandboxes>
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  {
-    sandbox-contents:text <- editor-contents current-sandbox
-    break-unless sandbox-contents
-    # if contents exist, first save them
-    # run them and turn them into a new sandbox
-    new-sandbox:&:sandbox <- new sandbox:type
-    *new-sandbox <- put *new-sandbox, data:offset, sandbox-contents
-    # push to head of sandbox list
-    dest:&:sandbox <- get *env, sandbox:offset
-    *new-sandbox <- put *new-sandbox, next-sandbox:offset, dest
-    *env <- put *env, sandbox:offset, new-sandbox
-    # update sandbox count
-    sandbox-count:num <- get *env, number-of-sandboxes:offset
-    sandbox-count <- add sandbox-count, 1
-    *env <- put *env, number-of-sandboxes:offset, sandbox-count
-    # save all sandboxes
-    # needs to be before running them, in case we die when running
-    save-sandboxes env, resources
-    # clear sandbox editor
-    init:&:duplex-list:char <- push 167/§, null
-    *current-sandbox <- put *current-sandbox, data:offset, init
-    *current-sandbox <- put *current-sandbox, top-of-screen:offset, init
-  }
-  # run all sandboxes
-  curr:&:sandbox <- get *env, sandbox:offset
-  idx:num <- copy 0
-  {
-    break-unless curr
-    curr <- update-sandbox curr, env, idx
-    curr <- get *curr, next-sandbox:offset
-    idx <- add idx, 1
-    loop
-  }
-  <end-run-sandboxes>
-  +return
-  {
-    break-if resources  # ignore this in tests
-    $system [./snapshot_lesson]
-  }
-]
-
-# load code from disk
-# replaced in a later layer (whereupon errors-found? will actually be set)
-def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [
-  local-scope
-  load-inputs
-  recipes:&:editor <- get *env, recipes:offset
-  in:text <- editor-contents recipes
-  resources <- dump resources, [lesson/recipes.mu], in
-  reload in
-  errors-found? <- copy false
-]
-
-# replaced in a later layer
-def update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  response:text, _, fake-screen:&:screen <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-]
-
-def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  screen <- move-cursor screen, 0, 2
-  screen <- print screen, msg, color, 238/grey/background
-]
-
-def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [
-  local-scope
-  load-inputs
-  trace 11, [app], [save sandboxes]
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  # first clear previous versions, in case we deleted some sandbox
-  $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
-  curr:&:sandbox <- get *env, sandbox:offset
-  idx:num <- copy 0
-  {
-    break-unless curr
-    resources <- save-sandbox resources, curr, idx
-    idx <- add idx, 1
-    curr <- get *curr, next-sandbox:offset
-    loop
-  }
-]
-
-def save-sandbox resources:&:resources, sandbox:&:sandbox, sandbox-index:num -> resources:&:resources [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  filename:text <- append [lesson/], sandbox-index
-  resources <- dump resources, filename, data
-  <end-save-sandbox>
-]
-
-def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 11, [app], [render sandbox side]
-  old-top-idx:num <- save-top-idx screen
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  row:num, column:num <- copy 1, 0
-  left:num <- get *current-sandbox, left:offset
-  right:num <- get *current-sandbox, right:offset
-  # render sandbox editor
-  render-from:num <- get *env, render-from:offset
-  {
-    render-current-sandbox?:bool <- equal render-from, -1
-    break-unless render-current-sandbox?
-    row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox
-  }
-  # render sandboxes
-  draw-horizontal screen, row, left, right
-  sandbox:&:sandbox <- get *env, sandbox:offset
-  row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from
-  clear-rest-of-screen screen, row, left, right
-  #
-  assert-no-scroll screen, old-top-idx
-]
-
-def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  return-unless sandbox
-  screen-height:num <- screen-height screen
-  hidden?:bool <- lesser-than idx, render-from
-  {
-    break-if hidden?
-    # render sandbox menu
-    row <- add row, 1
-    at-bottom?:bool <- greater-or-equal row, screen-height
-    return-if at-bottom?
-    screen <- move-cursor screen, row, left
-    screen <- render-sandbox-menu screen, idx, left, right
-    # save menu row so we can detect clicks to it later
-    *sandbox <- put *sandbox, starting-row-on-screen:offset, row
-    # render sandbox contents
-    row <- add row, 1
-    screen <- move-cursor screen, row, left
-    sandbox-data:text <- get *sandbox, data:offset
-    row, screen <- render-code screen, sandbox-data, left, right, row
-    *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row
-    # render sandbox warnings, screen or response, in that order
-    sandbox-response:text <- get *sandbox, response:offset
-    <render-sandbox-results>
-    {
-      sandbox-screen:&:screen <- get *sandbox, screen:offset
-      empty-screen?:bool <- fake-screen-is-empty? sandbox-screen
-      break-if empty-screen?
-      row, screen <- render-screen screen, sandbox-screen, left, right, row
-    }
-    {
-      break-unless empty-screen?
-      <render-sandbox-response>
-      row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row
-    }
-    +render-sandbox-end
-    at-bottom?:bool <- greater-or-equal row, screen-height
-    return-if at-bottom?
-    # draw solid line after sandbox
-    draw-horizontal screen, row, left, right
-  }
-  # if hidden, reset row attributes
-  {
-    break-unless hidden?
-    *sandbox <- put *sandbox, starting-row-on-screen:offset, 0
-    *sandbox <- put *sandbox, code-ending-row-on-screen:offset, 0
-    <end-render-sandbox-reset-hidden>
-  }
-  # draw next sandbox
-  next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-  next-idx:num <- add idx, 1
-  row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx
-]
-
-def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  move-cursor-to-column screen, left
-  edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right
-  print screen, sandbox-index, 232/dark-grey, 245/grey
-  start-buttons:num <- subtract edit-button-left, 1
-  clear-line-until screen, start-buttons, 245/grey
-  print screen, [edit], 232/black, 25/background-blue
-  clear-line-until screen, edit-button-right, 25/background-blue
-  print screen, [copy], 232/black, 58/background-green
-  clear-line-until screen, copy-button-right, 58/background-green
-  print screen, [to recipe], 232/black, 94/background-orange
-  clear-line-until screen, recipe-button-right, 94/background-orange
-  print screen, [delete], 232/black, 52/background-red
-  clear-line-until screen, right, 52/background-red
-]
-
-scenario skip-rendering-sandbox-menu-past-bottom-row [
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 6/height
-  # recipe editor is empty
-  assume-resources [
-    [lesson/0] <- [|add 2, 2|]
-    [lesson/1] <- [|add 1, 1|]
-  ]
-  # create two sandboxes such that the top one just barely fills the screen
-  env:&:environment <- new-programming-environment resources, screen, []
-  env <- restore-sandboxes env, resources
-  run [
-    render-all screen, env, render
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊─────────────────────────────────────────────────.
-  ]
-]
-
-# divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons
-# delete-button-right == right
-# all left/right pairs are inclusive
-def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num [
-  local-scope
-  load-inputs
-  start-buttons:num <- add left, 4/space-for-sandbox-index
-  buttons-space:num <- subtract right, start-buttons
-  button-width:num <- divide-with-remainder buttons-space, 4  # integer division
-  buttons-wide-enough?:bool <- greater-or-equal button-width, 10
-  assert buttons-wide-enough?, [sandbox must be at least 40 or so characters wide]
-  edit-button-left:num <- copy start-buttons
-  copy-button-left:num <- add start-buttons, button-width
-  edit-button-right:num <- subtract copy-button-left, 1
-  recipe-button-left:num <- add copy-button-left, button-width
-  copy-button-right:num <- subtract recipe-button-left, 1
-  delete-button-left:num <- subtract right, button-width, -2  # because 'to recipe' is wider than 'delete'
-  recipe-button-right:num <- subtract delete-button-left, 1
-]
-
-# print a text 's' to 'editor' in 'color' starting at 'row'
-# clear rest of last line, move cursor to next line
-# like 'render-code' but without syntax-based colorization
-def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless s
-  column:num <- copy left
-  screen <- move-cursor screen, row, column
-  screen-height:num <- screen-height screen
-  i:num <- copy 0
-  len:num <- length *s
-  {
-    +next-character
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    c:char <- index *s, i
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      {
-        done?:bool <- greater-than column, right
-        break-if done?
-        space:char <- copy 32/space
-        print screen, space
-        column <- add column, 1
-        loop
-      }
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      i <- add i, 1
-      loop +next-character
-    }
-    {
-      # at right? wrap.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment i
-      loop +next-character
-    }
-    i <- add i, 1
-    print screen, c, color
-    column <- add column, 1
-    loop
-  }
-  was-at-left?:bool <- equal column, left
-  clear-line-until screen, right
-  {
-    break-if was-at-left?
-    row <- add row, 1
-  }
-  move-cursor screen, row, left
-]
-
-scenario render-text-wraps-barely-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  run [
-    render-text screen, [abcde], 0/left, 4/right, 7/white, 1/row
-  ]
-  screen-should-contain [
-    .     .
-    .abcd↩.
-    .e    .
-    .     .
-  ]
-]
-
-# assumes programming environment has no sandboxes; restores them from previous session
-def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [
-  local-scope
-  load-inputs
-  # read all scenarios, pushing them to end of a list of scenarios
-  idx:num <- copy 0
-  curr:&:sandbox <- copy null
-  prev:&:sandbox <- copy null
-  {
-    filename:text <- append [lesson/], idx
-    contents:text <- slurp resources, filename
-    break-unless contents  # stop at first error; assuming file didn't exist
-                           # todo: handle empty sandbox
-    # create new sandbox for file
-    curr <- new sandbox:type
-    *curr <- put *curr, data:offset, contents
-    <end-restore-sandbox>
-    {
-      break-if idx
-      *env <- put *env, sandbox:offset, curr
-    }
-    {
-      break-unless idx
-      *prev <- put *prev, next-sandbox:offset, curr
-    }
-    idx <- add idx, 1
-    prev <- copy curr
-    loop
-  }
-  # update sandbox count
-  *env <- put *env, number-of-sandboxes:offset, idx
-]
-
-# print the fake sandbox screen to 'screen' with appropriate delimiters
-# leave cursor at start of next line
-def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless sandbox-screen
-  # print 'screen:'
-  row <- render-text screen, [screen:], left, right, 245/grey, row
-  screen <- move-cursor screen, row, left
-  # start printing sandbox-screen
-  column:num <- copy left
-  s-width:num <- screen-width sandbox-screen
-  s-height:num <- screen-height sandbox-screen
-  buf:&:@:screen-cell <- get *sandbox-screen, data:offset
-  stop-printing:num <- add left, s-width, 3
-  max-column:num <- min stop-printing, right
-  i:num <- copy 0
-  len:num <- length *buf
-  screen-height:num <- screen-height screen
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    column <- copy left
-    screen <- move-cursor screen, row, column
-    # initial leader for each row: two spaces and a '.'
-    space:char <- copy 32/space
-    print screen, space, 245/grey
-    print screen, space, 245/grey
-    full-stop:char <- copy 46/period
-    print screen, full-stop, 245/grey
-    column <- add left, 3
-    {
-      # print row
-      row-done?:bool <- greater-or-equal column, max-column
-      break-if row-done?
-      curr:screen-cell <- index *buf, i
-      c:char <- get curr, contents:offset
-      color:num <- get curr, color:offset
-      {
-        # damp whites down to grey
-        white?:bool <- equal color, 7/white
-        break-unless white?
-        color <- copy 245/grey
-      }
-      print screen, c, color
-      column <- add column, 1
-      i <- add i, 1
-      loop
-    }
-    # print final '.'
-    print screen, full-stop, 245/grey
-    column <- add column, 1
-    {
-      # clear rest of current line
-      line-done?:bool <- greater-than column, right
-      break-if line-done?
-      print screen, space
-      column <- add column, 1
-      loop
-    }
-    row <- add row, 1
-    loop
-  }
-]
-
-scenario run-updates-results [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 12/height
-  # define a recipe (no indent for the 'add' line below so column numbers are more obvious)
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      ||
-      |recipe foo [|
-      |  local-scope|
-      |  z:num <- add 2, 2|
-      |  reply z|
-      |]|
-    ]
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, [foo]  # contents of sandbox editor
-  render-all screen, env, render
-  $clear-trace
-  # run the code in the editors
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .recipe foo [                                      ┊─────────────────────────────────────────────────.
-    .  local-scope                                     ┊0   edit       copy       to recipe    delete    .
-    .  z:num <- add 2, 2                               ┊foo                                              .
-    .  reply z                                         ┊4                                                .
-    .]                                                 ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # the new sandbox should be saved to disk
-  trace-should-contain [
-    app: save sandboxes
-  ]
-  # no need to update editor
-  trace-should-not-contain [
-    app: render recipes
-  ]
-  # make a change (incrementing one of the args to 'add'), then rerun
-  $clear-trace
-  assume-console [
-    left-click 4, 28  # one past the value of the second arg
-    press backspace
-    type [3]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen updates the result on the right
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .recipe foo [                                      ┊─────────────────────────────────────────────────.
-    .  local-scope                                     ┊0   edit       copy       to recipe    delete    .
-    .  z:num <- add 2, 3                               ┊foo                                              .
-    .  reply z                                         ┊5                                                .
-    .]                                                 ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # no need to save sandboxes all over again
-  trace-should-not-contain [
-    app: save sandboxes
-  ]
-]
-
-scenario run-instruction-manages-screen-per-sandbox [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 20/height
-  # empty recipes
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction
-  env:&:environment <- new-programming-environment resources, screen, [print screen, 4]  # contents of sandbox editor
-  render-all screen, env, render
-  # run the code in the editor
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that it prints a little toy screen
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊print screen, 4                                  .
-    .                                                  ┊screen:                                          .
-    .                                                  ┊  .4                             .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-def editor-contents editor:&:editor -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  curr:&:duplex-list:char <- get *editor, data:offset
-  # skip § sentinel
-  assert curr, [editor without data is illegal; must have at least a sentinel]
-  curr <- next curr
-  return-unless curr, null
-  {
-    break-unless curr
-    c:char <- get *curr, value:offset
-    buf <- append buf, c
-    curr <- next curr
-    loop
-  }
-  result <- buffer-to-array buf
-]
-
-scenario editor-provides-edited-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  assume-console [
-    left-click 1, 2
-    type [def]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    s:text <- editor-contents e
-    1:@:char/raw <- copy *s
-  ]
-  memory-should-contain [
-    1:array:character <- [abdefc]
-  ]
-]
-
-# keep the bottom of recipes from scrolling off the screen
-
-scenario scrolling-down-past-bottom-of-recipe-editor [
-  local-scope
-  trace-until 100/app
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    press enter
-    press down-arrow
-  ]
-  event-loop screen, console, env, resources
-  # no scroll
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario cursor-down-in-recipe-editor [
-  local-scope
-  trace-until 100/app
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    press enter
-    press up-arrow
-    press down-arrow  # while cursor isn't at bottom
-  ]
-  event-loop screen, console, env, resources
-  cursor:char <- copy 9251/␣
-  print screen, cursor
-  # cursor moves back to bottom
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .␣                                                 ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario scrolling-down-past-bottom-of-recipe-editor-2 [
-  local-scope
-  trace-until 100/app
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    # add a line
-    press enter
-    # cursor back to top line
-    press up-arrow
-    # try to scroll
-    press page-down  # or ctrl-f
-  ]
-  event-loop screen, console, env, resources
-  # no scroll, and cursor remains at top line
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario scrolling-down-past-bottom-of-recipe-editor-3 [
-  local-scope
-  trace-until 100/app
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [ab
-cd]
-  render-all screen, env, render
-  assume-console [
-    # add a line
-    press enter
-    # switch to sandbox
-    press ctrl-n
-    # move cursor
-    press down-arrow
-  ]
-  event-loop screen, console, env, resources
-  cursor:char <- copy 9251/␣
-  print screen, cursor
-  # no scroll on recipe side, cursor moves on sandbox side
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊ab                                               .
-    .                                                  ┊␣d                                               .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-# scrolling through sandboxes
-
-scenario scrolling-down-past-bottom-of-sandbox-editor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  assume-console [
-    # create a sandbox
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-  ]
-  # switch to sandbox window and hit 'page-down'
-  assume-console [
-    press ctrl-n
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # hit 'page-up'
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor displays again, cursor is in editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊␣                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-  ]
-]
-
-# page-down on sandbox side updates render-from to scroll sandboxes
-after <global-keypress> [
-  {
-    break-unless sandbox-in-focus?
-    page-down?:bool <- equal k, 65518/page-down
-    break-unless page-down?
-    sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless sandbox
-    # slide down if possible
-    {
-      render-from:num <- get *env, render-from:offset
-      number-of-sandboxes:num <- get *env, number-of-sandboxes:offset
-      max:num <- subtract number-of-sandboxes, 1
-      at-end?:bool <- greater-or-equal render-from, max
-      loop-if at-end?, +next-event  # render nothing
-      render-from <- add render-from, 1
-      *env <- put *env, render-from:offset, render-from
-    }
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# update-cursor takes render-from into account
-after <update-cursor-special-cases> [
-  {
-    break-unless sandbox-in-focus?
-    render-from:num <- get *env, render-from:offset
-    scrolling?:bool <- greater-or-equal render-from, 0
-    break-unless scrolling?
-    cursor-column:num <- get *current-sandbox, left:offset
-    screen <- move-cursor screen, 2/row, cursor-column  # highlighted sandbox will always start at row 2
-    return
-  }
-]
-
-# 'page-up' on sandbox side is like 'page-down': updates render-from when necessary
-after <global-keypress> [
-  {
-    break-unless sandbox-in-focus?
-    page-up?:bool <- equal k, 65519/page-up
-    break-unless page-up?
-    render-from:num <- get *env, render-from:offset
-    at-beginning?:bool <- equal render-from, -1
-    break-if at-beginning?
-    render-from <- subtract render-from, 1
-    *env <- put *env, render-from:offset, render-from
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# sandbox belonging to 'env' whose next-sandbox is 'in'
-# return null if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox
-def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [
-  local-scope
-  load-inputs
-  curr:&:sandbox <- get *env, sandbox:offset
-  return-unless curr, null
-  next:&:sandbox <- get *curr, next-sandbox:offset
-  {
-    return-unless next, null
-    found?:bool <- equal next, in
-    break-if found?
-    curr <- copy next
-    next <- get *curr, next-sandbox:offset
-    loop
-  }
-  return curr
-]
-
-scenario scrolling-through-multiple-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  cursor:char <- copy 9251/␣
-  print screen, cursor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊␣                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # hit 'page-down'
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # hit 'page-down' again
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # just second sandbox displayed
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # hit 'page-down' again
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # hit 'page-up'
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # back to displaying both sandboxes without editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # back to displaying both sandboxes as well as editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊␣                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # no change
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊␣                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-]
-
-scenario scrolling-manages-sandbox-index-correctly [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create a sandbox
-  assume-console [
-    press ctrl-n
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # hit 'page-down' and 'page-up' a couple of times. sandbox index should be stable
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # back to displaying both sandboxes as well as editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # hit 'page-down'
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
diff --git a/archive/2.vm/edit/006-sandbox-copy.mu b/archive/2.vm/edit/006-sandbox-copy.mu
deleted file mode 100644
index 6af72f77..00000000
--- a/archive/2.vm/edit/006-sandbox-copy.mu
+++ /dev/null
@@ -1,395 +0,0 @@
-## the 'copy' button makes it easy to duplicate a sandbox, and thence to
-## see code operate in multiple situations
-
-scenario copy-a-sandbox-to-editor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click at left edge of 'copy' button
-  assume-console [
-    left-click 3, 69
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it copies into editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊add 1, 1                                         .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊0add 1, 1                                        .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario copy-a-sandbox-to-editor-2 [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click at right edge of 'copy' button (just before 'delete')
-  assume-console [
-    left-click 3, 76
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it copies into editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊add 1, 1                                         .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊0add 1, 1                                        .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-after <global-touch> [
-  # support 'copy' button
-  {
-    copy?:bool <- should-attempt-copy? click-row, click-column, env
-    break-unless copy?
-    copy?, env <- try-copy-sandbox click-row, env
-    break-unless copy?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to copy a sandbox
-def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'copy' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  _, _, copy-button-left:num, copy-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right
-  return-unless copy-button-vertical-area?, false
-  # finally, is sandbox editor empty?
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  result <- empty-editor? current-sandbox
-]
-
-def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to copy, if the click was actually on the 'copy' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-copy-button? <- copy true
-  text:text <- get *sandbox, data:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  current-sandbox <- insert-text current-sandbox, text
-  # reset scroll
-  *env <- put *env, render-from:offset, -1
-  # position cursor in sandbox editor
-  *env <- put *env, sandbox-in-focus?:offset, true
-]
-
-def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [
-  local-scope
-  load-inputs
-  curr-sandbox:&:sandbox <- get *env, sandbox:offset
-  {
-    break-unless curr-sandbox
-    start:num <- get *curr-sandbox, starting-row-on-screen:offset
-    found?:bool <- equal click-row, start
-    return-if found?, curr-sandbox
-    curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-    loop
-  }
-  return null/not-found
-]
-
-def click-on-sandbox-area? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  sandbox-left-margin:num <- get *current-sandbox, left:offset
-  on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
-  return-unless on-sandbox-side?, false
-  first-sandbox:&:sandbox <- get *env, sandbox:offset
-  return-unless first-sandbox, false
-  first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-  result <- greater-or-equal click-row, first-sandbox-begins
-]
-
-def empty-editor? editor:&:editor -> result:bool [
-  local-scope
-  load-inputs
-  head:&:duplex-list:char <- get *editor, data:offset
-  first:&:duplex-list:char <- next head
-  result <- not first
-]
-
-def within-range? x:num, low:num, high:num -> result:bool [
-  local-scope
-  load-inputs
-  not-too-far-left?:bool <- greater-or-equal x, low
-  not-too-far-right?:bool <- lesser-or-equal x, high
-  result <- and not-too-far-left? not-too-far-right?
-]
-
-scenario copy-fails-if-sandbox-editor-not-empty [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # type something into the sandbox editor, then click on the 'copy' button
-  assume-console [
-    left-click 2, 70  # put cursor in sandbox editor
-    type [0]  # type something
-    left-click 3, 70  # click 'copy' button
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # copy doesn't happen
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊0                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊01                                               .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-## the 'to recipe' button makes it easy to create a function out of a sandbox
-
-scenario copy-a-sandbox-to-recipe-side [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click at left edge of 'copy' button
-  assume-console [
-    left-click 3, 78
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it copies into recipe side
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .add 1, 1                                          ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be at the top left of the recipe side
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .0add 1, 1                                         ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-after <global-touch> [
-  # support 'copy to recipe' button
-  {
-    copy?:bool <- should-copy-to-recipe? click-row, click-column, env
-    break-unless copy?
-    modified?:bool <- prepend-sandbox-into-recipe-side click-row, env
-    break-unless modified?
-    *env <- put *env, sandbox-in-focus?:offset, false
-    screen <- render-recipes screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to copy a sandbox into the recipe side
-def should-copy-to-recipe? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'copy' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  _, _, _, _, recipe-button-left:num, recipe-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  result <- within-range? click-column, recipe-button-left, recipe-button-right
-]
-
-def prepend-sandbox-into-recipe-side click-row:num, env:&:environment -> clicked-on-copy-to-recipe-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  recipe-editor:&:editor <- get *env, recipes:offset
-  recipe-data:&:duplex-list:char <- get *recipe-editor, data:offset
-  # make the newly inserted code easy to delineate
-  newline:char <- copy 10
-  insert newline, recipe-data
-  insert newline, recipe-data
-  # insert code from the selected sandbox
-  sandbox-data:text <- get *sandbox, data:offset
-  insert recipe-data, sandbox-data
-  # reset cursor
-  *recipe-editor <- put *recipe-editor, top-of-screen:offset, recipe-data
-  *recipe-editor <- put *recipe-editor, before-cursor:offset, recipe-data
-  *recipe-editor <- put *recipe-editor, cursor-row:offset, 1
-  *recipe-editor <- put *recipe-editor, cursor-column:offset, 0
-  return true
-]
diff --git a/archive/2.vm/edit/007-sandbox-delete.mu b/archive/2.vm/edit/007-sandbox-delete.mu
deleted file mode 100644
index 5e7989fb..00000000
--- a/archive/2.vm/edit/007-sandbox-delete.mu
+++ /dev/null
@@ -1,342 +0,0 @@
-## deleting sandboxes
-
-scenario deleting-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # run a few commands
-  assume-console [
-    left-click 1, 75
-    type [divide-with-remainder 11, 3]
-    press F4
-    type [add 2, 2]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊divide-with-remainder 11, 3                      .
-    .                                                  ┊3                                                .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # delete second sandbox by clicking on left edge of 'delete' button
-  assume-console [
-    left-click 7, 90
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # delete first sandbox by clicking at right edge of 'delete' button
-  assume-console [
-    left-click 3, 99
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-after <global-touch> [
-  # support 'delete' button
-  {
-    delete?:bool <- should-attempt-delete? click-row, click-column, env
-    break-unless delete?
-    delete?, env <- try-delete-sandbox click-row, env
-    break-unless delete?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to delete a sandbox
-def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'copy' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  _, _, _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  result <- within-range? click-column, delete-button-left, sandbox-right-margin
-]
-
-def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to delete, if the click was actually on the 'delete' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-delete-button? <- copy true
-  env <- delete-sandbox env, sandbox
-]
-
-def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [
-  local-scope
-  load-inputs
-  curr-sandbox:&:sandbox <- get *env, sandbox:offset
-  first-sandbox?:bool <- equal curr-sandbox, sandbox
-  {
-    # first sandbox? pop
-    break-unless first-sandbox?
-    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
-    *env <- put *env, sandbox:offset, next-sandbox
-  }
-  {
-    # not first sandbox?
-    break-if first-sandbox?
-    prev-sandbox:&:sandbox <- copy curr-sandbox
-    curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-    {
-      assert curr-sandbox, [sandbox not found! something is wrong.]
-      found?:bool <- equal curr-sandbox, sandbox
-      break-if found?
-      prev-sandbox <- copy curr-sandbox
-      curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-      loop
-    }
-    # snip sandbox out of its list
-    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
-    *prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox
-  }
-  # update sandbox count
-  sandbox-count:num <- get *env, number-of-sandboxes:offset
-  sandbox-count <- subtract sandbox-count, 1
-  *env <- put *env, number-of-sandboxes:offset, sandbox-count
-  # reset scroll if deleted sandbox was last
-  {
-    break-if next-sandbox
-    render-from:num <- get *env, render-from:offset
-    reset-scroll?:bool <- equal render-from, sandbox-count
-    break-unless reset-scroll?
-    *env <- put *env, render-from:offset, -1
-  }
-]
-
-scenario deleting-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 6, 99
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario deleting-top-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 2, 99
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario deleting-final-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 2, 99
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # implicitly scroll up to first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario deleting-updates-sandbox-count [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # delete the second sandbox, then try to scroll down twice
-  assume-console [
-    left-click 3, 99
-    press page-down
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # shouldn't go past last sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
diff --git a/archive/2.vm/edit/008-sandbox-edit.mu b/archive/2.vm/edit/008-sandbox-edit.mu
deleted file mode 100644
index 57cdbc0d..00000000
--- a/archive/2.vm/edit/008-sandbox-edit.mu
+++ /dev/null
@@ -1,325 +0,0 @@
-## editing sandboxes after they've been created
-
-scenario clicking-on-sandbox-edit-button-moves-it-to-editor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click at left edge of 'edit' button
-  assume-console [
-    left-click 3, 55
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it pops back into editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊add 2, 2                                         .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊0add 2, 2                                        .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario clicking-on-sandbox-edit-button-moves-it-to-editor-2 [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click at right edge of 'edit' button (just before 'copy')
-  assume-console [
-    left-click 3, 65
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it pops back into editor
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊add 2, 2                                         .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊0add 2, 2                                        .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-after <global-touch> [
-  # support 'edit' button
-  {
-    edit?:bool <- should-attempt-edit? click-row, click-column, env
-    break-unless edit?
-    edit?, env <- try-edit-sandbox click-row, env
-    break-unless edit?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to edit a sandbox
-def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'edit' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right
-  return-unless edit-button-vertical-area?, false
-  # finally, is sandbox editor empty?
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  result <- empty-editor? current-sandbox
-]
-
-def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to edit, if the click was actually on the 'edit' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-edit-button? <- copy true
-  # 'edit' button = 'copy' button + 'delete' button
-  text:text <- get *sandbox, data:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  current-sandbox <- insert-text current-sandbox, text
-  env <- delete-sandbox env, sandbox
-  # reset scroll
-  *env <- put *env, render-from:offset, -1
-  # position cursor in sandbox editor
-  *env <- put *env, sandbox-in-focus?:offset, true
-]
-
-scenario sandbox-with-print-can-be-edited [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 20/height
-  # left editor is empty
-  assume-resources [
-  ]
-  # right editor contains a print instruction
-  env:&:environment <- new-programming-environment resources, screen, [print screen, 4]
-  render-all screen, env, render
-  # run the sandbox
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊print screen, 4                                  .
-    .                                                  ┊screen:                                          .
-    .                                                  ┊  .4                             .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # edit the sandbox
-  assume-console [
-    left-click 3, 65
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊print screen, 4                                  .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario editing-sandbox-after-scrolling-resets-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # edit the second sandbox
-  assume-console [
-    left-click 2, 55
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊add 2, 2                                         .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario editing-sandbox-updates-sandbox-count [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # edit the second sandbox, then resave
-  assume-console [
-    left-click 3, 60
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change in contents
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 1, 1                                         .
-    .                                                  ┊2                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-  ]
-  # now try to scroll past end
-  assume-console [
-    press page-down
-    press page-down
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # screen should show just final sandbox with the right index (1)
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
diff --git a/archive/2.vm/edit/009-sandbox-test.mu b/archive/2.vm/edit/009-sandbox-test.mu
deleted file mode 100644
index 52c1e909..00000000
--- a/archive/2.vm/edit/009-sandbox-test.mu
+++ /dev/null
@@ -1,231 +0,0 @@
-## clicking on sandbox results to 'fix' them and turn sandboxes into tests
-
-scenario sandbox-click-on-result-toggles-color-to-green [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 20/height
-  # basic recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  reply 4|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  reply 4                                         ┊─────────────────────────────────────────────────.
-    .]                                                 ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊foo                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click on the '4' in the result
-  $clear-trace
-  assume-console [
-    left-click 5, 51
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # color toggles to green
-  screen-should-contain-in-color 2/green, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   4                                                .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-  # don't render entire sandbox side
-  check-trace-count-for-label-lesser-than 250, [print-character]  # say 5 sandbox lines
-  # cursor should remain unmoved
-  run [
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .␣ecipe foo [                                      ┊                                                 .
-    .  reply 4                                         ┊─────────────────────────────────────────────────.
-    .]                                                 ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊foo                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # now change the result
-  # then rerun
-  assume-console [
-    left-click 2, 11  # cursor to end of line
-    press backspace
-    type [3]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # result turns red
-  screen-should-contain-in-color 1/red, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   3                                                .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-]
-
-# this requires tracking a couple more things
-container sandbox [
-  response-starting-row-on-screen:num
-  expected-response:text
-]
-
-# include expected response when saving or restoring a sandbox
-before <end-save-sandbox> [
-  {
-    expected-response:text <- get *sandbox, expected-response:offset
-    break-unless expected-response
-    filename <- append filename, [.out]
-    resources <- dump resources, filename, expected-response
-  }
-]
-
-before <end-restore-sandbox> [
-  {
-    filename <- append filename, [.out]
-    contents <- slurp resources, filename
-    break-unless contents
-    *curr <- put *curr, expected-response:offset, contents
-  }
-]
-
-# clicks on sandbox responses save it as 'expected'
-after <global-touch> [
-  # check if it's inside the output of any sandbox
-  {
-    sandbox-left-margin:num <- get *current-sandbox, left:offset
-    click-column:num <- get t, column:offset
-    on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
-    break-unless on-sandbox-side?
-    first-sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless first-sandbox
-    first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-    click-row:num <- get t, row:offset
-    below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
-    break-unless below-sandbox-editor?
-    # identify the sandbox whose output is being clicked on
-    sandbox:&:sandbox, sandbox-index:num <- find-click-in-sandbox-output env, click-row
-    break-unless sandbox
-    # update it
-    sandbox <- toggle-expected-response sandbox
-    # minimal update to disk
-    save-sandbox resources, sandbox, sandbox-index
-    # minimal update to screen
-    sandbox-right-margin:num <- get *current-sandbox, right:offset
-    row:num <- render-sandbox-response screen, sandbox, sandbox-left-margin, sandbox-right-margin
-    {
-      height:num <- screen-height screen
-      at-bottom?:bool <- greater-or-equal row, height
-      break-if at-bottom?
-      draw-horizontal screen, row, sandbox-left-margin, sandbox-right-margin
-    }
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox, sandbox-index:num [
-  local-scope
-  load-inputs
-  # assert click-row >= sandbox.starting-row-on-screen
-  sandbox:&:sandbox <- get *env, sandbox:offset
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
-  assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
-  # while click-row < sandbox.next-sandbox.starting-row-on-screen
-  sandbox-index <- copy 0
-  {
-    next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-    break-unless next-sandbox
-    next-start:num <- get *next-sandbox, starting-row-on-screen:offset
-    found?:bool <- lesser-than click-row, next-start
-    break-if found?
-    sandbox <- copy next-sandbox
-    sandbox-index <- add sandbox-index, 1
-    loop
-  }
-  # return sandbox if click is in its output region
-  response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset
-  return-unless response-starting-row, null/no-click-in-sandbox-output, 0/sandbox-index
-  click-in-response?:bool <- greater-or-equal click-row, response-starting-row
-  return-unless click-in-response?, null/no-click-in-sandbox-output, 0/sandbox-index
-  return sandbox, sandbox-index
-]
-
-def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  expected-response:text <- get *sandbox, expected-response:offset
-  {
-    # if expected-response is set, reset
-    break-unless expected-response
-    *sandbox <- put *sandbox, expected-response:offset, null
-  }
-  {
-    # if not, set expected response to the current response
-    break-if expected-response
-    response:text <- get *sandbox, response:offset
-    *sandbox <- put *sandbox, expected-response:offset, response
-  }
-]
-
-# when rendering a sandbox, color it in red/green if expected response exists
-after <render-sandbox-response> [
-  {
-    break-unless sandbox-response
-    *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row
-    row <- render-sandbox-response screen, sandbox, left, right
-    jump +render-sandbox-end
-  }
-]
-
-def render-sandbox-response screen:&:screen, sandbox:&:sandbox, left:num, right:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  sandbox-response:text <- get *sandbox, response:offset
-  expected-response:text <- get *sandbox, expected-response:offset
-  row:num <- get *sandbox response-starting-row-on-screen:offset
-  {
-    break-if expected-response
-    row <- render-text screen, sandbox-response, left, right, 245/grey, row
-    return
-  }
-  response-is-expected?:bool <- equal expected-response, sandbox-response
-  {
-    break-if response-is-expected?
-    row <- render-text screen, sandbox-response, left, right, 1/red, row
-  }
-  {
-    break-unless response-is-expected?:bool
-    row <- render-text screen, sandbox-response, left, right, 2/green, row
-  }
-]
-
-before <end-render-sandbox-reset-hidden> [
-  *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0
-]
diff --git a/archive/2.vm/edit/010-sandbox-trace.mu b/archive/2.vm/edit/010-sandbox-trace.mu
deleted file mode 100644
index 23b88833..00000000
--- a/archive/2.vm/edit/010-sandbox-trace.mu
+++ /dev/null
@@ -1,253 +0,0 @@
-## clicking on the code typed into a sandbox toggles its trace
-
-scenario sandbox-click-on-code-toggles-app-trace [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # basic recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  stash [abc]|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  stash [abc]                                     ┊─────────────────────────────────────────────────.
-    .]                                                 ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊foo                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click on the code in the sandbox
-  assume-console [
-    left-click 4, 51
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # trace now printed and cursor shouldn't have budged
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .␣ecipe foo [                                      ┊                                                 .
-    .  stash [abc]                                     ┊─────────────────────────────────────────────────.
-    .]                                                 ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊foo                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc                                              .
-  ]
-  screen-should-contain-in-color 245/grey, [
-    .                                                                                                    .
-    .                                                  ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc                                              .
-  ]
-  # click again on the same region
-  assume-console [
-    left-click 4, 55
-  ]
-  run [
-    event-loop screen, console, env, resources
-    print screen, cursor
-  ]
-  # trace hidden again
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .␣ecipe foo [                                      ┊                                                 .
-    .  stash [abc]                                     ┊─────────────────────────────────────────────────.
-    .]                                                 ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊foo                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario sandbox-shows-app-trace-and-result [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # basic recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  stash [abc]|
-      |  reply 4|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  stash [abc]                                     ┊─────────────────────────────────────────────────.
-    .  reply 4                                         ┊0   edit       copy       to recipe    delete    .
-    .]                                                 ┊foo                                              .
-    .                                                  ┊4                                                .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  # click on the code in the sandbox
-  assume-console [
-    left-click 4, 51
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # trace now printed above result
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  stash [abc]                                     ┊─────────────────────────────────────────────────.
-    .  reply 4                                         ┊0   edit       copy       to recipe    delete    .
-    .]                                                 ┊foo                                              .
-    .                                                  ┊abc                                              .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊8 instructions run                               .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario clicking-on-app-trace-does-nothing [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [stash 123456789]
-  render-all screen, env, render
-  # create and expand the trace
-  assume-console [
-    press F4
-    left-click 4, 51
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊stash 123456789                                  .
-    .                                                  ┊123456789                                        .
-  ]
-  # click on the stash under the edit-button region (or any of the other buttons, really)
-  assume-console [
-    left-click 5, 57
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change; doesn't die
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊stash 123456789                                  .
-    .                                                  ┊123456789                                        .
-  ]
-]
-
-container sandbox [
-  trace:text
-  display-trace?:bool
-]
-
-# replaced in a later layer
-def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-  *sandbox <- put *sandbox, trace:offset, trace
-]
-
-# clicks on sandbox code toggle its display-trace? flag
-after <global-touch> [
-  # check if it's inside the code of any sandbox
-  {
-    sandbox-left-margin:num <- get *current-sandbox, left:offset
-    click-column:num <- get t, column:offset
-    on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
-    break-unless on-sandbox-side?
-    first-sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless first-sandbox
-    first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-    click-row:num <- get t, row:offset
-    below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
-    break-unless below-sandbox-editor?
-    # identify the sandbox whose code is being clicked on
-    sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row
-    break-unless sandbox
-    # toggle its display-trace? property
-    x:bool <- get *sandbox, display-trace?:offset
-    x <- not x
-    *sandbox <- put *sandbox, display-trace?:offset, x
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
-    loop +next-event
-  }
-]
-
-def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  # assert click-row >= sandbox.starting-row-on-screen
-  sandbox <- get *env, sandbox:offset
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
-  assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
-  # while click-row < sandbox.next-sandbox.starting-row-on-screen
-  {
-    next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-    break-unless next-sandbox
-    next-start:num <- get *next-sandbox, starting-row-on-screen:offset
-    found?:bool <- lesser-than click-row, next-start
-    break-if found?
-    sandbox <- copy next-sandbox
-    loop
-  }
-  # return sandbox if click is in its code region
-  code-ending-row:num <- get *sandbox, code-ending-row-on-screen:offset
-  click-above-response?:bool <- lesser-than click-row, code-ending-row
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  click-below-menu?:bool <- greater-than click-row, start
-  click-on-sandbox-code?:bool <- and click-above-response?, click-below-menu?
-  {
-    break-if click-on-sandbox-code?
-    return null/no-click-in-sandbox-output
-  }
-  return sandbox
-]
-
-# when rendering a sandbox, dump its trace before response/warning if display-trace? property is set
-after <render-sandbox-results> [
-  {
-    display-trace?:bool <- get *sandbox, display-trace?:offset
-    break-unless display-trace?
-    sandbox-trace:text <- get *sandbox, trace:offset
-    break-unless sandbox-trace  # nothing to print; move on
-    row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row
-  }
-  <render-sandbox-trace-done>
-]
diff --git a/archive/2.vm/edit/011-errors.mu b/archive/2.vm/edit/011-errors.mu
deleted file mode 100644
index 47258815..00000000
--- a/archive/2.vm/edit/011-errors.mu
+++ /dev/null
@@ -1,886 +0,0 @@
-## handling malformed programs
-
-container environment [
-  recipe-errors:text
-]
-
-# copy code from recipe editor, persist to disk, load, save any errors
-def! update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [
-  local-scope
-  load-inputs
-  recipes:&:editor <- get *env, recipes:offset
-  in:text <- editor-contents recipes
-  resources <- dump resources, [lesson/recipes.mu], in
-  recipe-errors:text <- reload in
-  *env <- put *env, recipe-errors:offset, recipe-errors
-  # if recipe editor has errors, stop
-  {
-    break-unless recipe-errors
-    update-status screen, [errors found     ], 1/red
-    errors-found? <- copy true
-    return
-  }
-  errors-found? <- copy false
-]
-
-after <begin-run-sandboxes-on-F4> [
-  old-recipe-errors:text <- get *env, recipe-errors:offset
-]
-before <end-run-sandboxes-on-F4> [
-  # if there were recipe errors before, check if we can clear them
-  {
-    break-unless old-recipe-errors
-    screen <- render-recipes screen, env, render
-  }
-  render-recipe-errors env, screen
-]
-
-before <end-render-recipe-components> [
-  row <- render-recipe-errors env, screen
-]
-
-def render-recipe-errors env:&:environment, screen:&:screen -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  recipe-errors:text <- get *env, recipe-errors:offset
-  recipes:&:editor <- get *env, recipes:offset
-  row:num <- get *recipes, bottom:offset
-  row <- add row, 1
-  return-unless recipe-errors
-  left:num <- get *recipes, left:offset
-  right:num <- get *recipes, right:offset
-  row, screen <- render-text screen, recipe-errors, left, right, 1/red, row
-  # draw dotted line after recipes
-  draw-horizontal screen, row, left, right, 9480/horizontal-dotted
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-]
-
-container environment [
-  error-index:num  # index of first sandbox with an error (or -1 if none)
-]
-
-after <programming-environment-initialization> [
-  *result <- put *result, error-index:offset, -1
-]
-
-after <begin-run-sandboxes> [
-  *env <- put *env, error-index:offset, -1
-]
-
-before <end-run-sandboxes> [
-  {
-    error-index:num <- get *env, error-index:offset
-    sandboxes-completed-successfully?:bool <- equal error-index, -1
-    break-if sandboxes-completed-successfully?
-    errors-found? <- copy true
-  }
-]
-
-before <end-run-sandboxes-on-F4> [
-  {
-    break-unless error?
-    recipe-errors:text <- get *env, recipe-errors:offset
-    break-if recipe-errors
-    error-index:num <- get *env, error-index:offset
-    sandboxes-completed-successfully?:bool <- equal error-index, -1
-    break-if sandboxes-completed-successfully?
-    error-index-text:text <- to-text error-index
-    status:text <- interpolate [errors found (_)    ], error-index-text
-    update-status screen, status, 1/red
-  }
-]
-
-container sandbox [
-  errors:text
-]
-
-def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, errors:offset, errors
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-  *sandbox <- put *sandbox, trace:offset, trace
-  {
-    break-if errors
-    break-if completed?
-    errors <- new [took too long!
-]
-    *sandbox <- put *sandbox, errors:offset, errors
-  }
-  {
-    break-unless errors
-    error-index:num <- get *env, error-index:offset
-    error-not-set?:bool <- equal error-index, -1
-    break-unless error-not-set?
-    *env <- put *env, error-index:offset, idx
-  }
-]
-
-# make sure we render any trace
-after <render-sandbox-trace-done> [
-  {
-    sandbox-errors:text <- get *sandbox, errors:offset
-    break-unless sandbox-errors
-    *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0  # no response
-    row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row
-    # don't try to print anything more for this sandbox
-    jump +render-sandbox-end
-  }
-]
-
-scenario run-shows-errors-in-get [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  get 123:num, foo:offset|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  get 123:num, foo:offset                         ┊─────────────────────────────────────────────────.
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  get 123:num, foo:offset                         ┊─────────────────────────────────────────────────.
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: unknown element 'foo' in container 'number'  ┊                                                 .
-    .foo: first ingredient of 'get' should be a contai↩┊                                                 .
-    .ner, but got '123:num'                            ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .  errors found                                                                                      .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .foo: unknown element 'foo' in container 'number'                                                    .
-    .foo: first ingredient of 'get' should be a contai                                                   .
-    .ner, but got '123:num'                                                                              .
-    .                                                                                                    .
-  ]
-]
-
-scenario run-shows-errors-without-final-newline-in-recipe-side [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen
-  render-all screen, env, render
-  assume-console [
-    type [recipe foo x [
-]]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo x [                                    ┊                                                 .
-    .]                                                 ┊─────────────────────────────────────────────────.
-    .foo: ingredient 'x' has no type                   ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-updates-status-with-first-erroneous-sandbox [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    left-click 3, 80
-    # create invalid sandbox 1
-    type [get foo, x:offset]
-    press F4
-    # create invalid sandbox 0
-    type [get foo, x:offset]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # status line shows that error is in first sandbox
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-  ]
-]
-
-scenario run-updates-status-with-first-erroneous-sandbox-2 [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    left-click 3, 80
-    # create invalid sandbox 2
-    type [get foo, x:offset]
-    press F4
-    # create invalid sandbox 1
-    type [get foo, x:offset]
-    press F4
-    # create valid sandbox 0
-    type [add 2, 2]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # status line shows that error is in second sandbox
-  screen-should-contain [
-    .  errors found (1)                                                               run (F4)           .
-  ]
-]
-
-scenario run-hides-errors-from-past-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset]  # invalid
-  render-all screen, env, render
-  assume-console [
-    press F4  # generate error
-  ]
-  event-loop screen, console, env, resources
-  assume-console [
-    left-click 3, 58
-    press ctrl-k
-    type [add 2, 2]  # valid code
-    press F4  # update sandbox
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # error should disappear
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊add 2, 2                                         .
-    .                                                  ┊4                                                .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-updates-errors-for-shape-shifting-recipes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # define a shape-shifting recipe with an error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo x:_elem -> z:_elem [|
-      |  local-scope|
-      |  load-ingredients|
-      |  y:&:num <- copy null|
-      |  z <- add x, y|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo 2]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .recipe foo x:_elem -> z:_elem [                   ┊                                                 .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  load-ingredients                                ┊0   edit       copy       to recipe    delete    .
-    .  y:&:num <- copy null                            ┊foo 2                                            .
-    .  z <- add x, y                                   ┊foo_2: 'add' requires number ingredients, but go↩.
-    .]                                                 ┊t 'y'                                            .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # now rerun everything
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # error should remain unchanged
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .recipe foo x:_elem -> z:_elem [                   ┊                                                 .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  load-ingredients                                ┊0   edit       copy       to recipe    delete    .
-    .  y:&:num <- copy null                            ┊foo 2                                            .
-    .  z <- add x, y                                   ┊foo_3: 'add' requires number ingredients, but go↩.
-    .]                                                 ┊t 'y'                                            .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # overload a well-known shape-shifting recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe length l:&:list:_elem -> n:num [|
-      |]|
-    ]
-  ]
-  # call code that uses other variants of it, but not it itself
-  test-sandbox:text <- new [x:&:list:num <- copy null
-to-text x]
-  env:&:environment <- new-programming-environment resources, screen, test-sandbox
-  render-all screen, env, render
-  # run it once
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  # no errors anywhere on screen (can't check anything else, since to-text will return an address)
-  screen-should-contain-in-color 1/red, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                <-                                  .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-  # rerun everything
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # still no errors
-  screen-should-contain-in-color 1/red, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                <-                                  .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-]
-
-scenario run-shows-missing-type-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  x <- copy 0|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  x <- copy 0                                     ┊─────────────────────────────────────────────────.
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: missing type for 'x' in 'x <- copy 0'        ┊                                                 .
-    .foo: can't copy '0' to 'x'; types don't match     ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-shows-unbalanced-bracket-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # recipe is incomplete (unbalanced '[')
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo \\\[|
-      |  x <- copy 0|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo \\[                                      ┊foo                                              .
-    .  x <- copy 0                                     ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .9: unbalanced '\\[' for recipe                      ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-shows-get-on-non-container-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:&:point <- new point:type|
-      |  get x:&:point, 1:offset|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:&:point <- new point:type                     ┊                                                 .
-    .  get x:&:point, 1:offset                         ┊                                                 .
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: first ingredient of 'get' should be a contai↩┊                                                 .
-    .ner, but got 'x:&:point'                          ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-shows-non-literal-get-argument-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:num <- copy 0|
-      |  y:&:point <- new point:type|
-      |  get *y:&:point, x:num|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:num <- copy 0                                 ┊                                                 .
-    .  y:&:point <- new point:type                     ┊                                                 .
-    .  get *y:&:point, x:num                           ┊                                                 .
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: second ingredient of 'get' should have type ↩┊                                                 .
-    .'offset', but got 'x:num'                         ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-shows-errors-every-time [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # try to run a file with an error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:num <- copy y:num|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:num <- copy y:num                             ┊                                                 .
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
-    .py y:num' but it hasn't been written to yet       ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # rerun the file, check for the same error
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:num <- copy y:num                             ┊                                                 .
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
-    .py y:num' but it hasn't been written to yet       ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-hides-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 15/height
-  # try to run a file with an error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:num <- copy y:num|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .recipe foo [                                      ┊foo                                              .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:num <- copy y:num                             ┊                                                 .
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-    .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
-    .py y:num' but it hasn't been written to yet       ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # fix the error, hit F4
-  assume-console [
-    left-click 3, 16
-    press ctrl-k
-    type [0]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  # no error anymore
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  x:num <- copy 0                                 ┊0   edit       copy       to recipe    delete    .
-    .]                                                 ┊foo                                              .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario scrolling-recipe-side-reveals-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 5/height
-  # recipe overflows recipe side
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  a:num <- copy 0|  # padding to overflow recipe side
-      |  b:num <- copy 0|  # padding to overflow recipe side
-      |  get 123:num, foo:offset|  # line containing error
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # hit F4, generating errors, then scroll down
-  assume-console [
-    press F4
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # errors should be displayed
-  screen-should-contain [
-    .  errors found                                                                   run (F4)           .
-    .  get 123:num, foo:offset                         ┊foo                                              .
-    .\\]                                                 ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .foo: unknown element 'foo' in container 'number'  ┊                                                 .
-  ]
-]
-
-scenario run-instruction-and-print-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  # sandbox editor contains an illegal instruction
-  env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints error message in red
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊get 1234:num, foo:offset                         .
-    .                                                  ┊unknown element 'foo' in container 'number'      .
-    .                                                  ┊first ingredient of 'get' should be a container,↩.
-    .                                                  ┊ but got '1234:num'                              .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-  screen-should-contain-in-color 7/white, [
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   get 1234:num, foo:offset                         .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .  errors found (0)                                                                                  .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                                                                    .
-    .                                                   unknown element 'foo' in container 'number'      .
-    .                                                   first ingredient of 'get' should be a container, .
-    .                                                    but got '1234:num'                              .
-    .                                                                                                    .
-  ]
-  screen-should-contain-in-color 245/grey, [
-    .                                                                                                    .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                ↩.
-    .                                                  ┊                                                 .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario run-instruction-and-print-errors-only-once [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  assume-resources [
-  ]
-  # sandbox editor contains an illegal instruction
-  env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset]
-  render-all screen, env, render
-  # run the code in the editors multiple times
-  assume-console [
-    press F4
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints error message just once
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────.
-    .                                                  ┊0   edit       copy       to recipe    delete    .
-    .                                                  ┊get 1234:num, foo:offset                         .
-    .                                                  ┊unknown element 'foo' in container 'number'      .
-    .                                                  ┊first ingredient of 'get' should be a container,↩.
-    .                                                  ┊ but got '1234:num'                              .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario sandbox-can-handle-infinite-loop [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 20/height
-  # sandbox editor will trigger an infinite loop
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  {|
-      |    loop|
-      |  }|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # run the sandbox
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  {                                               ┊─────────────────────────────────────────────────.
-    .    loop                                          ┊0   edit       copy       to recipe    delete    .
-    .  }                                               ┊foo                                              .
-    .]                                                 ┊took too long!                                   .
-    .                                                  ┊─────────────────────────────────────────────────.
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
-scenario sandbox-with-errors-shows-trace [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
-  # generate a stash and a error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  a:num <- next-ingredient|
-      |  b:num <- next-ingredient|
-      |  stash [dividing by], b|
-      |  _, c:num <- divide-with-remainder a, b|
-      |  reply b|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo 4, 0]
-  render-all screen, env, render
-  # run
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  # screen prints error message
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  a:num <- next-ingredient                        ┊0   edit       copy       to recipe    delete    .
-    .  b:num <- next-ingredient                        ┊foo 4, 0                                         .
-    .  stash [dividing by], b                          ┊foo: divide by zero in '_, c:num <- divide-with-↩.
-    .  _, c:num <- divide-with-remainder a, b          ┊remainder a, b'                                  .
-    .  reply b                                         ┊─────────────────────────────────────────────────.
-    .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-  # click on the call in the sandbox
-  assume-console [
-    left-click 4, 55
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # screen should expand trace
-  screen-should-contain [
-    .  errors found (0)                                                               run (F4)           .
-    .recipe foo [                                      ┊                                                 .
-    .  local-scope                                     ┊─────────────────────────────────────────────────.
-    .  a:num <- next-ingredient                        ┊0   edit       copy       to recipe    delete    .
-    .  b:num <- next-ingredient                        ┊foo 4, 0                                         .
-    .  stash [dividing by], b                          ┊dividing by 0                                    .
-    .  _, c:num <- divide-with-remainder a, b          ┊14 instructions run                              .
-    .  reply b                                         ┊foo: divide by zero in '_, c:num <- divide-with-↩.
-    .]                                                 ┊remainder a, b'                                  .
-    .                                                  ┊─────────────────────────────────────────────────.
-  ]
-]
diff --git a/archive/2.vm/edit/012-editor-undo.mu b/archive/2.vm/edit/012-editor-undo.mu
deleted file mode 100644
index 871f6c74..00000000
--- a/archive/2.vm/edit/012-editor-undo.mu
+++ /dev/null
@@ -1,2111 +0,0 @@
-## undo/redo
-
-# for every undoable event, create a type of *operation* that contains all the
-# information needed to reverse it
-exclusive-container operation [
-  typing:insert-operation
-  move:move-operation
-  delete:delete-operation
-]
-
-container insert-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate
-  insert-from:&:duplex-list:char
-  insert-until:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (enter+indent)
-    # 1: regular alphanumeric characters
-]
-
-container move-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (touch events, etc)
-    # 1: left arrow
-    # 2: right arrow
-    # 3: up arrow
-    # 4: down arrow
-    # 5: line up
-    # 6: line down
-]
-
-container delete-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  deleted-text:&:duplex-list:char
-  delete-from:&:duplex-list:char
-  delete-until:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (ctrl-k, ctrl-u)
-    # 1: backspace
-    # 2: delete
-]
-
-# every editor accumulates a list of operations to undo/redo
-container editor [
-  undo:&:list:&:operation
-  redo:&:list:&:operation
-]
-
-# ctrl-z - undo operation
-after <handle-special-character> [
-  {
-    undo?:bool <- equal c, 26/ctrl-z
-    break-unless undo?
-    undo:&:list:&:operation <- get *editor, undo:offset
-    break-unless undo
-    op:&:operation <- first undo
-    undo <- rest undo
-    *editor <- put *editor, undo:offset, undo
-    redo:&:list:&:operation <- get *editor, redo:offset
-    redo <- push op, redo
-    *editor <- put *editor, redo:offset, redo
-    <handle-undo>
-    return true/go-render
-  }
-]
-
-# ctrl-y - redo operation
-after <handle-special-character> [
-  {
-    redo?:bool <- equal c, 25/ctrl-y
-    break-unless redo?
-    redo:&:list:&:operation <- get *editor, redo:offset
-    break-unless redo
-    op:&:operation <- first redo
-    redo <- rest redo
-    *editor <- put *editor, redo:offset, redo
-    undo:&:list:&:operation <- get *editor, undo:offset
-    undo <- push op, undo
-    *editor <- put *editor, undo:offset, undo
-    <handle-redo>
-    return true/go-render
-  }
-]
-
-# undo typing
-
-scenario editor-can-undo-typing [
-  local-scope
-  # create an editor and type a character
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [0]
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # character should be gone
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# save operation to undo
-after <begin-insert-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset
-]
-before <end-insert-character> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  undo:&:list:&:operation <- get *editor, undo:offset
-  {
-    # if previous operation was an insert, coalesce this operation with it
-    break-unless undo
-    op:&:operation <- first undo
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    previous-coalesce-tag:num <- get typing, tag:offset
-    break-unless previous-coalesce-tag
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    insert-until:&:duplex-list:char <- next before-cursor
-    typing <- put typing, insert-until:offset, insert-until
-    typing <- put typing, after-row:offset, cursor-row
-    typing <- put typing, after-column:offset, cursor-column
-    typing <- put typing, after-top-of-screen:offset, top-after
-    *op <- merge 0/insert-operation, typing
-    break +done-adding-insert-operation
-  }
-  # if not, create a new operation
-  insert-from:&:duplex-list:char <- next cursor-before
-  insert-to:&:duplex-list:char <- next insert-from
-  op:&:operation <- new operation:type
-  *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 1/coalesce
-  editor <- add-operation editor, op
-  +done-adding-insert-operation
-]
-
-# enter operations never coalesce with typing before or after
-after <begin-insert-enter> [
-  cursor-row-before:num <- copy cursor-row
-  cursor-column-before:num <- copy cursor-column
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset
-]
-before <end-insert-enter> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-row:offset
-  # never coalesce
-  insert-from:&:duplex-list:char <- next cursor-before
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  insert-to:&:duplex-list:char <- next before-cursor
-  op:&:operation <- new operation:type
-  *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce
-  editor <- add-operation editor, op
-]
-
-# Everytime you add a new operation to the undo stack, be sure to clear the
-# redo stack, because it's now obsolete.
-# Beware: since we're counting cursor moves as operations, this means just
-# moving the cursor can lose work on the undo stack.
-def add-operation editor:&:editor, op:&:operation -> editor:&:editor [
-  local-scope
-  load-inputs
-  undo:&:list:&:operation <- get *editor, undo:offset
-  undo <- push op undo
-  *editor <- put *editor, undo:offset, undo
-  redo:&:list:&:operation <- get *editor, redo:offset
-  redo <- copy null
-  *editor <- put *editor, redo:offset, redo
-]
-
-after <handle-undo> [
-  {
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    start:&:duplex-list:char <- get typing, insert-from:offset
-    end:&:duplex-list:char <- get typing, insert-until:offset
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    before-cursor:&:duplex-list:char <- prev start
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    remove-between before-cursor, end
-    cursor-row <- get typing, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get typing, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get typing, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-can-undo-typing-multiple [
-  local-scope
-  # create an editor and type multiple characters
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be gone
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-can-undo-typing-multiple-2 [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [a], 0/left, 10/right
-  editor-render screen, e
-  # type some characters
-  assume-console [
-    type [012]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .012a      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # back to original text
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .3a        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-can-undo-typing-enter [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [  abc], 0/left, 10/right
-  editor-render screen, e
-  # new line
-  assume-console [
-    left-click 1, 8
-    press enter
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .  abc     .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # line is indented
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 5
-  ]
-  # back to original text
-  screen-should-contain [
-    .          .
-    .  abc     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be at end of line
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  abc1    .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# redo typing
-
-scenario editor-redo-typing [
-  local-scope
-  # create an editor, type something, undo
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [a], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be back
-  screen-should-contain [
-    .          .
-    .012a      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0123a     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-redo> [
-  {
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    before-cursor <- get *editor, before-cursor:offset
-    insert-from:&:duplex-list:char <- get typing, insert-from:offset  # ignore insert-to because it's already been spliced away
-    # assert insert-to matches next(before-cursor)
-    splice before-cursor, insert-from
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get typing, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get typing, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get typing, after-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-redo-typing-empty [
-  local-scope
-  # create an editor, type something, undo
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be back
-  screen-should-contain [
-    .          .
-    .012       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0123      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-work-clears-redo-stack [
-  local-scope
-  # create an editor with some text, do some work, undo
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [1]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  # do some more work
-  assume-console [
-    type [0]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # nothing should happen
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-redo-typing-and-enter-and-tab [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and tabs, hit enter, some more text and tabs
-  assume-console [
-    press tab
-    type [ab]
-    press tab
-    type [cd]
-    press enter
-    press tab
-    type [efg]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .    efg   .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 7
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # typing in second line deleted, but not indent
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # indent and newline deleted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 8
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # empty screen
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 8
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # newline and indent inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # indent and newline deleted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 7
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .    efg   .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# undo cursor movement and scroll
-
-scenario editor-can-undo-touch [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # click undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-after <begin-move-cursor> [
-  cursor-row-before:num <- get *editor, cursor-row:offset
-  cursor-column-before:num <- get *editor, cursor-column:offset
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-move-cursor> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  {
-    break-unless undo-coalesce-tag
-    # if previous operation was also a move, and also had the same coalesce
-    # tag, coalesce with it
-    undo:&:list:&:operation <- get *editor, undo:offset
-    break-unless undo
-    op:&:operation <- first undo
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    previous-coalesce-tag:num <- get move, tag:offset
-    coalesce?:bool <- equal undo-coalesce-tag, previous-coalesce-tag
-    break-unless coalesce?
-    move <- put move, after-row:offset, cursor-row
-    move <- put move, after-column:offset, cursor-column
-    move <- put move, after-top-of-screen:offset, top-after
-    *op <- merge 1/move-operation, move
-    break +done-adding-move-operation
-  }
-  op:&:operation <- new operation:type
-  *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag
-  editor <- add-operation editor, op
-  +done-adding-move-operation
-]
-
-after <handle-undo> [
-  {
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get move, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get move, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get move, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-can-undo-scroll [
-  local-scope
-  # screen has 1 line for menu + 3 lines
-  assume-screen 5/width, 4/height
-  # editor contains a wrapped line
-  contents:text <- new [a
-b
-cdefgh]
-  e:&:editor <- new-editor contents, 0/left, 5/right
-  # position cursor at end of screen and try to move right
-  assume-console [
-    left-click 3, 3
-    press right-arrow
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  # screen scrolls
-  screen-should-contain [
-    .     .
-    .b    .
-    .cdef↩.
-    .gh   .
-  ]
-  memory-should-contain [
-    3 <- 3
-    4 <- 0
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moved back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 3
-  ]
-  # scroll undone
-  screen-should-contain [
-    .     .
-    .a    .
-    .b    .
-    .cdef↩.
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .     .
-    .b    .
-    .cde1↩.
-    .fgh  .
-  ]
-]
-
-scenario editor-can-undo-left-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-    press left-arrow
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-up-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-    press up-arrow
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-down-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 2, 1
-    press down-arrow
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-ctrl-f [
-  local-scope
-  # create an editor with multiple pages of text
-  assume-screen 10/width, 5/height
-  contents:text <- new [a
-b
-c
-d
-e
-f]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # scroll the page
-  assume-console [
-    press ctrl-f
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen should again show page 1
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-    .d         .
-  ]
-]
-
-scenario editor-can-undo-page-down [
-  local-scope
-  # create an editor with multiple pages of text
-  assume-screen 10/width, 5/height
-  contents:text <- new [a
-b
-c
-d
-e
-f]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # scroll the page
-  assume-console [
-    press page-down
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen should again show page 1
-  screen-should-contain [
-    .          .
-    .a         .
-    .b         .
-    .c         .
-    .d         .
-  ]
-]
-
-scenario editor-can-undo-ctrl-b [
-  local-scope
-  # create an editor with multiple pages of text
-  assume-screen 10/width, 5/height
-  contents:text <- new [a
-b
-c
-d
-e
-f]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # scroll the page down and up
-  assume-console [
-    press page-down
-    press ctrl-b
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen should again show page 2
-  screen-should-contain [
-    .          .
-    .d         .
-    .e         .
-    .f         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-page-up [
-  local-scope
-  # create an editor with multiple pages of text
-  assume-screen 10/width, 5/height
-  contents:text <- new [a
-b
-c
-d
-e
-f]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # scroll the page down and up
-  assume-console [
-    press page-down
-    press page-up
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen should again show page 2
-  screen-should-contain [
-    .          .
-    .d         .
-    .e         .
-    .f         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-ctrl-a [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press ctrl-a
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-home [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press home
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-ctrl-e [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press ctrl-e
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-end [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press end
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-multiple-arrows-in-the-same-direction [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 2, 1
-    press right-arrow
-    press right-arrow
-    press up-arrow
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # up-arrow is undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 3
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # both right-arrows are undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-]
-
-# redo cursor movement and scroll
-
-scenario editor-redo-touch [
-  local-scope
-  # create an editor with some text, click on a character, undo
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    left-click 3, 1
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves to left-click
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-after <handle-redo> [
-  {
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get move, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get move, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get move, after-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-separates-undo-insert-from-undo-cursor-move [
-  local-scope
-  # create an editor, type some text, move the cursor, type some more text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [abc]
-    left-click 1, 1
-    type [d]
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  screen-should-contain [
-    .          .
-    .adbc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # last letter typed is deleted
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # no change to screen; cursor moves
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen empty
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # first insert
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor moves
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # second insert
-  screen-should-contain [
-    .          .
-    .adbc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-]
-
-# undo backspace
-
-scenario editor-can-undo-and-redo-backspace [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit backspace
-  assume-console [
-    type [abc]
-    press backspace
-    press backspace
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# save operation to undo
-after <begin-backspace-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-backspace-character> [
-  {
-    break-unless backspaced-cell  # backspace failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-row:offset
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    undo:&:list:&:operation <- get *editor, undo:offset
-    {
-      # if previous operation was an insert, coalesce this operation with it
-      break-unless undo
-      op:&:operation <- first undo
-      deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-      break-unless is-delete?
-      previous-coalesce-tag:num <- get deletion, tag:offset
-      coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace
-      break-unless coalesce?
-      deletion <- put deletion, delete-from:offset, before-cursor
-      backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset
-      splice backspaced-cell, backspaced-so-far
-      deletion <- put deletion, deleted-text:offset, backspaced-cell
-      deletion <- put deletion, after-row:offset, cursor-row
-      deletion <- put deletion, after-column:offset, cursor-column
-      deletion <- put deletion, after-top-of-screen:offset, top-after
-      *op <- merge 2/delete-operation, deletion
-      break +done-adding-backspace-operation
-    }
-    # if not, create a new operation
-    op:&:operation <- new operation:type
-    deleted-until:&:duplex-list:char <- next before-cursor
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, 1/coalesce-backspace
-    editor <- add-operation editor, op
-    +done-adding-backspace-operation
-  }
-]
-
-after <handle-undo> [
-  {
-    deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-    break-unless is-delete?
-    anchor:&:duplex-list:char <- get deletion, delete-from:offset
-    break-unless anchor
-    deleted:&:duplex-list:char <- get deletion, deleted-text:offset
-    old-cursor:&:duplex-list:char <- last deleted
-    splice anchor, deleted
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    before-cursor <- copy old-cursor
-    cursor-row <- get deletion, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get deletion, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get deletion, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-after <handle-redo> [
-  {
-    deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-    break-unless is-delete?
-    start:&:duplex-list:char <- get deletion, delete-from:offset
-    end:&:duplex-list:char <- get deletion, delete-until:offset
-    data:&:duplex-list:char <- get *editor, data:offset
-    remove-between start, end
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get deletion, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get deletion, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get deletion, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-# undo delete
-
-scenario editor-can-undo-and-redo-delete [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    type [abcdef]
-    left-click 1, 2
-    press delete
-    press backspace
-    press delete
-    press delete
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .af        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo deletes
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .adef      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo backspace
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abdef     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo first delete
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abcdef    .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo first delete
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abdef     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo backspace
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .adef      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo deletes
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .af        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-character> [
-  {
-    break-unless deleted-cell  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    undo:&:list:&:operation <- get *editor, undo:offset
-    {
-      # if previous operation was an insert, coalesce this operation with it
-      break-unless undo
-      op:&:operation <- first undo
-      deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-      break-unless is-delete?
-      previous-coalesce-tag:num <- get deletion, tag:offset
-      coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete
-      break-unless coalesce?
-      delete-until:&:duplex-list:char <- next before-cursor
-      deletion <- put deletion, delete-until:offset, delete-until
-      deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset
-      deleted-so-far <- append deleted-so-far, deleted-cell
-      deletion <- put deletion, deleted-text:offset, deleted-so-far
-      deletion <- put deletion, after-row:offset, cursor-row
-      deletion <- put deletion, after-column:offset, cursor-column
-      deletion <- put deletion, after-top-of-screen:offset, top-after
-      *op <- merge 2/delete-operation, deletion
-      break +done-adding-delete-operation
-    }
-    # if not, create a new operation
-    op:&:operation <- new operation:type
-    deleted-until:&:duplex-list:char <- next before-cursor
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, 2/coalesce-delete
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-# undo ctrl-k
-
-scenario editor-can-undo-and-redo-ctrl-k [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    left-click 1, 1
-    press ctrl-k
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  screen-should-contain [
-    .          .
-    .a         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a1        .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-to-end-of-line> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-to-end-of-line> [
-  {
-    break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    deleted-until:&:duplex-list:char <- next before-cursor
-    op:&:operation <- new operation:type
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-# undo ctrl-u
-
-scenario editor-can-undo-and-redo-ctrl-u [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    left-click 1, 2
-    press ctrl-u
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .c         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  screen-should-contain [
-    .          .
-    .c         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1c        .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-to-start-of-line> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-to-start-of-line> [
-  {
-    break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    op:&:operation <- new operation:type
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    deleted-until:&:duplex-list:char <- next before-cursor
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-scenario editor-can-undo-and-redo-ctrl-u-2 [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    type [abc]
-    press ctrl-u
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
diff --git a/archive/2.vm/edit/Readme.md b/archive/2.vm/edit/Readme.md
deleted file mode 100644
index 698e534b..00000000
--- a/archive/2.vm/edit/Readme.md
+++ /dev/null
@@ -1,49 +0,0 @@
-Environment for learning programming using Mu: http://akkartik.name/post/mu
-
-Run it from the `mu` directory:
-
-  ```shell
-  $ ./mu edit
-  ```
-
-This will load all the `.mu` files in this directory and then run the editor.
-Press ctrl-c to quit. Press F4 to save your work (if a lesson/ directory
-exists) and to run the contents of the sandbox editor on the right.
-
-You can also run the tests for the environment:
-
-  ```shell
-  $ ./mu test edit
-  ```
-
-You can also load the files more explicitly by enumerating them all (in order):
-
-  ```shell
-  $  ./mu edit/*.mu
-  ```
-
-This is handy if you want to play with simpler versions of the editor that are
-easier to understand. Stop loading at any layer to run with a subset of
-features:
-
-  ```shell
-  $ ./mu edit/001*.mu edit/002*.mu  # run a simple editor rather than the full environment
-  ```
-
----
-
-Appendix: keyboard shortcuts
-
-  _moving and scrolling_
-  - `ctrl-a` or `home`: move cursor to start of line
-  - `ctrl-e` or `end`: move cursor to end of line
-  - `ctrl-f` or `page-down`: scroll down by one page
-  - `ctrl-b` or `page-up`: scroll up by one page
-  - `ctrl-x`: scroll down by one line
-  - `ctrl-s`: scroll up by one line
-  - `ctrl-t`: scroll until current line is at top of screen
-
-  _modifying text_
-  - `ctrl-k`: delete text from cursor to end of line
-  - `ctrl-u`: delete text from start of line until just before cursor
-  - `ctrl-/`: comment/uncomment current line (using a special leader to ignore real comments https://www.reddit.com/r/vim/comments/4ootmz/_/d4ehmql)
diff --git a/archive/2.vm/example1.mu b/archive/2.vm/example1.mu
deleted file mode 100644
index 83995a1e..00000000
--- a/archive/2.vm/example1.mu
+++ /dev/null
@@ -1,7 +0,0 @@
-def main [
-  local-scope
-  a:num <- add 2, 2
-  a <- multiply a, 3
-  # uncomment the next line to see the output
-# $print a
-]
diff --git a/archive/2.vm/exception1.mu b/archive/2.vm/exception1.mu
deleted file mode 100644
index df4754e5..00000000
--- a/archive/2.vm/exception1.mu
+++ /dev/null
@@ -1,61 +0,0 @@
-# Example program showing exceptions built out of delimited continuations.
-
-# Since Mu is statically typed, we can't build an all-purpose higher-order
-# function called 'try'; it wouldn't know how many arguments the function
-# passed to it needs to take, what their types are, etc. Instead, until Mu
-# gets macros we'll directly use the continuation primitives.
-
-def main [
-  local-scope
-  foo false/no-exception
-  foo true/raise-exception
-]
-
-# example showing exception handling
-def foo raise-exception?:bool [
-  local-scope
-  load-inputs
-  # To run an instruction of the form:
-  #   try f ...
-  # write this:
-  #   call-with-continuation-mark 999/exception-tag, f, ...
-  # By convention we reserve tag 999 for exceptions.
-  #
-  # 'f' above may terminate at either a regular 'return' or a 'return-with-continuation-mark'.
-  # We never re-call the continuation returned in the latter case;
-  # its existence merely signals that an exception was raised.
-  # So just treat it as a boolean.
-  # The other inputs and outputs to 'call-with-continuation-mark' depend on
-  # the function it is called with.
-  exception-raised?:bool, err:text, result:num <- call-with-continuation-mark 999/exception-tag, f, raise-exception?
-  {
-    break-if exception-raised?
-    $print [normal exit; result ] result 10/newline
-  }
-  {
-    break-unless exception-raised?
-    $print [error caught: ] err 10/newline
-  }
-]
-
-# A callee function that can raise an exception has some weird constraints at
-# the moment.
-#
-# The caller's 'call-with-continuation-mark' instruction may return with
-# either a regular 'return' or a 'return-continuation-until-mark'.
-# To handle both cases, regular 'return' instructions in the callee must
-# prepend an extra 0 result, in place of the continuation that may have been
-# returned.
-# This change to number of outputs violates our type system, so the call has
-# to be dynamically typed. The callee can't have a header.
-def f [
-  local-scope
-  raise-exception?:bool <- next-input
-  {
-    break-unless raise-exception?
-    # throw/raise: 2 results + implicit continuation (ignoring the continuation tag)
-    return-continuation-until-mark 999/exception-tag, [error will robinson!], 0/unused
-  }
-  # normal return: 3 results including 0 continuation placeholder at start
-  return 0/continuation-placeholder, null/no-error, 34/regular-result
-]
diff --git a/archive/2.vm/exception2.mu b/archive/2.vm/exception2.mu
deleted file mode 100644
index f07c135b..00000000
--- a/archive/2.vm/exception2.mu
+++ /dev/null
@@ -1,62 +0,0 @@
-# Example program showing exceptions built out of delimited continuations.
-# Slightly less klunky than exception1.mu.
-
-# Since Mu is statically typed, we can't build an all-purpose higher-order
-# function called 'try'; it wouldn't know how many arguments the function
-# passed to it needs to take, what their types are, etc. Instead, until Mu
-# gets macros we'll directly use the continuation primitives.
-
-exclusive-container error-or:_elem [
-  error:text
-  value:_elem
-]
-
-def main [
-  local-scope
-  foo false/no-exception
-  foo true/raise-exception
-]
-
-# example showing exception handling
-def foo raise-exception?:bool [
-  local-scope
-  load-inputs
-  # To run an instruction of the form:
-  #   try f ...
-  # write this:
-  #   call-with-continuation-mark 999/exception-tag, f, ...
-  # By convention we reserve tag 999 for exceptions.
-  #
-  # The other inputs and outputs to 'call-with-continuation-mark' depend on
-  # the function it is called with.
-  _, result:error-or:num <- call-with-continuation-mark 999/exception-tag, f, raise-exception?
-  {
-    val:num, normal-exit?:bool <- maybe-convert result, value:variant
-    break-unless normal-exit?
-    $print [normal exit; result ] val 10/newline
-  }
-  {
-    err:text, error-exit?:bool <- maybe-convert result, error:variant
-    break-unless error-exit?
-    $print [error caught: ] err 10/newline
-  }
-]
-
-# Callee function that we catch exceptions in must always return using a
-# continuation.
-def f raise-exception?:bool -> result:error-or:num [
-  local-scope
-  load-inputs
-  {
-    break-unless raise-exception?
-    # throw/raise
-    result <- merge 0/error, [error will robinson!]
-    return-continuation-until-mark 999/exception-tag, result
-  }
-  # 'normal' return; still uses the continuation mark
-  result <- merge 1/value, 34
-  return-continuation-until-mark 999/exception-tag, result
-  # dead code just to avoid errors
-  result <- merge 1/value, 0
-  return result
-]
diff --git a/archive/2.vm/exuberant_ctags_rc b/archive/2.vm/exuberant_ctags_rc
deleted file mode 100644
index 46823a2e..00000000
--- a/archive/2.vm/exuberant_ctags_rc
+++ /dev/null
@@ -1,11 +0,0 @@
---langdef=mu
---langmap=mu:.mu
---regex-mu=/^def[ \t]+([^ \t]*)/\1/d,definition/
---regex-mu=/^def![ \t]+([^ \t]*)/\1/d,definition/
---regex-mu=/^recipe[ \t]+([^ \t]*)/\1/d,definition/
---regex-mu=/^recipe![ \t]+([^ \t]*)/\1/d,definition/
---regex-mu=/^type[ \t]+([^ \t]*)/\1/t,typeref/
---regex-mu=/^container[ \t]+([^ \t:]*)/\1/s,struct/
---regex-mu=/^exclusive-container[ \t]+([^ \t:]*)/\1/u,union/
---regex-mu=/$x/x/x/e/ --------- next option is for way-points in Mu
---regex-mu=/^[ \t]*(<[^ \t]*>)/\1/d,definition/
diff --git a/archive/2.vm/factorial.mu b/archive/2.vm/factorial.mu
deleted file mode 100644
index cf2284b2..00000000
--- a/archive/2.vm/factorial.mu
+++ /dev/null
@@ -1,33 +0,0 @@
-# example program: compute the factorial of 5
-
-def main [
-  local-scope
-  x:num <- factorial 5
-  $print [result: ], x, [ 
-]
-]
-
-def factorial n:num -> result:num [
-  local-scope
-  load-inputs
-  {
-    # if n=0 return 1
-    zero?:bool <- equal n, 0
-    break-unless zero?
-    return 1
-  }
-  # return n * factorial(n-1)
-  x:num <- subtract n, 1
-  subresult:num <- factorial x
-  result <- multiply subresult, n
-]
-
-# unit test
-scenario factorial-test [
-  run [
-    1:num <- factorial 5
-  ]
-  memory-should-contain [
-    1 <- 120
-  ]
-]
diff --git a/archive/2.vm/filesystem.mu b/archive/2.vm/filesystem.mu
deleted file mode 100644
index 6ea8e08c..00000000
--- a/archive/2.vm/filesystem.mu
+++ /dev/null
@@ -1,20 +0,0 @@
-# example program: copy one file into another, character by character
-# BEWARE: this will modify your file system
-# before running it, put some text into /tmp/mu-x
-# after running it, check /tmp/mu-y
-
-def main [
-  local-scope
-  source-file:&:source:char <- start-reading null/real-filesystem, [/tmp/mu-x]
-  sink-file:&:sink:char, write-routine:num <- start-writing null/real-filesystem, [/tmp/mu-y]
-  {
-    c:char, done?:bool, source-file <- read source-file
-    break-if done?
-    sink-file <- write sink-file, c
-    loop
-  }
-  close sink-file
-  # make sure to wait for the file to be actually written to disk
-  # (Mu practices structured concurrency: http://250bpm.com/blog:71)
-  wait-for-routine write-routine
-]
diff --git a/archive/2.vm/fork.mu b/archive/2.vm/fork.mu
deleted file mode 100644
index af414cf2..00000000
--- a/archive/2.vm/fork.mu
+++ /dev/null
@@ -1,16 +0,0 @@
-# example program: running multiple routines
-
-def main [
-  start-running thread2
-  {
-    $print 34
-    loop
-  }
-]
-
-def thread2 [
-  {
-    $print 35
-    loop
-  }
-]
diff --git a/archive/2.vm/git_log_filtered b/archive/2.vm/git_log_filtered
deleted file mode 100755
index 7ab6d43e..00000000
--- a/archive/2.vm/git_log_filtered
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-# Show the log while skipping unimportant directories.
-#
-# I usually run this through an alias local to this repo:
-#   $ git config alias.ll '!./git_log_filtered'
-#   $ git ll --stat
-set -e
-
-git log $* -- . ":(exclude)html"
diff --git a/archive/2.vm/http-client.mu b/archive/2.vm/http-client.mu
deleted file mode 100644
index 8f04c2bc..00000000
--- a/archive/2.vm/http-client.mu
+++ /dev/null
@@ -1,29 +0,0 @@
-# example program: reading a URL over HTTP
-
-def main [
-  local-scope
-  $print [aaa] 10/newline
-  google:&:source:char <- start-reading-from-network null/real-resources, [google.com/]
-  $print [bbb] 10/newline
-  n:num <- copy 0
-  buf:&:buffer:char <- new-buffer 30
-  {
-    c:char, done?:bool <- read google
-    break-if done?
-    n <- add n, 1
-    buf <- append buf, c
-    {
-      _, a:num <- divide-with-remainder n, 100
-      break-if a
-      $print n 10/newline
-    }
-    loop
-  }
-  result:text <- buffer-to-array buf
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  len:num <- length *result
-  print null/real-screen, result
-  wait-for-some-interaction
-  close-console
-]
diff --git a/archive/2.vm/http-server.mu b/archive/2.vm/http-server.mu
deleted file mode 100644
index 6bd172b3..00000000
--- a/archive/2.vm/http-server.mu
+++ /dev/null
@@ -1,28 +0,0 @@
-# example program: a single-request HTTP server
-#   listen for connections from clients on a server socket
-#   when a connection occurs, transfer it to a session socket
-#   read from it using channels
-#   write to it directly
-#
-# After running it, navigate to localhost:8080. Your browser should display
-# "SUCCESS!" and the server will terminate after one connection.
-
-def main [
-  local-scope
-  socket:num <- $open-server-socket 8080/port
-  $print [Mu socket creation returned ], socket, 10/newline
-  return-unless socket
-  session:num <- $accept socket
-  contents:&:source:char, sink:&:sink:char <- new-channel 30
-  sink <- start-running receive-from-socket session, sink
-  query:text <- drain contents
-  $print [Done reading from socket.], 10/newline
-  write-to-socket session, [HTTP/1.0 200 OK
-Content-type: text/plain
-
-SUCCESS!
-]
-  $print 10/newline, [Wrote to and closing socket...], 10/newline
-  session <- $close-socket session
-  socket <- $close-socket socket
-]
diff --git a/archive/2.vm/immutable-error.mu b/archive/2.vm/immutable-error.mu
deleted file mode 100644
index 25554b2f..00000000
--- a/archive/2.vm/immutable-error.mu
+++ /dev/null
@@ -1,13 +0,0 @@
-# compare mutable.mu
-
-def main [
-  local-scope
-  x:&:num <- new number:type
-  foo x
-]
-
-def foo x:&:num [
-  local-scope
-  load-inputs
-  *x <- copy 34  # will cause an error because x is immutable in this function
-]
diff --git a/archive/2.vm/lambda-to-mu.mu b/archive/2.vm/lambda-to-mu.mu
deleted file mode 100644
index a171b4ca..00000000
--- a/archive/2.vm/lambda-to-mu.mu
+++ /dev/null
@@ -1,590 +0,0 @@
-## experimental compiler to translate programs written in a generic
-## expression-oriented language called 'lambda' into Mu
-
-# incomplete; code generator not done
-# potential enhancements:
-#   symbol table
-#   poor man's macros
-#     substitute one instruction with multiple, parameterized by inputs and products
-
-scenario convert-lambda [
-  run [
-    local-scope
-    1:text/raw <- lambda-to-mu [(add a (multiply b c))]
-    2:@:char/raw <- copy *1:text/raw
-  ]
-  memory-should-contain [
-    2:array:character <- [t1 <- multiply b c
-result <- add a t1]
-  ]
-]
-
-def lambda-to-mu in:text -> out:text [
-  local-scope
-  load-inputs
-  out <- copy null
-  cells:&:cell <- parse in
-  out <- to-mu cells
-]
-
-# 'parse' will turn lambda expressions into trees made of cells
-exclusive-container cell [
-  atom:text
-  pair:pair
-]
-
-# printed below as < first | rest >
-container pair [
-  first:&:cell
-  rest:&:cell
-]
-
-def new-atom name:text -> result:&:cell [
-  local-scope
-  load-inputs
-  result <- new cell:type
-  *result <- merge 0/tag:atom, name
-]
-
-def new-pair a:&:cell, b:&:cell -> result:&:cell [
-  local-scope
-  load-inputs
-  result <- new cell:type
-  *result <- merge 1/tag:pair, a/first, b/rest
-]
-
-def is-atom? x:&:cell -> result:bool [
-  local-scope
-  load-inputs
-  return-unless x, false
-  _, result <- maybe-convert *x, atom:variant
-]
-
-def is-pair? x:&:cell -> result:bool [
-  local-scope
-  load-inputs
-  return-unless x, false
-  _, result <- maybe-convert *x, pair:variant
-]
-
-scenario atom-is-not-pair [
-  local-scope
-  s:text <- new [a]
-  x:&:cell <- new-atom s
-  10:bool/raw <- is-atom? x
-  11:bool/raw <- is-pair? x
-  memory-should-contain [
-    10 <- 1
-    11 <- 0
-  ]
-]
-
-scenario pair-is-not-atom [
-  local-scope
-  # construct (a . nil)
-  s:text <- new [a]
-  x:&:cell <- new-atom s
-  y:&:cell <- new-pair x, null
-  10:bool/raw <- is-atom? y
-  11:bool/raw <- is-pair? y
-  memory-should-contain [
-    10 <- 0
-    11 <- 1
-  ]
-]
-
-def atom-match? x:&:cell, pat:text -> result:bool [
-  local-scope
-  load-inputs
-  s:text, is-atom?:bool <- maybe-convert *x, atom:variant
-  return-unless is-atom?, false
-  result <- equal pat, s
-]
-
-scenario atom-match [
-  local-scope
-  x:&:cell <- new-atom [abc]
-  10:bool/raw <- atom-match? x, [abc]
-  memory-should-contain [
-    10 <- 1
-  ]
-]
-
-def first x:&:cell -> result:&:cell [
-  local-scope
-  load-inputs
-  pair:pair, pair?:bool <- maybe-convert *x, pair:variant
-  return-unless pair?, null
-  result <- get pair, first:offset
-]
-
-def rest x:&:cell -> result:&:cell [
-  local-scope
-  load-inputs
-  pair:pair, pair?:bool <- maybe-convert *x, pair:variant
-  return-unless pair?, null
-  result <- get pair, rest:offset
-]
-
-def set-first base:&:cell, new-first:&:cell -> base:&:cell [
-  local-scope
-  load-inputs
-  pair:pair, is-pair?:bool <- maybe-convert *base, pair:variant
-  return-unless is-pair?
-  pair <- put pair, first:offset, new-first
-  *base <- merge 1/pair, pair
-]
-
-def set-rest base:&:cell, new-rest:&:cell -> base:&:cell [
-  local-scope
-  load-inputs
-  pair:pair, is-pair?:bool <- maybe-convert *base, pair:variant
-  return-unless is-pair?
-  pair <- put pair, rest:offset, new-rest
-  *base <- merge 1/pair, pair
-]
-
-scenario cell-operations-on-atom [
-  local-scope
-  s:text <- new [a]
-  x:&:cell <- new-atom s
-  10:&:cell/raw <- first x
-  11:&:cell/raw <- rest x
-  memory-should-contain [
-    10 <- 0  # first is nil
-    11 <- 0  # rest is nil
-  ]
-]
-
-scenario cell-operations-on-pair [
-  local-scope
-  # construct (a . nil)
-  s:text <- new [a]
-  x:&:cell <- new-atom s
-  y:&:cell <- new-pair x, null
-  x2:&:cell <- first y
-  10:bool/raw <- equal x, x2
-  11:&:cell/raw <- rest y
-  memory-should-contain [
-    10 <- 1  # first is correct
-    11 <- 0  # rest is nil
-  ]
-]
-
-## convert lambda text to a tree of cells
-
-def parse in:text -> out:&:cell [
-  local-scope
-  load-inputs
-  s:&:stream:char <- new-stream in
-  out, s <- parse s
-  trace 2, [app/parse], out
-]
-
-def parse in:&:stream:char -> out:&:cell, in:&:stream:char [
-  local-scope
-  load-inputs
-  # skip whitespace
-  in <- skip-whitespace in
-  c:char, eof?:bool <- peek in
-  return-if eof?, null
-  pair?:bool <- equal c, 40/open-paren
-  {
-    break-if pair?
-    # atom
-    buf:&:buffer:char <- new-buffer 30
-    {
-      done?:bool <- end-of-stream? in
-      break-if done?
-      # stop before close paren or space
-      c:char <- peek in
-      done? <- equal c, 41/close-paren
-      break-if done?
-      done? <- space? c
-      break-if done?
-      c <- read in
-      buf <- append buf, c
-      loop
-    }
-    s:text <- buffer-to-array buf
-    out <- new-atom s
-  }
-  {
-    break-unless pair?
-    # pair
-    read in  # skip the open-paren
-    out <- new cell:type  # start out with nil
-    # read in first element of pair
-    {
-      end?:bool <- end-of-stream? in
-      not-end?:bool <- not end?
-      assert not-end?, [unbalanced '(' in expression]
-      c <- peek in
-      close-paren?:bool <- equal c, 41/close-paren
-      break-if close-paren?
-      first:&:cell, in <- parse in
-      *out <- merge 1/pair, first, null
-    }
-    # read in any remaining elements
-    curr:&:cell <- copy out
-    {
-      in <- skip-whitespace in
-      end?:bool <- end-of-stream? in
-      not-end?:bool <- not end?
-      assert not-end?, [unbalanced '(' in expression]
-      # termination check: ')'
-      c <- peek in
-      {
-        close-paren?:bool <- equal c, 41/close-paren
-        break-unless close-paren?
-        read in  # skip ')'
-        break +end-pair
-      }
-      # still here? read next element of pair
-      next:&:cell, in <- parse in
-      is-dot?:bool <- atom-match? next, [.]
-      {
-        break-if is-dot?
-        next-curr:&:cell <- new-pair next, null
-        curr <- set-rest curr, next-curr
-        curr <- rest curr
-      }
-      {
-        break-unless is-dot?
-        # deal with dotted pair
-        in <- skip-whitespace in
-        c <- peek in
-        not-close-paren?:bool <- not-equal c, 41/close-paren
-        assert not-close-paren?, [')' cannot immediately follow '.']
-        final:&:cell <- parse in
-        curr <- set-rest curr, final
-        # we're not gonna update curr, so better make sure the next iteration
-        # is going to end the pair
-        in <- skip-whitespace in
-        c <- peek in
-        close-paren?:bool <- equal c, 41/close-paren
-        assert close-paren?, ['.' must be followed by exactly one expression before ')']
-      }
-      loop
-    }
-    +end-pair
-  }
-]
-
-def skip-whitespace in:&:stream:char -> in:&:stream:char [
-  local-scope
-  load-inputs
-  {
-    done?:bool <- end-of-stream? in
-    return-if done?, null
-    c:char <- peek in
-    space?:bool <- space? c
-    break-unless space?
-    read in  # skip
-    loop
-  }
-]
-
-def to-text x:&:cell -> out:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 30
-  buf <- to-buffer x, buf
-  out <- buffer-to-array buf
-]
-
-def to-buffer x:&:cell, buf:&:buffer:char -> buf:&:buffer:char [
-  local-scope
-  load-inputs
-  # base case: empty cell
-  {
-    break-if x
-    buf <- append buf, [<>]
-    return
-  }
-  # base case: atom
-  {
-    s:text, atom?:bool <- maybe-convert *x, atom:variant
-    break-unless atom?
-    buf <- append buf, s
-    return
-  }
-  # recursive case: pair
-  buf <- append buf, [< ]
-  first:&:cell <- first x
-  buf <- to-buffer first, buf
-  buf <- append buf, [ | ]
-  rest:&:cell <- rest x
-  buf <- to-buffer rest, buf
-  buf <- append buf, [ >]
-]
-
-scenario parse-single-letter-atom [
-  local-scope
-  s:text <- new [a]
-  x:&:cell <- parse s
-  s2:text, 10:bool/raw <- maybe-convert *x, atom:variant
-  11:@:char/raw <- copy *s2
-  memory-should-contain [
-    10 <- 1  # parse result is an atom
-    11:array:character <- [a]
-  ]
-]
-
-scenario parse-atom [
-  local-scope
-  s:text <- new [abc]
-  x:&:cell <- parse s
-  s2:text, 10:bool/raw <- maybe-convert *x, atom:variant
-  11:@:char/raw <- copy *s2
-  memory-should-contain [
-    10 <- 1  # parse result is an atom
-    11:array:character <- [abc]
-  ]
-]
-
-scenario parse-list-of-two-atoms [
-  local-scope
-  s:text <- new [(abc def)]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < abc | < def | <> > >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  x2:&:cell <- rest x
-  s1:text, 11:bool/raw <- maybe-convert *x1, atom:variant
-  12:bool/raw <- is-pair? x2
-  x3:&:cell <- first x2
-  s2:text, 13:bool/raw <- maybe-convert *x3, atom:variant
-  14:&:cell/raw <- rest x2
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is an atom
-    12 <- 1  # result.rest is a pair
-    13 <- 1  # result.rest.first is an atom
-    14 <- 0  # result.rest.rest is nil
-    20:array:character <- [abc]  # result.first
-    30:array:character <- [def]  # result.rest.first
-  ]
-]
-
-scenario parse-list-with-extra-spaces [
-  local-scope
-  s:text <- new [ ( abc  def ) ]  # extra spaces
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < abc | < def | <> > >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  x2:&:cell <- rest x
-  s1:text, 11:bool/raw <- maybe-convert *x1, atom:variant
-  12:bool/raw <- is-pair? x2
-  x3:&:cell <- first x2
-  s2:text, 13:bool/raw <- maybe-convert *x3, atom:variant
-  14:&:cell/raw <- rest x2
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is an atom
-    12 <- 1  # result.rest is a pair
-    13 <- 1  # result.rest.first is an atom
-    14 <- 0  # result.rest.rest is nil
-    20:array:character <- [abc]  # result.first
-    30:array:character <- [def]  # result.rest.first
-  ]
-]
-
-scenario parse-list-of-more-than-two-atoms [
-  local-scope
-  s:text <- new [(abc def ghi)]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < abc | < def | < ghi | <> > > >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  x2:&:cell <- rest x
-  s1:text, 11:bool/raw <- maybe-convert *x1, atom:variant
-  12:bool/raw <- is-pair? x2
-  x3:&:cell <- first x2
-  s2:text, 13:bool/raw <- maybe-convert *x3, atom:variant
-  x4:&:cell <- rest x2
-  14:bool/raw <- is-pair? x4
-  x5:&:cell <- first x4
-  s3:text, 15:bool/raw <- maybe-convert *x5, atom:variant
-  16:&:cell/raw <- rest x4
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  40:@:char/raw <- copy *s3
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is an atom
-    12 <- 1  # result.rest is a pair
-    13 <- 1  # result.rest.first is an atom
-    14 <- 1  # result.rest.rest is a pair
-    15 <- 1  # result.rest.rest.first is an atom
-    16 <- 0  # result.rest.rest.rest is nil
-    20:array:character <- [abc]  # result.first
-    30:array:character <- [def]  # result.rest.first
-    40:array:character <- [ghi]  # result.rest.rest
-  ]
-]
-
-scenario parse-nested-list [
-  local-scope
-  s:text <- new [((abc))]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < < abc | <> > | <> >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  11:bool/raw <- is-pair? x
-  x2:&:cell <- first x1
-  s1:text, 12:bool/raw <- maybe-convert *x2, atom:variant
-  13:&:cell/raw <- rest x1
-  14:&:cell/raw <- rest x
-  20:@:char/raw <- copy *s1
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is a pair
-    12 <- 1  # result.first.first is an atom
-    13 <- 0  # result.first.rest is nil
-    14 <- 0  # result.rest is nil
-    20:array:character <- [abc]  # result.first.first
-  ]
-]
-
-scenario parse-nested-list-2 [
-  local-scope
-  s:text <- new [((abc) def)]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < < abc | <> > | < def | <> > >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  11:bool/raw <- is-pair? x
-  x2:&:cell <- first x1
-  s1:text, 12:bool/raw <- maybe-convert *x2, atom:variant
-  13:&:cell/raw <- rest x1
-  x3:&:cell <- rest x
-  x4:&:cell <- first x3
-  s2:text, 14:bool/raw <- maybe-convert *x4, atom:variant
-  15:&:cell/raw <- rest x3
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is a pair
-    12 <- 1  # result.first.first is an atom
-    13 <- 0  # result.first.rest is nil
-    14 <- 1  # result.rest.first is an atom
-    15 <- 0  # result.rest.rest is nil
-    20:array:character <- [abc]  # result.first.first
-    30:array:character <- [def]  # result.rest.first
-  ]
-]
-
-# todo: uncomment these tests after we figure out how to continue tests after
-# assertion failures
-#? scenario parse-error [
-#?   local-scope
-#?   s:text <- new [(]
-#? #?   hide-errors
-#?   x:&:cell <- parse s
-#? #?   show-errors
-#?   trace-should-contain [
-#?     error: unbalanced '(' in expression
-#?   ]
-#? ]
-#? 
-#? scenario parse-error-after-element [
-#?   local-scope
-#?   s:text <- new [(abc]
-#? #?   hide-errors
-#?   x:&:cell <- parse s
-#? #?   show-errors
-#?   trace-should-contain [
-#?     error: unbalanced '(' in expression
-#?   ]
-#? ]
-
-scenario parse-dotted-list-of-two-atoms [
-  local-scope
-  s:text <- new [(abc . def)]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < abc | def >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  x2:&:cell <- rest x
-  s1:text, 11:bool/raw <- maybe-convert *x1, atom:variant
-  s2:text, 12:bool/raw <- maybe-convert *x2, atom:variant
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  memory-should-contain [
-    # parses to < abc | def >
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is an atom
-    12 <- 1  # result.rest is an atom
-    20:array:character <- [abc]  # result.first
-    30:array:character <- [def]  # result.rest
-  ]
-]
-
-scenario parse-dotted-list-of-more-than-two-atoms [
-  local-scope
-  s:text <- new [(abc def . ghi)]
-  x:&:cell <- parse s
-  trace-should-contain [
-    app/parse: < abc | < def | ghi > >
-  ]
-  10:bool/raw <- is-pair? x
-  x1:&:cell <- first x
-  x2:&:cell <- rest x
-  s1:text, 11:bool/raw <- maybe-convert *x1, atom:variant
-  12:bool/raw <- is-pair? x2
-  x3:&:cell <- first x2
-  s2:text, 13:bool/raw <- maybe-convert *x3, atom:variant
-  x4:&:cell <- rest x2
-  s3:text, 14:bool/raw <- maybe-convert *x4, atom:variant
-  20:@:char/raw <- copy *s1
-  30:@:char/raw <- copy *s2
-  40:@:char/raw <- copy *s3
-  memory-should-contain [
-    10 <- 1  # parse result is a pair
-    11 <- 1  # result.first is an atom
-    12 <- 1  # result.rest is a pair
-    13 <- 1  # result.rest.first is an atom
-    14 <- 1  # result.rest.rest is an atom
-    20:array:character <- [abc]  # result.first
-    30:array:character <- [def]  # result.rest.first
-    40:array:character <- [ghi]  # result.rest.rest
-  ]
-]
-
-## convert tree of cells to Mu text
-
-def to-mu in:&:cell -> out:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 30
-  buf <- to-mu in, buf
-  out <- buffer-to-array buf
-]
-
-def to-mu in:&:cell, buf:&:buffer:char -> buf:&:buffer:char, result-name:text [
-  local-scope
-  load-inputs
-  # null cell? no change.
-  # pair with all atoms? gensym a new variable
-  # pair containing other pairs? recurse
-  result-name <- copy null
-]
diff --git a/archive/2.vm/mu b/archive/2.vm/mu
deleted file mode 100755
index 67068ebb..00000000
--- a/archive/2.vm/mu
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-# Run interpreter, first compiling if necessary.
-set -e
-
-./build3  &&  ./mu_bin "$@"
-
-# Scenarios considered:
-#   ./mu
-#   ./mu --help
-#   ./mu test
-#   ./mu test file1.mu
diff --git a/archive/2.vm/mu.vim b/archive/2.vm/mu.vim
deleted file mode 100644
index dd0763a7..00000000
--- a/archive/2.vm/mu.vim
+++ /dev/null
@@ -1,98 +0,0 @@
-" Vim syntax file
-" Language:    mu
-" Maintainer:  Kartik Agaram <mu@akkartik.com>
-" URL:         http://github.com/akkartik/mu
-" License:     public domain
-"
-" Copy this into your ftplugin directory, and add the following to your vimrc
-" or to .vim/ftdetect/mu.vim:
-"   autocmd BufReadPost,BufNewFile *.mu set filetype=mu
-
-let s:save_cpo = &cpo
-set cpo&vim
-
-" todo: why does this periodically lose syntax, like on file reload?
-"   $ vim x.mu
-"   :e
-"? if exists("b:syntax")
-"?   finish
-"? endif
-"? let b:syntax = "mu"
-
-setlocal iskeyword=@,48-57,?,!,_,$,-
-setlocal formatoptions-=t  " Mu programs have long lines
-setlocal formatoptions+=c  " but comments should still wrap
-
-syntax match muComment /#.*$/  | highlight link muComment Comment
-syntax match muSalientComment /##.*$/  | highlight link muSalientComment SalientComment
-syntax match muComment /;.*$/  | highlight link muComment Comment
-syntax match muSalientComment /;;.*$/  | highlight link muSalientComment SalientComment
-set comments+=n:#
-syntax match muCommentedCode "#? .*"  | highlight link muCommentedCode CommentedCode
-let b:cmt_head = "#? "
-
-syntax match muDelimiter "[{}]"  | highlight link muDelimiter Delimiter
-
-" Mu strings are inside [ ... ] and can span multiple lines
-" don't match '[' at end of line, that's usually code
-syntax match muLiteral %^[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*\|[ ,]\@<=[^ a-zA-Z0-9(){}\[\]#$_*@&,=-][^ ,]*%
-syntax region muString start=+\[[^\]]+ end=+\]+
-syntax match muString "\[\]"
-highlight link muString String
-" Mu syntax for representing the screen in scenarios
-syntax region muScreen start=+ \.+ end=+\.$\|$+
-highlight link muScreen muString
-
-" Mu literals
-syntax match muLiteral %[^ ]\+:literal/[^ ,]*\|[^ ]\+:literal\>%
-syntax match muLiteral %\<[0-9-]\?[0-9]\+/[^ ,]*%
-syntax match muLiteral % [0-9-]\?[0-9]\+[, ]\@=\| [0-9-]\?[0-9]\+$%
-syntax match muLiteral "^\s\+[^ 0-9a-zA-Z{}$#\[\]][^ ]*\s*$"
-" labels
-syntax match muLiteral %[^ ]\+:label/[^ ,]*\|[^ ]\+:label\>%
-" other literal types
-syntax match muLiteral %[^ ]\+:type/[^ ,]*\|[^ ]\+:type\>%
-syntax match muLiteral %[^ ]\+:offset/[^ ,]*\|[^ ]\+:offset\>%
-syntax match muLiteral %[^ ]\+:variant/[^ ,]*\|[^ ]\+:variant\>%
-syntax match muLiteral % true\(\/[^ ]*\)\?\| false\(\/[^ ]*\)\?%  " literals will never be the first word in an instruction
-syntax match muLiteral % null\(\/[^ ]*\)\?%
-highlight link muLiteral Constant
-
-" sources of action at a distance
-syntax match muAssign "<-"
-syntax match muAssign "\<raw\>"
-highlight link muAssign SpecialChar
-syntax match muGlobal %[^ ]\+:global/\?[^ ,]*%  | highlight link muGlobal SpecialChar
-
-" common keywords
-" use regular expressions for common words that may come after '/'
-syntax keyword muKeyword default-space local-scope
-syntax keyword muKeyword next-input rewind-inputs load-inputs
-syntax keyword muKeyword next-ingredient rewind-ingredients load-ingredients
-syntax match muKeyword " input\>\| ingredient\>"
-highlight link muKeyword Constant
-
-syntax keyword muControl return return-if return-unless
-syntax keyword muControl reply reply-if reply-unless
-syntax keyword muControl output-if output-unless
-syntax match muControl "^return\>\| return\>\|^reply\>\| reply\>\|^output\|^ output\>"
-syntax keyword muControl jump-if jump-unless
-syntax keyword muControl break-if break-unless
-syntax keyword muControl loop-if loop-unless
-syntax match muControl "^jump\>\| jump\>\|^break\>\| break\>\|^loop\>\| loop\>"
-syntax keyword muControl start-running
-syntax keyword muControl call-with-continuation-mark return-continuation-until-mark
-highlight link muControl Identifier
-
-syntax match muRecipe "->"
-syntax match muRecipe "^recipe\>\|^def\>\|^before\>\|^after\>\| -> "
-syntax keyword muRecipe recipe! def! function fn
-highlight link muRecipe PreProc
-
-syntax match muScenario "^scenario\>"  | highlight link muScenario Statement
-syntax keyword muPendingScenario pending-scenario  | highlight link muPendingScenario SpecialChar
-syntax match muData "^type\>\|^container\>"
-syntax keyword muData exclusive-container
-highlight link muData Constant
-
-let &cpo = s:save_cpo
diff --git a/archive/2.vm/mutable.mu b/archive/2.vm/mutable.mu
deleted file mode 100644
index 1a1ec7f0..00000000
--- a/archive/2.vm/mutable.mu
+++ /dev/null
@@ -1,13 +0,0 @@
-# compare immutable-error.mu
-
-def main [
-  local-scope
-  x:&:num <- new number:type
-  foo x
-]
-
-def foo x:&:num -> x:&:num [
-  local-scope
-  load-inputs
-  *x <- copy 34
-]
diff --git a/archive/2.vm/new_lesson b/archive/2.vm/new_lesson
deleted file mode 100755
index 3642b823..00000000
--- a/archive/2.vm/new_lesson
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-# Run this before running './mu edit' or './mu sandbox' to make sure you don't
-# lose any work.
-#
-# You'll be editing code in lesson/recipes.mu, and any sandboxes you create
-# will be in lesson/0, lesson/1, etc., from top to bottom.
-
-set -e
-
-mkdir lesson
-cd lesson
-git init
-echo '**/.*.swp' > .gitignore
-git add .
-git commit -m 0
diff --git a/archive/2.vm/nqueens.mu b/archive/2.vm/nqueens.mu
deleted file mode 100644
index 9e9f4425..00000000
--- a/archive/2.vm/nqueens.mu
+++ /dev/null
@@ -1,101 +0,0 @@
-# http://rosettacode.org/wiki/N-queens_problem
-# port of the Arc solution at http://arclanguage.org/item?id=19743
-# run with tracing turned on:
-#   ./mu --trace nqueens.mu
-
-container square [
-  rank:num
-  file:num
-]
-
-def nqueens n:num, queens:&:list:square -> result:num, queens:&:list:square [
-  local-scope
-  load-inputs
-  # if 'queens' is already long enough, print it and return
-  added-so-far:num <- length queens
-  {
-    done?:bool <- greater-or-equal added-so-far, n
-    break-unless done?
-    stash queens
-    return 1
-  }
-  # still work to do
-  next-rank:num <- copy 0
-  {
-    break-unless queens
-    first:square <- first queens
-    existing-rank:num <- get first, rank:offset
-    next-rank <- add existing-rank, 1
-  }
-  result <- copy 0
-  next-file:num <- copy 0
-  {
-    done?:bool <- greater-or-equal next-file, n
-    break-if done?
-    curr:square <- merge next-rank, next-file
-    {
-      curr-conflicts?:bool <- conflict? curr, queens
-      break-if curr-conflicts?
-      new-queens:&:list:square <- push curr, queens
-      sub-result:num <- nqueens n, new-queens
-      result <- add result, sub-result
-    }
-    next-file <- add next-file, 1
-    loop
-  }
-]
-
-# check if putting a queen on 'curr' conflicts with any of the existing
-# queens
-# assumes that 'curr' is on a non-conflicting rank, and checks for conflict
-# only in files and diagonals
-def conflict? curr:square, queens:&:list:square -> result:bool [
-  local-scope
-  load-inputs
-  result <- conflicting-file? curr, queens
-  return-if result
-  result <- conflicting-diagonal? curr, queens
-]
-
-def conflicting-file? curr:square, queens:&:list:square -> result:bool [
-  local-scope
-  load-inputs
-  curr-file:num <- get curr, file:offset
-  {
-    break-unless queens
-    q:square <- first queens
-    qfile:num <- get q, file:offset
-    file-match?:bool <- equal curr-file, qfile
-    return-if file-match?, true/conflict-found
-    queens <- rest queens
-    loop
-  }
-  return false/no-conflict-found
-]
-
-def conflicting-diagonal? curr:square, queens:&:list:square -> result:bool [
-  local-scope
-  load-inputs
-  curr-rank:num <- get curr, rank:offset
-  curr-file:num <- get curr, file:offset
-  {
-    break-unless queens
-    q:square <- first queens
-    qrank:num <- get q, rank:offset
-    qfile:num <- get q, file:offset
-    rank-delta:num <- subtract qrank, curr-rank
-    file-delta:num <- subtract qfile, curr-file
-    rank-delta <- abs rank-delta
-    file-delta <- abs file-delta
-    diagonal-match?:bool <- equal rank-delta, file-delta
-    return-if diagonal-match?, true/conflict-found
-    queens <- rest queens
-    loop
-  }
-  return false/no-conflict-found
-]
-
-def main [
-  nqueens 4
-  $dump-trace [app]
-]
diff --git a/archive/2.vm/real-files.mu b/archive/2.vm/real-files.mu
deleted file mode 100644
index 7e50ac8e..00000000
--- a/archive/2.vm/real-files.mu
+++ /dev/null
@@ -1,18 +0,0 @@
-# example program: read a character from one file and write it to another
-# BEWARE: this will modify your file system
-# before running it, put a character into /tmp/mu-x
-# after running it, check /tmp/mu-y
-
-def main [
-  local-scope
-  f:num/file <- $open-file-for-reading [/tmp/mu-x]
-  $print [file to read from: ], f, 10/newline
-  c:char, eof?:bool <- $read-from-file f
-  $print [copying ], c, 10/newline
-  f <- $close-file f
-  $print [file after closing: ], f, 10/newline
-  f <- $open-file-for-writing [/tmp/mu-y]
-  $print [file to write to: ], f, 10/newline
-  $write-to-file f, c
-  f <- $close-file f
-]
diff --git a/archive/2.vm/relayout b/archive/2.vm/relayout
deleted file mode 100755
index 8ea48920..00000000
--- a/archive/2.vm/relayout
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-# Helper to change the numerical prefixes across the repo, say if you want to
-# create room between 023 and 024, and so on.
-#
-# Assumes there's only ever one file with any numeric prefix. If you move
-# 003trace.test.cc you might need to do some manual patch-up.
-
-set -e
-
-if [[ $# -eq 0 && `git diff HEAD |wc -l` -gt 0 ]]
-then
-  echo "Uncommitted changes"
-  exit
-fi
-
-if [[ $# -gt 0 ]] # dry run
-then
-  git() {
-    echo $*
-  }
-fi
-
-#
-
-index=0
-ls [0-9]* |grep -v "trace.test" |sort -n |
-  while read file
-  do
-    while [[ $file != `printf "%03d" $index`* ]]
-    do
-      echo
-      index=$(($index+1))
-    done
-    echo $file
-    index=$(($index+1))
-  done > .layout
-
-vim -c "set nu" .layout
-
-#
-
-root() {
-  echo $1 |sed 's/^[0-9]*//'
-}
-
-index=0
-cat .layout |
-  while read file
-  do
-    if [ ! -z $file ]
-    then
-      newfile=`printf "%03d" $index``root $file`
-      if [[ $newfile != $file ]]
-      then
-        echo git mv $file $newfile
-        git mv $file $newfile
-      fi
-    fi
-    index=$(($index+1))
-  done
-
-rm .layout
-
-# Scenarios considered:
-#   Don't redo the layout if Vim exits with error.
diff --git a/archive/2.vm/same-fringe.mu b/archive/2.vm/same-fringe.mu
deleted file mode 100644
index b9235006..00000000
--- a/archive/2.vm/same-fringe.mu
+++ /dev/null
@@ -1,89 +0,0 @@
-# The 'same fringe' problem: http://wiki.c2.com/?SameFringeProblem
-# Example program demonstrating coroutines using Mu's delimited continuations.
-#
-# Expected output:
-#   1
-# (i.e. that the two given trees x and y have the same leaves, in the same
-# order from left to right)
-
-container tree:_elem [
-  val:_elem
-  left:&:tree:_elem
-  right:&:tree:_elem
-]
-
-def main [
-  local-scope
-  # x: ((a b) c)
-  # y: (a (b c))
-  a:&:tree:num <- new-tree 3
-  b:&:tree:num <- new-tree 4
-  c:&:tree:num <- new-tree 5
-  x1:&:tree:num <- new-tree a, b
-  x:&:tree:num <- new-tree x1, c
-  y1:&:tree:num <- new-tree b, c
-  y:&:tree:num <- new-tree a, y1
-  result:bool <- same-fringe x, y
-  $print result 10/newline
-]
-
-def same-fringe a:&:tree:_elem, b:&:tree:_elem -> result:bool [
-  local-scope
-  load-inputs
-  k1:continuation <- call-with-continuation-mark 100/mark, process, a
-  k2:continuation <- call-with-continuation-mark 100/mark, process, b
-  {
-    k1, x:_elem, a-done?:bool <- call k1
-    k2, y:_elem, b-done?:bool <- call k2
-    break-if a-done?
-    break-if b-done?
-    match?:bool <- equal x, y
-    return-unless match?, false
-    loop
-  }
-  result <- and a-done?, b-done?
-]
-
-# harness around traversal
-def process t:&:tree:_elem [
-  local-scope
-  load-inputs
-  return-continuation-until-mark 100/mark  # initial
-  traverse t
-  zero-val:&:_elem <- new _elem:type
-  return-continuation-until-mark 100/mark, *zero-val, true/done  # final
-  assert false, [continuation called past done]
-]
-
-# core traversal
-def traverse t:&:tree:_elem [
-  local-scope
-  load-inputs
-  return-unless t
-  l:&:tree:_elem <- get *t, left:offset
-  traverse l
-  r:&:tree:_elem <- get *t, right:offset
-  traverse r
-  return-if l
-  return-if r
-  # leaf
-  v:_elem <- get *t, val:offset
-  return-continuation-until-mark 100/mark, v, false/not-done
-]
-
-# details
-
-def new-tree x:_elem -> result:&:tree:_elem [
-  local-scope
-  load-inputs
-  result <- new {(tree _elem): type}
-  put *result, val:offset, x
-]
-
-def new-tree l:&:tree:_elem, r:&:tree:_elem -> result:&:tree:_elem [
-  local-scope
-  load-inputs
-  result <- new {(tree _elem): type}
-  put *result, left:offset, l
-  put *result, right:offset, r
-]
diff --git a/archive/2.vm/sandbox/001-editor.mu b/archive/2.vm/sandbox/001-editor.mu
deleted file mode 100644
index b3399dbb..00000000
--- a/archive/2.vm/sandbox/001-editor.mu
+++ /dev/null
@@ -1,464 +0,0 @@
-## the basic editor data structure, and how it displays text to the screen
-
-# temporary main for this layer: just render the given text at the given
-# screen dimensions, then stop
-def main text:text [
-  local-scope
-  load-inputs
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  e:&:editor <- new-editor text, 0/left, 5/right
-  render null/screen, e
-  wait-for-event null/console
-  close-console
-]
-
-scenario editor-renders-text-to-screen [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    # top line of screen reserved for menu
-    .          .
-    .abc       .
-    .          .
-  ]
-]
-
-container editor [
-  # editable text: doubly linked list of characters (head contains a special sentinel)
-  data:&:duplex-list:char
-  top-of-screen:&:duplex-list:char
-  bottom-of-screen:&:duplex-list:char
-  # location before cursor inside data
-  before-cursor:&:duplex-list:char
-
-  # raw bounds of display area on screen
-  # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen
-  left:num
-  right:num
-  bottom:num
-  # raw screen coordinates of cursor
-  cursor-row:num
-  cursor-column:num
-]
-
-# creates a new editor widget
-#   right is exclusive
-def new-editor s:text, left:num, right:num -> result:&:editor [
-  local-scope
-  load-inputs
-  # no clipping of bounds
-  right <- subtract right, 1
-  result <- new editor:type
-  # initialize screen-related fields
-  *result <- put *result, left:offset, left
-  *result <- put *result, right:offset, right
-  # initialize cursor coordinates
-  *result <- put *result, cursor-row:offset, 1/top
-  *result <- put *result, cursor-column:offset, left
-  # initialize empty contents
-  init:&:duplex-list:char <- push 167/§, null
-  *result <- put *result, data:offset, init
-  *result <- put *result, top-of-screen:offset, init
-  *result <- put *result, before-cursor:offset, init
-  result <- insert-text result, s
-  <editor-initialization>
-]
-
-def insert-text editor:&:editor, text:text -> editor:&:editor [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- get *editor, data:offset
-  insert curr, text
-]
-
-scenario editor-initializes-without-data [
-  local-scope
-  assume-screen 5/width, 3/height
-  run [
-    e:&:editor <- new-editor null/data, 2/left, 5/right
-    1:editor/raw <- copy *e
-  ]
-  memory-should-contain [
-    # 1,2 (data) <- just the § sentinel
-    # 3,4 (top of screen) <- the § sentinel
-    # 5 (bottom of screen) <- null since text fits on screen
-    5 <- 0
-    6 <- 0
-    # 7,8 (before cursor) <- the § sentinel
-    9 <- 2  # left
-    10 <- 4  # right  (inclusive)
-    11 <- 0  # bottom (not set until render)
-    12 <- 1  # cursor row
-    13 <- 2  # cursor column
-  ]
-  screen-should-contain [
-    .     .
-    .     .
-    .     .
-  ]
-]
-
-# Assumes cursor should be at coordinates (cursor-row, cursor-column) and
-# updates before-cursor to match. Might also move coordinates if they're
-# outside text.
-def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, 1/top, 0/left
-  left:num <- get *editor, left:offset
-  screen-height:num <- screen-height screen
-  right:num <- get *editor, right:offset
-  # traversing editor
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  # traversing screen
-  color:num <- copy 7/white
-  row:num <- copy 1/top
-  column:num <- copy left
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  screen <- move-cursor screen, row, column
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # update editor.before-cursor
-    # Doing so at the start of each iteration ensures it stays one step behind
-    # the current character.
-    {
-      at-cursor-row?:bool <- equal row, cursor-row
-      break-unless at-cursor-row?
-      at-cursor?:bool <- equal column, cursor-column
-      break-unless at-cursor?
-      before-cursor <- copy prev
-    }
-    c:char <- get *curr, value:offset
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # adjust cursor if necessary
-      {
-        at-cursor-row?:bool <- equal row, cursor-row
-        break-unless at-cursor-row?
-        left-of-cursor?:bool <- lesser-than column, cursor-column
-        break-unless left-of-cursor?
-        cursor-column <- copy column
-        before-cursor <- prev curr
-      }
-      # clear rest of line in this window
-      clear-line-until screen, right
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment curr
-      loop +next-character
-    }
-    print screen, c, color
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # save first character off-screen
-  *editor <- put *editor, bottom-of-screen:offset, curr
-  # is cursor to the right of the last line? move to end
-  {
-    at-cursor-row?:bool <- equal row, cursor-row
-    cursor-outside-line?:bool <- lesser-or-equal column, cursor-column
-    before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line?
-    above-cursor-row?:bool <- lesser-than row, cursor-row
-    before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row?
-    break-unless before-cursor?
-    cursor-row <- copy row
-    cursor-column <- copy column
-    before-cursor <- copy prev
-  }
-  *editor <- put *editor, bottom:offset, row
-  *editor <- put *editor, cursor-row:offset, cursor-row
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  clear-line-until screen, right
-  row <- add row, 1
-  return row, left/column
-]
-
-def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  # if it's the real screen, use the optimized primitive
-  {
-    break-if screen
-    clear-display-from row, column, left, right
-    return
-  }
-  # if not, go the slower route
-  screen <- move-cursor screen, row, column
-  clear-line-until screen, right
-  clear-rest-of-screen screen, row, left, right
-]
-
-def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  row <- add row, 1
-  # if it's the real screen, use the optimized primitive
-  {
-    break-if screen
-    clear-display-from row, left, left, right
-    return
-  }
-  screen <- move-cursor screen, row, left
-  screen-height:num <- screen-height screen
-  {
-    at-bottom-of-screen?:bool <- greater-or-equal row, screen-height
-    break-if at-bottom-of-screen?
-    screen <- move-cursor screen, row, left
-    clear-line-until screen, right
-    row <- add row, 1
-    loop
-  }
-]
-
-scenario editor-prints-multiple-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc  .
-    .def  .
-    .     .
-  ]
-]
-
-scenario editor-handles-offsets [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc], 1/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    . abc .
-    .     .
-  ]
-]
-
-scenario editor-prints-multiple-lines-at-offset [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 1/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    . abc .
-    . def .
-    .     .
-  ]
-]
-
-scenario editor-wraps-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc def], 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc ↩.
-    .def  .
-    .     .
-  ]
-  screen-should-contain-in-color 245/grey [
-    .     .
-    .    ↩.
-    .     .
-    .     .
-  ]
-]
-
-scenario editor-wraps-barely-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  # still wrap, even though the line would fit. We need room to click on the
-  # end of the line
-  screen-should-contain [
-    .     .
-    .abcd↩.
-    .e    .
-    .     .
-  ]
-  screen-should-contain-in-color 245/grey [
-    .     .
-    .    ↩.
-    .     .
-    .     .
-  ]
-]
-
-scenario editor-with-empty-text [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  run [
-    render screen, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .     .
-    .     .
-    .     .
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 0  # cursor column
-  ]
-]
-
-# just a little color for Mu code
-
-scenario render-colors-comments [
-  local-scope
-  assume-screen 5/width, 5/height
-  s:text <- new [abc
-# de
-f]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .     .
-    .abc  .
-    .# de .
-    .f    .
-    .     .
-  ]
-  screen-should-contain-in-color 12/lightblue, [
-    .     .
-    .     .
-    .# de .
-    .     .
-    .     .
-  ]
-  screen-should-contain-in-color 7/white, [
-    .     .
-    .abc  .
-    .     .
-    .f    .
-    .     .
-  ]
-]
-
-after <character-c-received> [
-  color <- get-color color, c
-]
-
-# so far the previous color is all the information we need; that may change
-def get-color color:num, c:char -> color:num [
-  local-scope
-  load-inputs
-  color-is-white?:bool <- equal color, 7/white
-  # if color is white and next character is '#', switch color to blue
-  {
-    break-unless color-is-white?
-    starting-comment?:bool <- equal c, 35/#
-    break-unless starting-comment?
-    trace 90, [app], [switch color back to blue]
-    return 12/lightblue
-  }
-  # if color is blue and next character is newline, switch color to white
-  {
-    color-is-blue?:bool <- equal color, 12/lightblue
-    break-unless color-is-blue?
-    ending-comment?:bool <- equal c, 10/newline
-    break-unless ending-comment?
-    trace 90, [app], [switch color back to white]
-    return 7/white
-  }
-  # if color is white (no comments) and next character is '<', switch color to red
-  {
-    break-unless color-is-white?
-    starting-assignment?:bool <- equal c, 60/<
-    break-unless starting-assignment?
-    return 1/red
-  }
-  # if color is red and next character is space, switch color to white
-  {
-    color-is-red?:bool <- equal color, 1/red
-    break-unless color-is-red?
-    ending-assignment?:bool <- equal c, 32/space
-    break-unless ending-assignment?
-    return 7/white
-  }
-  # otherwise no change
-  return color
-]
-
-scenario render-colors-assignment [
-  local-scope
-  assume-screen 8/width, 5/height
-  s:text <- new [abc
-d <- e
-f]
-  e:&:editor <- new-editor s, 0/left, 8/right
-  run [
-    render screen, e
-  ]
-  screen-should-contain [
-    .        .
-    .abc     .
-    .d <- e  .
-    .f       .
-    .        .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .        .
-    .        .
-    .  <-    .
-    .        .
-    .        .
-  ]
-]
diff --git a/archive/2.vm/sandbox/002-typing.mu b/archive/2.vm/sandbox/002-typing.mu
deleted file mode 100644
index ef3f25d2..00000000
--- a/archive/2.vm/sandbox/002-typing.mu
+++ /dev/null
@@ -1,1144 +0,0 @@
-## handling events from the keyboard, mouse, touch screen, ...
-
-# temporary main: interactive editor
-# hit ctrl-c to exit
-def! main text:text [
-  local-scope
-  load-inputs
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  editor:&:editor <- new-editor text, 5/left, 45/right
-  editor-render null/screen, editor
-  editor-event-loop null/screen, null/console, editor
-  close-console
-]
-
-def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [
-  local-scope
-  load-inputs
-  {
-    # looping over each (keyboard or touch) event as it occurs
-    +next-event
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    screen <- move-cursor screen, cursor-row, cursor-column
-    e:event, found?:bool, quit?:bool, console <- read-event console
-    loop-unless found?
-    break-if quit?  # only in tests
-    trace 10, [app], [next-event]
-    # 'touch' event
-    t:touch-event, is-touch?:bool <- maybe-convert e, touch:variant
-    {
-      break-unless is-touch?
-      move-cursor editor, screen, t
-      loop +next-event
-    }
-    # keyboard events
-    {
-      break-if is-touch?
-      go-render?:bool <- handle-keyboard-event screen, editor, e
-      {
-        break-unless go-render?
-        screen <- editor-render screen, editor
-      }
-    }
-    loop
-  }
-]
-
-# process click, return if it was on current editor
-def move-cursor editor:&:editor, screen:&:screen, t:touch-event -> in-focus?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, false
-  click-row:num <- get t, row:offset
-  return-unless click-row, false  # ignore clicks on 'menu'
-  click-column:num <- get t, column:offset
-  left:num <- get *editor, left:offset
-  too-far-left?:bool <- lesser-than click-column, left
-  return-if too-far-left?, false
-  right:num <- get *editor, right:offset
-  too-far-right?:bool <- greater-than click-column, right
-  return-if too-far-right?, false
-  # position cursor
-  <begin-move-cursor>
-  editor <- snap-cursor editor, screen, click-row, click-column
-  undo-coalesce-tag:num <- copy 0/never
-  <end-move-cursor>
-  # gain focus
-  return true
-]
-
-# Variant of 'render' that only moves the cursor (coordinates and
-# before-cursor). If it's past the end of a line, it 'slides' it left. If it's
-# past the last line it positions at end of last line.
-def snap-cursor editor:&:editor, screen:&:screen, target-row:num, target-column:num -> editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  screen-height:num <- screen-height screen
-  # count newlines until screen row
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  row:num <- copy 1/top
-  column:num <- copy left
-  *editor <- put *editor, cursor-row:offset, target-row
-  cursor-row:num <- copy target-row
-  *editor <- put *editor, cursor-column:offset, target-column
-  cursor-column:num <- copy target-column
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # update editor.before-cursor
-    # Doing so at the start of each iteration ensures it stays one step behind
-    # the current character.
-    {
-      at-cursor-row?:bool <- equal row, cursor-row
-      break-unless at-cursor-row?
-      at-cursor?:bool <- equal column, cursor-column
-      break-unless at-cursor?
-      before-cursor <- copy prev
-      *editor <- put *editor, before-cursor:offset, before-cursor
-    }
-    c:char <- get *curr, value:offset
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # adjust cursor if necessary
-      {
-        at-cursor-row?:bool <- equal row, cursor-row
-        break-unless at-cursor-row?
-        left-of-cursor?:bool <- lesser-than column, cursor-column
-        break-unless left-of-cursor?
-        cursor-column <- copy column
-        *editor <- put *editor, cursor-column:offset, cursor-column
-        before-cursor <- copy prev
-        *editor <- put *editor, before-cursor:offset, before-cursor
-      }
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      column <- copy left
-      row <- add row, 1
-      # don't increment curr/prev
-      loop +next-character
-    }
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # is cursor to the right of the last line? move to end
-  {
-    at-cursor-row?:bool <- equal row, cursor-row
-    cursor-outside-line?:bool <- lesser-or-equal column, cursor-column
-    before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line?
-    above-cursor-row?:bool <- lesser-than row, cursor-row
-    before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row?
-    break-unless before-cursor?
-    cursor-row <- copy row
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy column
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    before-cursor <- copy prev
-    *editor <- put *editor, before-cursor:offset, before-cursor
-  }
-]
-
-# Process an event 'e' and try to minimally update the screen.
-# Set 'go-render?' to true to indicate the caller must perform a non-minimal update.
-def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render?:bool, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, false/don't-render
-  screen-width:num <- screen-width screen
-  screen-height:num <- screen-height screen
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  save-row:num <- copy cursor-row
-  save-column:num <- copy cursor-column
-  # character
-  {
-    c:char, is-unicode?:bool <- maybe-convert e, text:variant
-    break-unless is-unicode?
-    trace 10, [app], [handle-keyboard-event: special character]
-    # exceptions for special characters go here
-    <handle-special-character>
-    # ignore any other special characters
-    regular-character?:bool <- greater-or-equal c, 32/space
-    return-unless regular-character?, false/don't-render
-    # otherwise type it in
-    <begin-insert-character>
-    go-render? <- insert-at-cursor editor, c, screen
-    <end-insert-character>
-    return
-  }
-  # special key to modify the text or move the cursor
-  k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant
-  assert is-keycode?, [event was of unknown type; neither keyboard nor mouse]
-  # handlers for each special key will go here
-  <handle-special-key>
-  return true/go-render
-]
-
-def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  insert c, before-cursor
-  before-cursor <- next before-cursor
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  save-row:num <- copy cursor-row
-  save-column:num <- copy cursor-column
-  screen-width:num <- screen-width screen
-  screen-height:num <- screen-height screen
-  # occasionally we'll need to mess with the cursor
-  <insert-character-special-case>
-  # but mostly we'll just move the cursor right
-  cursor-column <- add cursor-column, 1
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  next:&:duplex-list:char <- next before-cursor
-  {
-    # at end of all text? no need to scroll? just print the character and leave
-    at-end?:bool <- equal next, null
-    break-unless at-end?
-    bottom:num <- subtract screen-height, 1
-    at-bottom?:bool <- equal save-row, bottom
-    at-right?:bool <- equal save-column, right
-    overflow?:bool <- and at-bottom?, at-right?
-    break-if overflow?
-    move-cursor screen, save-row, save-column
-    print screen, c
-    return false/don't-render
-  }
-  {
-    # not at right margin? print the character and rest of line
-    break-unless next
-    at-right?:bool <- greater-or-equal cursor-column, screen-width
-    break-if at-right?
-    curr:&:duplex-list:char <- copy before-cursor
-    move-cursor screen, save-row, save-column
-    curr-column:num <- copy save-column
-    {
-      # hit right margin? give up and let caller render
-      at-right?:bool <- greater-than curr-column, right
-      return-if at-right?, true/go-render
-      break-unless curr
-      # newline? done.
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      print screen, currc
-      curr-column <- add curr-column, 1
-      curr <- next curr
-      loop
-    }
-    return false/don't-render
-  }
-  return true/go-render
-]
-
-# helper for tests
-def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  old-top-idx:num <- save-top-idx screen
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  row:num, column:num <- render screen, editor
-  draw-horizontal screen, row, left, right, 9480/horizontal-dotted
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-  assert-no-scroll screen, old-top-idx
-]
-
-scenario editor-handles-empty-event-queue [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  assume-console []
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-handles-mouse-clicks [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 1  # on the 'b'
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor is at row 0..
-    4 <- 1  # ..and column 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 1, 7  # last line, to the right of text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 1, 7  # interior line, to the right of text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-text-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  assume-console [
-    left-click 3, 7  # below text
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 3  # cursor column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-outside-column [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor occupies only left half of screen
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    # click on right half of screen
-    left-click 3, 8
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1  # no change to cursor row
-    4 <- 0  # ..or column
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-handles-mouse-clicks-in-menu-area [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    # click on first, 'menu' row
-    left-click 0, 3
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # no change to cursor
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-]
-
-scenario editor-inserts-characters-into-empty-editor [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    type [abc]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # type two letters at different places
-  assume-console [
-    type [0]
-    left-click 1, 2
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0adbc     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 7, [print-character]  # 4 for first letter, 3 for second
-]
-
-scenario editor-inserts-characters-at-cursor-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 5  # right of last line
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-5 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 5  # right of non-last line
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abce      .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [d]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .de        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-scenario editor-inserts-characters-at-cursor-6 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 3, 5  # below all text
-    type [ef]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]
-]
-
-scenario editor-moves-cursor-after-inserting-characters [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 5/right
-  editor-render screen, e
-  assume-console [
-    type [01]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .01ab      .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-# if the cursor reaches the right margin, wrap the line
-
-scenario editor-wraps-line-on-insert [
-  local-scope
-  assume-screen 5/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 5/right
-  editor-render screen, e
-  # type a letter
-  assume-console [
-    type [e]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # no wrap yet
-  screen-should-contain [
-    .     .
-    .eabc .
-    .┈┈┈┈┈.
-    .     .
-    .     .
-  ]
-  # type a second letter
-  assume-console [
-    type [f]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # now wrap
-  screen-should-contain [
-    .     .
-    .efab↩.
-    .c    .
-    .┈┈┈┈┈.
-    .     .
-  ]
-]
-
-scenario editor-wraps-line-on-insert-2 [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  s:text <- new [abcdefg
-defg]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  # type more text at the start
-  assume-console [
-    left-click 3, 0
-    type [abc]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor is not wrapped
-  memory-should-contain [
-    3 <- 3
-    4 <- 3
-  ]
-  # but line is wrapped
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .efg       .
-    .abcd↩     .
-    .efg       .
-  ]
-]
-
-after <insert-character-special-case> [
-  # if the line wraps at the cursor, move cursor to start of next row
-  {
-    # if either:
-    # a) we're at the end of the line and at the column of the wrap indicator, or
-    # b) we're not at end of line and just before the column of the wrap indicator
-    wrap-column:num <- copy right
-    before-wrap-column:num <- subtract wrap-column, 1
-    at-wrap?:bool <- greater-or-equal cursor-column, wrap-column
-    just-before-wrap?:bool <- greater-or-equal cursor-column, before-wrap-column
-    next:&:duplex-list:char <- next before-cursor
-    # at end of line? next == 0 || next.value == 10/newline
-    at-end-of-line?:bool <- equal next, null
-    {
-      break-if at-end-of-line?
-      next-character:char <- get *next, value:offset
-      at-end-of-line? <- equal next-character, 10/newline
-    }
-    # break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?))
-    move-cursor-to-next-line?:bool <- copy false
-    {
-      break-if at-end-of-line?
-      move-cursor-to-next-line? <- copy just-before-wrap?
-      # if we're moving the cursor because it's in the middle of a wrapping
-      # line, adjust it to left-most column
-      potential-new-cursor-column:num <- copy left
-    }
-    {
-      break-unless at-end-of-line?
-      move-cursor-to-next-line? <- copy at-wrap?
-      # if we're moving the cursor because it's at the end of a wrapping line,
-      # adjust it to one past the left-most column to make room for the
-      # newly-inserted wrap-indicator
-      potential-new-cursor-column:num <- add left, 1/make-room-for-wrap-indicator
-    }
-    break-unless move-cursor-to-next-line?
-    cursor-column <- copy potential-new-cursor-column
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    # if we're out of the screen, scroll down
-    {
-      below-screen?:bool <- greater-or-equal cursor-row, screen-height
-      break-unless below-screen?
-      <scroll-down>
-    }
-    return true/go-render
-  }
-]
-
-scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  assume-console [
-    left-click 1, 3  # right before the wrap icon
-    type [f]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcf↩     .
-    .de        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 0  # cursor column
-  ]
-]
-
-scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # create an editor containing two lines
-  s:text <- new [abc
-xyz]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .xyz       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 1, 4  # at end of first line
-    type [de]  # trigger wrap
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .xyz       .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-wraps-cursor-to-left-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 2/left, 7/right
-  assume-console [
-    left-click 1, 5  # line is full; no wrap icon yet
-    type [01]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .  abc0↩   .
-    .  1de     .
-    .  ┈┈┈┈┈   .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2  # cursor row
-    4 <- 3  # cursor column
-  ]
-]
-
-# if newline, move cursor to start of next line, and maybe align indent with previous line
-
-container editor [
-  indent?:bool
-]
-
-after <editor-initialization> [
-  *result <- put *result, indent?:offset, true
-]
-
-scenario editor-moves-cursor-down-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  assume-console [
-    type [0
-1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0         .
-    .1abc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-character> [
-  {
-    newline?:bool <- equal c, 10/newline
-    break-unless newline?
-    <begin-insert-enter>
-    insert-new-line-and-indent editor, screen
-    <end-insert-enter>
-    return true/go-render
-  }
-]
-
-def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  screen-height:num <- screen-height screen
-  # update cursor coordinates
-  at-start-of-wrapped-line?:bool <- at-start-of-wrapped-line? editor
-  {
-    break-if at-start-of-wrapped-line?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  cursor-column <- copy left
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  # maybe scroll
-  {
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal, never greater
-    break-unless below-screen?
-    <scroll-down2>
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  # insert newline
-  insert 10/newline, before-cursor
-  before-cursor <- next before-cursor
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  # indent if necessary
-  indent?:bool <- get *editor, indent?:offset
-  return-unless indent?
-  d:&:duplex-list:char <- get *editor, data:offset
-  end-of-previous-line:&:duplex-list:char <- prev before-cursor
-  indent:num <- line-indent end-of-previous-line, d
-  i:num <- copy 0
-  {
-    indent-done?:bool <- greater-or-equal i, indent
-    break-if indent-done?
-    insert-at-cursor editor, 32/space, screen
-    i <- add i, 1
-    loop
-  }
-]
-
-def at-start-of-wrapped-line? editor:&:editor -> result:bool [
-  local-scope
-  load-inputs
-  left:num <- get *editor, left:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  cursor-at-left?:bool <- equal cursor-column, left
-  return-unless cursor-at-left?, false
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  before-before-cursor:&:duplex-list:char <- prev before-cursor
-  return-unless before-before-cursor, false  # cursor is at start of editor
-  char-before-cursor:char <- get *before-cursor, value:offset
-  cursor-after-newline?:bool <- equal char-before-cursor, 10/newline
-  return-if cursor-after-newline?, false
-  # if cursor is at left margin and not at start, but previous character is not a newline,
-  # then we're at start of a wrapped line
-  return true
-]
-
-# takes a pointer 'curr' into the doubly-linked list and its sentinel, counts
-# the number of spaces at the start of the line containing 'curr'.
-def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [
-  local-scope
-  load-inputs
-  result:num <- copy 0
-  return-unless curr
-  at-start?:bool <- equal curr, start
-  return-if at-start?
-  {
-    curr <- prev curr
-    break-unless curr
-    at-start?:bool <- equal curr, start
-    break-if at-start?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    # if c is a space, increment result
-    is-space?:bool <- equal c, 32/space
-    {
-      break-unless is-space?
-      result <- add result, 1
-    }
-    # if c is not a space, reset result
-    {
-      break-if is-space?
-      result <- copy 0
-    }
-    loop
-  }
-]
-
-scenario editor-moves-cursor-down-after-inserting-newline-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 1/left, 10/right
-  assume-console [
-    type [0
-1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . 0        .
-    . 1abc     .
-    . ┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-clears-previous-line-completely-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    press enter
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # line should be fully cleared
-  screen-should-contain [
-    .          .
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-splits-wrapped-line-after-inserting-newline [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 2, 0
-    press enter
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .ef        .
-    .┈┈┈┈┈     .
-  ]
-  memory-should-contain [
-    10 <- 2  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-scenario editor-inserts-indent-after-newline [
-  local-scope
-  assume-screen 10/width, 10/height
-  s:text <- new [ab
-  cd
-ef]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  # position cursor after 'cd' and hit 'newline'
-  assume-console [
-    left-click 2, 8
-    type [
-]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor should be below start of previous line
-  memory-should-contain [
-    3 <- 3  # cursor row
-    4 <- 2  # cursor column (indented)
-  ]
-]
-
-scenario editor-skips-indent-around-paste [
-  local-scope
-  assume-screen 10/width, 10/height
-  s:text <- new [ab
-  cd
-ef]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  # position cursor after 'cd' and hit 'newline' surrounded by paste markers
-  assume-console [
-    left-click 2, 8
-    press 65507  # start paste
-    press enter
-    press 65506  # end paste
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor should be below start of previous line
-  memory-should-contain [
-    3 <- 3  # cursor row
-    4 <- 0  # cursor column (not indented)
-  ]
-]
-
-after <handle-special-key> [
-  {
-    paste-start?:bool <- equal k, 65507/paste-start
-    break-unless paste-start?
-    *editor <- put *editor, indent?:offset, false
-    return true/go-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    paste-end?:bool <- equal k, 65506/paste-end
-    break-unless paste-end?
-    *editor <- put *editor, indent?:offset, true
-    return true/go-render
-  }
-]
-
-## helpers
-
-def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  height:num <- screen-height screen
-  past-bottom?:bool <- greater-or-equal row, height
-  return-if past-bottom?
-  style:char, style-found?:bool <- next-input
-  {
-    break-if style-found?
-    style <- copy 9472/horizontal
-  }
-  color:num, color-found?:bool <- next-input
-  {
-    # default color to white
-    break-if color-found?
-    color <- copy 245/grey
-  }
-  bg-color:num, bg-color-found?:bool <- next-input
-  {
-    break-if bg-color-found?
-    bg-color <- copy 0/black
-  }
-  screen <- move-cursor screen, row, x
-  {
-    continue?:bool <- lesser-or-equal x, right  # right is inclusive, to match editor semantics
-    break-unless continue?
-    print screen, style, color, bg-color
-    x <- add x, 1
-    loop
-  }
-]
diff --git a/archive/2.vm/sandbox/003-shortcuts.mu b/archive/2.vm/sandbox/003-shortcuts.mu
deleted file mode 100644
index c9e66d5b..00000000
--- a/archive/2.vm/sandbox/003-shortcuts.mu
+++ /dev/null
@@ -1,2800 +0,0 @@
-## special shortcuts for manipulating the editor
-# Some keys on the keyboard generate unicode characters, others generate
-# terminfo key codes. We need to modify different places in the two cases.
-
-# tab - insert two spaces
-
-scenario editor-inserts-two-spaces-on-tab [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-cd]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press tab
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  ab      .
-    .cd        .
-  ]
-  # we render at most two editor rows worth (one row for each space)
-  check-trace-count-for-label-lesser-than 10, [print-character]
-]
-
-scenario editor-inserts-two-spaces-and-wraps-line-on-tab [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcd], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press tab
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  ab↩     .
-    .cd        .
-  ]
-  # we re-render the whole editor
-  check-trace-count-for-label-greater-than 10, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    tab?:bool <- equal c, 9/tab
-    break-unless tab?
-    <begin-insert-character>
-    # todo: decompose insert-at-cursor into editor update and screen update,
-    # so that 'tab' doesn't render the current line multiple times
-    insert-at-cursor editor, 32/space, screen
-    go-render? <- insert-at-cursor editor, 32/space, screen
-    <end-insert-character>
-    return
-  }
-]
-
-# backspace - delete character before cursor
-
-scenario editor-handles-backspace-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 1
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .bc        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 0
-  ]
-  check-trace-count-for-label 3, [print-character]  # length of original line to overwrite
-]
-
-after <handle-special-character> [
-  {
-    delete-previous-character?:bool <- equal c, 8/backspace
-    break-unless delete-previous-character?
-    <begin-backspace-character>
-    go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen
-    <end-backspace-character>
-    return
-  }
-]
-
-# return values:
-#   go-render? - whether caller needs to update the screen
-#   backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc.
-def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  data:&:duplex-list:char <- get *editor, data:offset
-  # if at start of text (before-cursor at § sentinel), return
-  prev:&:duplex-list:char <- prev before-cursor
-  return-unless prev, false/no-more-render, null/nothing-deleted
-  trace 10, [app], [delete-before-cursor]
-  original-row:num <- get *editor, cursor-row:offset
-  move-cursor-coordinates-left editor
-  backspaced-cell:&:duplex-list:char <- copy before-cursor
-  data <- remove before-cursor, data  # will also neatly trim next/prev pointers in backspaced-cell/before-cursor
-  before-cursor <- copy prev
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  screen-width:num <- screen-width screen
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  # did we just backspace over a newline?
-  same-row?:bool <- equal cursor-row, original-row
-  return-unless same-row?, true/go-render
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  curr:&:duplex-list:char <- next before-cursor
-  screen <- move-cursor screen, cursor-row, cursor-column
-  curr-column:num <- copy cursor-column
-  {
-    # hit right margin? give up and let caller render
-    at-right?:bool <- greater-or-equal curr-column, right
-    return-if at-right?, true/go-render
-    break-unless curr
-    # newline? done.
-    currc:char <- get *curr, value:offset
-    at-newline?:bool <- equal currc, 10/newline
-    break-if at-newline?
-    screen <- print screen, currc
-    curr-column <- add curr-column, 1
-    curr <- next curr
-    loop
-  }
-  # we're guaranteed not to be at the right margin
-  space:char <- copy 32/space
-  screen <- print screen, space
-  go-render? <- copy false
-]
-
-def move-cursor-coordinates-left editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  # if not at left margin, move one character left
-  {
-    at-left-margin?:bool <- equal cursor-column, left
-    break-if at-left-margin?
-    trace 10, [app], [decrementing cursor column]
-    cursor-column <- subtract cursor-column, 1
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    return
-  }
-  # if at left margin, we must move to previous row:
-  top-of-screen?:bool <- equal cursor-row, 1  # exclude menu bar
-  {
-    break-if top-of-screen?
-    cursor-row <- subtract cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-  }
-  {
-    break-unless top-of-screen?
-    # no scroll, so do nothing
-  }
-  {
-    # case 1: if previous character was newline, figure out how long the previous line is
-    previous-character:char <- get *before-cursor, value:offset
-    previous-character-is-newline?:bool <- equal previous-character, 10/newline
-    break-unless previous-character-is-newline?
-    # compute length of previous line
-    trace 10, [app], [switching to previous line]
-    d:&:duplex-list:char <- get *editor, data:offset
-    end-of-line:num <- previous-line-length before-cursor, d
-    right:num <- get *editor, right:offset
-    width:num <- subtract right, left
-    wrap?:bool <- greater-than end-of-line, width
-    {
-      break-unless wrap?
-      _, column-offset:num <- divide-with-remainder end-of-line, width
-      cursor-column <- add left, column-offset
-      *editor <- put *editor, cursor-column:offset, cursor-column
-    }
-    {
-      break-if wrap?
-      cursor-column <- add left, end-of-line
-      *editor <- put *editor, cursor-column:offset, cursor-column
-    }
-    return
-  }
-  # case 2: if previous-character was not newline, we're just at a wrapped line
-  trace 10, [app], [wrapping to previous line]
-  right:num <- get *editor, right:offset
-  cursor-column <- subtract right, 1  # leave room for wrap icon
-  *editor <- put *editor, cursor-column:offset, cursor-column
-]
-
-# takes a pointer 'curr' into the doubly-linked list and its sentinel, counts
-# the length of the previous line before the 'curr' pointer.
-def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [
-  local-scope
-  load-inputs
-  result:num <- copy 0
-  return-unless curr
-  at-start?:bool <- equal curr, start
-  return-if at-start?
-  {
-    curr <- prev curr
-    break-unless curr
-    at-start?:bool <- equal curr, start
-    break-if at-start?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    result <- add result, 1
-    loop
-  }
-]
-
-scenario editor-clears-last-line-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-cd]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  assume-console [
-    left-click 2, 0
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 2
-  ]
-]
-
-scenario editor-joins-and-wraps-lines-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with two long-ish but non-wrapping lines
-  s:text <- new [abc def
-ghi jkl]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position the cursor at the start of the second and hit backspace
-  assume-console [
-    left-click 2, 0
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # resulting single line should wrap correctly
-  screen-should-contain [
-    .          .
-    .abc defgh↩.
-    .i jkl     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-wraps-long-lines-on-backspace [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor in part of the screen with a long line
-  e:&:editor <- new-editor [abc def ghij], 0/left, 8/right
-  editor-render screen, e
-  # confirm that it wraps
-  screen-should-contain [
-    .          .
-    .abc def↩  .
-    . ghij     .
-    .┈┈┈┈┈┈┈┈  .
-  ]
-  $clear-trace
-  # position the cursor somewhere in the middle of the top screen line and hit backspace
-  assume-console [
-    left-click 1, 4
-    press backspace
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # resulting single line should wrap correctly and not overflow its bounds
-  screen-should-contain [
-    .          .
-    .abcdef ↩  .
-    .ghij      .
-    .┈┈┈┈┈┈┈┈  .
-    .          .
-  ]
-]
-
-# delete - delete character at cursor
-
-scenario editor-handles-delete-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press delete
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .bc        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]  # length of original line to overwrite
-  $clear-trace
-  assume-console [
-    press delete
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .c         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]  # new length to overwrite
-]
-
-after <handle-special-key> [
-  {
-    delete-next-character?:bool <- equal k, 65522/delete
-    break-unless delete-next-character?
-    <begin-delete-character>
-    go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen
-    <end-delete-character>
-    return
-  }
-]
-
-def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  data:&:duplex-list:char <- get *editor, data:offset
-  deleted-cell:&:duplex-list:char <- next before-cursor
-  return-unless deleted-cell, false/don't-render
-  currc:char <- get *deleted-cell, value:offset
-  data <- remove deleted-cell, data
-  deleted-newline?:bool <- equal currc, 10/newline
-  return-if deleted-newline?, true/go-render
-  # wasn't a newline? render rest of line
-  curr:&:duplex-list:char <- next before-cursor  # refresh after remove above
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  screen <- move-cursor screen, cursor-row, cursor-column
-  curr-column:num <- copy cursor-column
-  screen-width:num <- screen-width screen
-  {
-    # hit right margin? give up and let caller render
-    at-right?:bool <- greater-or-equal curr-column, screen-width
-    return-if at-right?, true/go-render
-    break-unless curr
-    currc:char <- get *curr, value:offset
-    at-newline?:bool <- equal currc, 10/newline
-    break-if at-newline?
-    screen <- print screen, currc
-    curr-column <- add curr-column, 1
-    curr <- next curr
-    loop
-  }
-  # we're guaranteed not to be at the right margin
-  space:char <- copy 32/space
-  screen <- print screen, space
-  go-render? <- copy false
-]
-
-# right arrow
-
-scenario editor-moves-cursor-right-with-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press right-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]  # 0 and following characters
-]
-
-after <handle-special-key> [
-  {
-    move-to-next-character?:bool <- equal k, 65514/right-arrow
-    break-unless move-to-next-character?
-    # if not at end of text
-    next-cursor:&:duplex-list:char <- next before-cursor
-    break-unless next-cursor
-    # scan to next character
-    <begin-move-cursor>
-    before-cursor <- copy next-cursor
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    go-render?:bool <- move-cursor-coordinates-right editor, screen-height
-    screen <- move-cursor screen, cursor-row, cursor-column
-    undo-coalesce-tag:num <- copy 2/right-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor before-cursor:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  # if crossed a newline, move cursor to start of next row
-  {
-    old-cursor-character:char <- get *before-cursor, value:offset
-    was-at-newline?:bool <- equal old-cursor-character, 10/newline
-    break-unless was-at-newline?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal
-    return-unless below-screen?, false/don't-render
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    return true/go-render
-  }
-  # if the line wraps, move cursor to start of next row
-  {
-    # if we're at the column just before the wrap indicator
-    wrap-column:num <- subtract right, 1
-    at-wrap?:bool <- equal cursor-column, wrap-column
-    break-unless at-wrap?
-    # and if next character isn't newline
-    next:&:duplex-list:char <- next before-cursor
-    break-unless next
-    next-character:char <- get *next, value:offset
-    newline?:bool <- equal next-character, 10/newline
-    break-if newline?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    below-screen?:bool <- greater-or-equal cursor-row, screen-height  # must be equal
-    return-unless below-screen?, false/no-more-render
-    cursor-row <- subtract cursor-row, 1  # bring back into screen range
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    return true/go-render
-  }
-  # otherwise move cursor one character right
-  cursor-column <- add cursor-column, 1
-  *editor <- put *editor, cursor-column:offset, cursor-column
-  go-render? <- copy false
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # type right-arrow a few times to get to start of second line
-  assume-console [
-    press right-arrow
-    press right-arrow
-    press right-arrow
-    press right-arrow  # next line
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # type something and ensure it goes where it should
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0d        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]  # new length of second line
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 1/left, 10/right
-  editor-render screen, e
-  assume-console [
-    press right-arrow
-    press right-arrow
-    press right-arrow
-    press right-arrow  # next line
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . abc      .
-    . 0d       .
-    . ┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # line just barely wrapping
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at last character before wrap and hit right-arrow
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  # now hit right arrow again
-  assume-console [
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcdef], 1/left, 6/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 4
-    press right-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    . abcd↩    .
-    . ef       .
-    . ┈┈┈┈┈    .
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # move to end of line, press right-arrow, type a character
-  assume-console [
-    left-click 1, 3
-    press right-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # new character should be in next line
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0d        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 2, [print-character]
-]
-
-# todo: ctrl-right: next word-end
-
-# left arrow
-
-scenario editor-moves-cursor-left-with-key [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 2
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 3, [print-character]
-]
-
-after <handle-special-key> [
-  {
-    move-to-previous-character?:bool <- equal k, 65515/left-arrow
-    break-unless move-to-previous-character?
-    trace 10, [app], [left arrow]
-    # if not at start of text (before-cursor at § sentinel)
-    prev:&:duplex-list:char <- prev before-cursor
-    return-unless prev, false/don't-render
-    <begin-move-cursor>
-    move-cursor-coordinates-left editor
-    before-cursor <- copy prev
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    undo-coalesce-tag:num <- copy 1/left-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with two lines
-  s:text <- new [abc
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at start of second line (so there's no previous newline)
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with three lines
-  s:text <- new [abc
-def
-g]
-  e:&:editor <- new-editor s:text, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor further down (so there's a newline before the character at
-  # the cursor)
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def0      .
-    .g         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 1, [print-character]  # just the '0'
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def
-g]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # position cursor at start of text, press left-arrow, then type a character
-  assume-console [
-    left-click 1, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # left-arrow should have had no effect
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .g         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 4, [print-character]  # length of first line
-]
-
-scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with text containing an empty line
-  s:text <- new [abc
-
-d]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e:&:editor
-  $clear-trace
-  # position cursor right after empty line
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0         .
-    .d         .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  check-trace-count-for-label 1, [print-character]  # just the '0'
-]
-
-scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a wrapping line
-  e:&:editor <- new-editor [abcdef], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # previous row
-    4 <- 3  # right margin except wrap icon
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a wrapping line followed by a second line
-  s:text <- new [abcdef
-g]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .ef        .
-    .g         .
-    .┈┈┈┈┈     .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 3, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2  # previous row
-    4 <- 2  # end of wrapped line
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  # initialize editor with a line on the verge of wrapping, followed by a second line
-  s:text <- new [abcd
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor right after empty line
-  assume-console [
-    left-click 2, 0
-    press left-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1  # previous row
-    4 <- 4  # end of wrapped line
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-# todo: ctrl-left: previous word-start
-
-# up arrow
-
-scenario editor-moves-to-previous-line-with-up-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 1
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a0bc      .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-key> [
-  {
-    move-to-previous-line?:bool <- equal k, 65517/up-arrow
-    break-unless move-to-previous-line?
-    <begin-move-cursor>
-    move-to-previous-line editor
-    undo-coalesce-tag:num <- copy 3/up-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-to-previous-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  already-at-top?:bool <- lesser-or-equal cursor-row, 1/top
-  {
-    # if cursor not at top, move it
-    break-if already-at-top?
-    # if not at newline, move to start of line (previous newline)
-    # then scan back another line
-    # if either step fails, give up without modifying cursor or coordinates
-    curr:&:duplex-list:char <- copy before-cursor
-    old:&:duplex-list:char <- copy curr
-    {
-      at-left?:bool <- equal cursor-column, left
-      break-if at-left?
-      curr <- before-previous-screen-line curr, editor
-      no-motion?:bool <- equal curr, old
-      return-if no-motion?
-    }
-    {
-      curr <- before-previous-screen-line curr, editor
-      no-motion?:bool <- equal curr, old
-      return-if no-motion?
-    }
-    before-cursor <- copy curr
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    cursor-row <- subtract cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    # scan ahead to right column or until end of line
-    target-column:num <- copy cursor-column
-    cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    {
-      done?:bool <- greater-or-equal cursor-column, target-column
-      break-if done?
-      curr:&:duplex-list:char <- next before-cursor
-      break-unless curr
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      #
-      before-cursor <- copy curr
-      *editor <- put *editor, before-cursor:offset, before-cursor
-      cursor-column <- add cursor-column, 1
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      loop
-    }
-  }
-]
-
-# Takes a pointer into the doubly-linked list, scans back to before start of
-# previous *wrapped* line.
-# Returns original if no next newline.
-# Beware: never return null pointer.
-def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- copy in
-  c:char <- get *curr, value:offset
-  # compute max, number of characters to skip
-  #   1 + len%(width-1)
-  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
-  sentinel:&:duplex-list:char <- get *editor, data:offset
-  len:num <- previous-line-length curr, sentinel
-  {
-    break-if len
-    # empty line; just skip this newline
-    prev:&:duplex-list:char <- prev curr
-    return-unless prev, curr
-    return prev
-  }
-  _, max:num <- divide-with-remainder len, max-line-length
-  # remainder 0 => scan one width-worth
-  {
-    break-if max
-    max <- copy max-line-length
-  }
-  max <- add max, 1
-  count:num <- copy 0
-  # skip 'max' characters
-  {
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    prev:&:duplex-list:char <- prev curr
-    break-unless prev
-    curr <- copy prev
-    count <- add count, 1
-    loop
-  }
-  return curr
-]
-
-scenario editor-adjusts-column-at-previous-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [ab
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 3
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .ab0       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-adjusts-column-at-empty-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 2, 3
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-moves-to-previous-line-from-zero-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  # start out with three lines
-  s:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # click on the third line and hit up-arrow, so you end up just after a newline
-  assume-console [
-    left-click 3, 0
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0def      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-moves-to-previous-line-from-left-margin [
-  local-scope
-  assume-screen 10/width, 5/height
-  # start out with three lines
-  s:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor s, 1/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # click on the third line and hit up-arrow, so you end up just after a newline
-  assume-console [
-    left-click 3, 1
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    . abc      .
-    . 0def     .
-    . ghi      .
-    . ┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-moves-to-top-line-in-presence-of-wrapped-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abcde], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd↩     .
-    .e         .
-    .┈┈┈┈┈     .
-  ]
-  $clear-trace
-  assume-console [
-    left-click 2, 0
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0abc↩     .
-    .de        .
-    .┈┈┈┈┈     .
-  ]
-]
-
-scenario editor-moves-to-top-line-in-presence-of-wrapped-line-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-defgh]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .defg↩     .
-    .h         .
-    .┈┈┈┈┈     .
-  ]
-  $clear-trace
-  assume-console [
-    left-click 3, 0
-    press up-arrow
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .defg↩     .
-    .h         .
-    .┈┈┈┈┈     .
-  ]
-]
-
-# down arrow
-
-scenario editor-moves-to-next-line-with-down-arrow [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [abc
-def]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # cursor starts out at (1, 0)
-  assume-console [
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # ..and ends at (2, 0)
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .0def      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-special-key> [
-  {
-    move-to-next-line?:bool <- equal k, 65516/down-arrow
-    break-unless move-to-next-line?
-    <begin-move-cursor>
-    move-to-next-line editor, screen-height
-    undo-coalesce-tag:num <- copy 4/down-arrow
-    <end-move-cursor>
-    return
-  }
-]
-
-def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [
-  local-scope
-  load-inputs
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  last-line:num <- subtract screen-height, 1
-  bottom:num <- get *editor, bottom:offset
-  at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line
-  return-unless before-cursor
-  next:&:duplex-list:char <- next before-cursor
-  return-unless next
-  already-at-bottom?:bool <- greater-or-equal cursor-row, last-line
-    # if cursor not at bottom, move it
-    return-if already-at-bottom?
-    target-column:num <- copy cursor-column
-    # scan to start of next line
-    {
-      next:&:duplex-list:char <- next before-cursor
-      break-unless next
-      done?:bool <- greater-or-equal cursor-column, right
-      break-if done?
-      cursor-column <- add cursor-column, 1
-      before-cursor <- copy next
-      c:char <- get *next, value:offset
-      at-newline?:bool <- equal c, 10/newline
-      break-if at-newline?
-      loop
-    }
-    return-unless next
-    cursor-row <- add cursor-row, 1
-    cursor-column <- copy left
-    {
-      next:&:duplex-list:char <- next before-cursor
-      break-unless next
-      c:char <- get *next, value:offset
-      at-newline?:bool <- equal c, 10/newline
-      break-if at-newline?
-      done?:bool <- greater-or-equal cursor-column, target-column
-      break-if done?
-      cursor-column <- add cursor-column, 1
-      before-cursor <- copy next
-      loop
-    }
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    *editor <- put *editor, cursor-row:offset, cursor-row
-]
-
-scenario editor-adjusts-column-at-next-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # second line is shorter than first
-  s:text <- new [abcde
-fg
-hi]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # move to end of first line, then press down
-  assume-console [
-    left-click 1, 8
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor doesn't go vertically down, it goes to end of shorter line
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abcde     .
-    .fg0       .
-    .hi        .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-# ctrl-a/home - move cursor to start of line
-
-scenario editor-moves-to-start-of-line-with-ctrl-a [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line, press ctrl-a
-  assume-console [
-    left-click 2, 3
-    press ctrl-a
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    4 <- 2
-    5 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    move-to-start-of-line?:bool <- equal c, 1/ctrl-a
-    break-unless move-to-start-of-line?
-    <begin-move-cursor>
-    move-to-start-of-screen-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    move-to-start-of-line?:bool <- equal k, 65521/home
-    break-unless move-to-start-of-line?
-    <begin-move-cursor>
-    move-to-start-of-screen-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-# handles wrapped lines
-# precondition: cursor-column should be in a consistent state
-def move-to-start-of-screen-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  # update cursor column
-  left:num <- get *editor, left:offset
-  col:num <- get *editor, cursor-column:offset
-  # update before-cursor
-  curr:&:duplex-list:char <- get *editor, before-cursor:offset
-  # while not at start of line, move
-  {
-    done?:bool <- equal col, left
-    break-if done?
-    assert curr, [move-to-start-of-line tried to move before start of text]
-    curr <- prev curr
-    col <- subtract col, 1
-    loop
-  }
-  *editor <- put *editor, cursor-column:offset, col
-  *editor <- put *editor, before-cursor:offset, curr
-]
-
-scenario editor-moves-to-start-of-line-with-ctrl-a-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press ctrl-a
-  assume-console [
-    left-click 1, 3
-    press ctrl-a
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    4 <- 1
-    5 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-line-with-home [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  $clear-trace
-  # start on second line, press 'home'
-  assume-console [
-    left-click 2, 3
-    press home
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    3 <- 2
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-line-with-home-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press 'home'
-  assume-console [
-    left-click 1, 3
-    press home
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of line
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-start-of-screen-line-with-ctrl-a [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [123456], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1234↩     .
-    .56        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # start on second line, press ctrl-a then up
-  assume-console [
-    left-click 2, 1
-    press ctrl-a
-    press up-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to start of first line
-  memory-should-contain [
-    4 <- 1  # cursor-row
-    5 <- 0  # cursor-column
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # make sure before-cursor is in sync
-  assume-console [
-    type [a]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .a123↩     .
-    .456       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1  # cursor-row
-    5 <- 1  # cursor-column
-  ]
-]
-
-# ctrl-e/end - move cursor to end of line
-
-scenario editor-moves-to-end-of-line-with-ctrl-e [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press ctrl-e
-  assume-console [
-    left-click 1, 1
-    press ctrl-e
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-  # editor inserts future characters at cursor
-  assume-console [
-    type [z]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 4
-  ]
-  screen-should-contain [
-    .          .
-    .123z      .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 1, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    move-to-end-of-line?:bool <- equal c, 5/ctrl-e
-    break-unless move-to-end-of-line?
-    <begin-move-cursor>
-    move-to-end-of-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-after <handle-special-key> [
-  {
-    move-to-end-of-line?:bool <- equal k, 65520/end
-    break-unless move-to-end-of-line?
-    <begin-move-cursor>
-    move-to-end-of-line editor
-    undo-coalesce-tag:num <- copy 0/never
-    <end-move-cursor>
-    return false/don't-render
-  }
-]
-
-def move-to-end-of-line editor:&:editor -> editor:&:editor [
-  local-scope
-  load-inputs
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  right:num <- get *editor, right:offset
-  # while not at end of line, move
-  {
-    next:&:duplex-list:char <- next before-cursor
-    break-unless next  # end of text
-    nextc:char <- get *next, value:offset
-    at-end-of-line?:bool <- equal nextc, 10/newline
-    break-if at-end-of-line?
-    cursor-column <- add cursor-column, 1
-    at-right?:bool <- equal cursor-column, right
-    break-if at-right?
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    before-cursor <- copy next
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    loop
-  }
-]
-
-scenario editor-moves-to-end-of-line-with-ctrl-e-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press ctrl-e
-  assume-console [
-    left-click 2, 1
-    press ctrl-e
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    4 <- 2
-    5 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-line-with-end [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press 'end'
-  assume-console [
-    left-click 1, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-line-with-end-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press 'end'
-  assume-console [
-    left-click 2, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    3 <- 2
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-moves-to-end-of-wrapped-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123456
-789]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press 'end'
-  assume-console [
-    left-click 1, 1
-    press end
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves to end of line
-  memory-should-contain [
-    10 <- 1
-    11 <- 3
-  ]
-  # no prints
-  check-trace-count-for-label 0, [print-character]
-  # before-cursor is also consistent
-  assume-console [
-    type [a]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .123a↩     .
-    .456       .
-    .789       .
-    .┈┈┈┈┈     .
-  ]
-]
-
-# ctrl-u - delete text from start of line until (but not at) cursor
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line, press ctrl-u
-  assume-console [
-    left-click 2, 2
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .6         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    delete-to-start-of-line?:bool <- equal c, 21/ctrl-u
-    break-unless delete-to-start-of-line?
-    <begin-delete-to-start-of-line>
-    deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor
-    <end-delete-to-start-of-line>
-    go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells
-    return
-  }
-]
-
-def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  curr-column:num <- get *editor, cursor-column:offset
-  # accumulate the current line as text and render it
-  buf:&:buffer:char <- new-buffer 30  # accumulator for the text we need to render
-  curr:&:duplex-list:char <- get *editor, before-cursor:offset
-  i:num <- copy curr-column
-  right:num <- get *editor, right:offset
-  {
-    # if we have a wrapped line, give up and render the whole screen
-    wrap?:bool <- greater-or-equal i, right
-    return-if wrap?, true/go-render
-    curr <- next curr
-    break-unless curr
-    c:char <- get *curr, value:offset
-    b:bool <- equal c, 10
-    break-if b
-    buf <- append buf, c
-    i <- add i, 1
-    loop
-  }
-  # if the line used to be wrapped, give up and render the whole screen
-  num-deleted-cells:num <- length deleted-cells
-  old-row-len:num <- add i, num-deleted-cells
-  left:num <- get *editor, left:offset
-  end:num <- subtract right, left
-  wrap?:bool <- greater-or-equal old-row-len, end
-  return-if wrap?, true/go-render
-  curr-line:text <- buffer-to-array buf
-  curr-row:num <- get *editor, cursor-row:offset
-  render-code screen, curr-line, curr-column, right, curr-row
-  return false/dont-render
-]
-
-def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [
-  local-scope
-  load-inputs
-  # compute range to delete
-  init:&:duplex-list:char <- get *editor, data:offset
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  start:&:duplex-list:char <- copy before-cursor
-  end:&:duplex-list:char <- next before-cursor
-  {
-    at-start-of-text?:bool <- equal start, init
-    break-if at-start-of-text?
-    curr:char <- get *start, value:offset
-    at-start-of-line?:bool <- equal curr, 10/newline
-    break-if at-start-of-line?
-    start <- prev start
-    assert start, [delete-to-start-of-line tried to move before start of text]
-    loop
-  }
-  # snip it out
-  result:&:duplex-list:char <- next start
-  remove-between start, end
-  # adjust cursor
-  before-cursor <- copy start
-  *editor <- put *editor, before-cursor:offset, before-cursor
-  left:num <- get *editor, left:offset
-  *editor <- put *editor, cursor-column:offset, left
-  # if the line wrapped before, we may need to adjust cursor-row as well
-  right:num <- get *editor, right:offset
-  width:num <- subtract right, left
-  num-deleted:num <- length result
-  cursor-row-adjustment:num <- divide-with-remainder num-deleted, width
-  return-unless cursor-row-adjustment
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-row <- subtract cursor-row, cursor-row-adjustment
-  put *editor, cursor-row:offset, cursor-row
-]
-
-def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless s
-  color:num <- copy 7/white
-  column:num <- copy left
-  screen <- move-cursor screen, row, column
-  screen-height:num <- screen-height screen
-  i:num <- copy 0
-  len:num <- length *s
-  {
-    +next-character
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    c:char <- index *s, i
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      {
-        done?:bool <- greater-than column, right
-        break-if done?
-        space:char <- copy 32/space
-        print screen, space
-        column <- add column, 1
-        loop
-      }
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      i <- add i, 1
-      loop +next-character
-    }
-    {
-      # at right? wrap.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment i
-      loop +next-character
-    }
-    i <- add i, 1
-    print screen, c, color
-    column <- add column, 1
-    loop
-  }
-  was-at-left?:bool <- equal column, left
-  clear-line-until screen, right
-  {
-    break-if was-at-left?
-    row <- add row, 1
-  }
-  move-cursor screen, row, left
-]
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line (no newline before), press ctrl-u
-  assume-console [
-    left-click 1, 2
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .3         .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of line, press ctrl-u
-  assume-console [
-    left-click 1, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .          .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-final-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of final line, press ctrl-u
-  assume-console [
-    left-click 2, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to start of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u [
-  local-scope
-  assume-screen 10/width, 10/height
-  # first line starts out wrapping
-  s:text <- new [123456
-789]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1234↩     .
-    .56        .
-    .789       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # ctrl-u enough of the first line that it's no longer wrapping
-  assume-console [
-    left-click 1, 3
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # entire screen needs to be refreshed
-  screen-should-contain [
-    .          .
-    .456       .
-    .789       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  check-trace-count-for-label 45, [print-character]
-]
-
-# sometimes hitting ctrl-u needs to adjust the cursor row
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-2 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-345678
-9]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .3456↩     .
-    .78        .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # position cursor on screen line after the wrap and hit ctrl-u
-  assume-console [
-    left-click 4, 1  # on '8'
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .8         .
-    .9         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # cursor moves up one screen line
-  memory-should-contain [
-    10 <- 3  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-# line wrapping twice (taking up 3 screen lines)
-scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u-3 [
-  local-scope
-  assume-screen 10/width, 10/height
-  # third line starts out wrapping
-  s:text <- new [1
-2
-3456789abcd
-e]
-  e:&:editor <- new-editor s, 0/left, 5/right
-  editor-render screen, e
-  assume-console [
-    left-click 4, 1  # on '8'
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .3456↩     .
-    .789a↩     .
-    .bcd       .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  assume-console [
-    left-click 5, 1
-    press ctrl-u
-  ]
-  run [
-    editor-event-loop screen, console, e
-    10:num/raw <- get *e, cursor-row:offset
-    11:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .2         .
-    .cd        .
-    .e         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  # make sure we adjusted cursor-row
-  memory-should-contain [
-    10 <- 3  # cursor-row
-    11 <- 0  # cursor-column
-  ]
-]
-
-# ctrl-k - delete text from cursor to end of line (but not the newline)
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on first line, press ctrl-k
-  assume-console [
-    left-click 1, 1
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to end of line
-  screen-should-contain [
-    .          .
-    .1         .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 9, [print-character]
-]
-
-after <handle-special-character> [
-  {
-    delete-to-end-of-line?:bool <- equal c, 11/ctrl-k
-    break-unless delete-to-end-of-line?
-    <begin-delete-to-end-of-line>
-    deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor
-    <end-delete-to-end-of-line>
-    # checks if we can do a minimal render and if we can it will do a minimal render
-    go-render?:bool <- minimal-render-for-ctrl-k screen, editor, deleted-cells
-    return
-  }
-]
-
-def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  # if we deleted nothing, there's nothing to render
-  return-unless deleted-cells, false/dont-render
-  # if the line used to wrap before, give up and render the whole screen
-  curr-column:num <- get *editor, cursor-column:offset
-  num-deleted-cells:num <- length deleted-cells
-  old-row-len:num <- add curr-column, num-deleted-cells
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  end:num <- subtract right, left
-  wrap?:bool <- greater-or-equal old-row-len, end
-  return-if wrap?, true/go-render
-  clear-line-until screen, right
-  return false/dont-render
-]
-
-def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [
-  local-scope
-  load-inputs
-  # compute range to delete
-  start:&:duplex-list:char <- get *editor, before-cursor:offset
-  end:&:duplex-list:char <- next start
-  {
-    at-end-of-text?:bool <- equal end, null
-    break-if at-end-of-text?
-    curr:char <- get *end, value:offset
-    at-end-of-line?:bool <- equal curr, 10/newline
-    break-if at-end-of-line?
-    end <- next end
-    loop
-  }
-  # snip it out
-  result <- next start
-  remove-between start, end
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start on second line (no newline after), press ctrl-k
-  assume-console [
-    left-click 2, 1
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes to end of line
-  screen-should-contain [
-    .          .
-    .123       .
-    .4         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 9, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start at end of line
-  assume-console [
-    left-click 1, 2
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes just last character
-  screen-should-contain [
-    .          .
-    .12        .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 8, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of line
-  assume-console [
-    left-click 1, 3
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes nothing
-  screen-should-contain [
-    .          .
-    .123       .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 7, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start at end of text
-  assume-console [
-    left-click 2, 2
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes just the final character
-  screen-should-contain [
-    .          .
-    .123       .
-    .45        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 8, [print-character]
-]
-
-scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [
-  local-scope
-  assume-screen 10/width, 5/height
-  s:text <- new [123
-456]
-  e:&:editor <- new-editor s, 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  # start past end of text
-  assume-console [
-    left-click 2, 3
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor deletes nothing
-  screen-should-contain [
-    .          .
-    .123       .
-    .456       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # no prints necessary
-  check-trace-count-for-label 0, [print-character]
-]
-
-scenario editor-deletes-to-end-of-wrapped-line-with-ctrl-k [
-  local-scope
-  assume-screen 10/width, 5/height
-  # create an editor with the first line wrapping to a second screen row
-  s:text <- new [1234
-567]
-  e:&:editor <- new-editor s, 0/left, 4/right
-  editor-render screen, e
-  $clear-trace
-  # delete all of the first wrapped line
-  assume-console [
-    press ctrl-k
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # screen shows an empty unwrapped first line
-  screen-should-contain [
-    .          .
-    .          .
-    .567       .
-    .┈┈┈┈      .
-    .          .
-  ]
-  # entire screen is refreshed
-  check-trace-count-for-label 16, [print-character]
-]
-
-# takes a pointer into the doubly-linked list, scans ahead at most 'max'
-# positions until the next newline
-# returns original if no next newline
-# beware: never return null pointer.
-def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [
-  local-scope
-  load-inputs
-  count:num <- copy 0
-  curr:&:duplex-list:char <- copy original
-  # skip the initial newline if it exists
-  {
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-unless at-newline?
-    curr <- next curr
-    count <- add count, 1
-  }
-  {
-    return-unless curr, original
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    c:char <- get *curr, value:offset
-    at-newline?:bool <- equal c, 10/newline
-    break-if at-newline?
-    curr <- next curr
-    count <- add count, 1
-    loop
-  }
-  return-unless curr, original
-  return curr
-]
-
-# ctrl-/ - comment/uncomment current line
-
-after <handle-special-character> [
-  {
-    comment-toggle?:bool <- equal c, 31/ctrl-slash
-    break-unless comment-toggle?
-    cursor-column:num <- get *editor, cursor-column:offset
-    data:&:duplex-list:char <- get *editor, data:offset
-    <begin-insert-character>
-    before-line-start:&:duplex-list:char <- before-start-of-screen-line editor
-    line-start:&:duplex-list:char <- next before-line-start
-    commented-out?:bool <- match line-start, [#? ]  # comment prefix
-    {
-      break-unless commented-out?
-      # uncomment
-      data <- remove line-start, 3/length-comment-prefix, data
-      cursor-column <- subtract cursor-column, 3/length-comment-prefix
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      go-render? <- render-line-from-start screen, editor, 3/size-of-comment-leader
-    }
-    {
-      break-if commented-out?
-      # comment
-      insert before-line-start, [#? ]
-      cursor-column <- add cursor-column, 3/length-comment-prefix
-      *editor <- put *editor, cursor-column:offset, cursor-column
-      go-render? <- render-line-from-start screen, editor, 0
-    }
-    <end-insert-character>
-    return
-  }
-]
-
-# Render just from the start of the current line, and only if it wasn't
-# wrapping before (include margin) and isn't wrapping now. Otherwise just tell
-# the caller to go-render? the entire screen.
-def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> go-render?:bool, screen:&:screen [
-  local-scope
-  load-inputs
-  before-line-start:&:duplex-list:char <- before-start-of-screen-line editor
-  line-start:&:duplex-list:char <- next before-line-start
-  color:num <- copy 7/white
-  left:num <- get *editor, left:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  screen <- move-cursor screen, cursor-row, left
-  right:num <- get *editor, right:offset
-  end:num <- subtract right, right-margin
-  i:num <- copy 0
-  curr:&:duplex-list:char <- copy line-start
-  {
-    render-all?:bool <- greater-or-equal i, end
-    return-if render-all?, true/go-render
-    break-unless curr
-    c:char <- get *curr, value:offset
-    newline?:bool <- equal c, 10/newline
-    break-if newline?
-    color <- get-color color, c
-    print screen, c, color
-    curr <- next curr
-    i <- add i, 1
-    loop
-  }
-  clear-line-until screen, right
-  return false/dont-render
-]
-
-def before-start-of-screen-line editor:&:editor -> result:&:duplex-list:char [
-  local-scope
-  load-inputs
-  cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  {
-    next:&:duplex-list:char <- next cursor
-    break-unless next
-    cursor <- copy next
-  }
-  result <- before-previous-screen-line cursor, editor
-]
-
-scenario editor-comments-empty-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 5/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#?        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 5, [print-character]
-]
-
-scenario editor-comments-at-start-of-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#? ab     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 3
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-comments-at-end-of-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [ab], 0/left, 10/right
-  editor-render screen, e
-  $clear-trace
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .#? ab     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    4 <- 1
-    5 <- 5
-  ]
-  check-trace-count-for-label 10, [print-character]
-  # toggle to uncomment
-  $clear-trace
-  assume-console [
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-    4:num/raw <- get *e, cursor-row:offset
-    5:num/raw <- get *e, cursor-column:offset
-  ]
-  screen-should-contain [
-    .          .
-    .ab        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  check-trace-count-for-label 10, [print-character]
-]
-
-scenario editor-comments-almost-wrapping-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor starts out with a non-wrapping line
-  e:&:editor <- new-editor [abcd], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .abcd      .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # on commenting the line is now wrapped
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .#? a↩     .
-    .bcd       .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
-
-scenario editor-uncomments-just-wrapping-line [
-  local-scope
-  assume-screen 10/width, 5/height
-  # editor starts out with a comment that wraps the line
-  e:&:editor <- new-editor [#? ab], 0/left, 5/right
-  editor-render screen, e
-  screen-should-contain [
-    .          .
-    .#? a↩     .
-    .b         .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-  $clear-trace
-  # on uncommenting the line is no longer wrapped
-  assume-console [
-    left-click 1, 7
-    press ctrl-slash
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .ab        .
-    .┈┈┈┈┈     .
-    .          .
-  ]
-]
diff --git a/archive/2.vm/sandbox/004-programming-environment.mu b/archive/2.vm/sandbox/004-programming-environment.mu
deleted file mode 100644
index 1454144b..00000000
--- a/archive/2.vm/sandbox/004-programming-environment.mu
+++ /dev/null
@@ -1,268 +0,0 @@
-## putting the environment together out of editors
-
-def! main [
-  local-scope
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  env:&:environment <- new-programming-environment null/filesystem, null/screen
-  render-all null/screen, env, render
-  event-loop null/screen, null/console, env, null/filesystem
-]
-
-container environment [
-  current-sandbox:&:editor
-]
-
-def new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text -> result:&:environment [
-  local-scope
-  load-inputs
-  width:num <- screen-width screen
-  result <- new environment:type
-  # sandbox editor
-  current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, 0/left, width/right
-  *result <- put *result, current-sandbox:offset, current-sandbox
-  <programming-environment-initialization>
-]
-
-def event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources -> screen:&:screen, console:&:console, env:&:environment, resources:&:resources [
-  local-scope
-  load-inputs
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  # if we fall behind we'll stop updating the screen, but then we have to
-  # render the entire screen when we catch up.
-  # todo: test this
-  render-all-on-no-more-events?:bool <- copy false
-  {
-    # looping over each (keyboard or touch) event as it occurs
-    +next-event
-    e:event, found?:bool, quit?:bool, console <- read-event console
-    loop-unless found?
-    break-if quit?  # only in tests
-    trace 10, [app], [next-event]
-    <handle-event>
-    # check for global events that will trigger regardless of which editor has focus
-    {
-      k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant
-      break-unless is-keycode?
-      <global-keypress>
-    }
-    {
-      c:char, is-unicode?:bool <- maybe-convert e:event, text:variant
-      break-unless is-unicode?
-      <global-type>
-    }
-    # 'touch' event
-    {
-      t:touch-event, is-touch?:bool <- maybe-convert e:event, touch:variant
-      break-unless is-touch?
-      # ignore all but 'left-click' events for now
-      # todo: test this
-      touch-type:num <- get t, type:offset
-      is-left-click?:bool <- equal touch-type, 65513/mouse-left
-      loop-unless is-left-click?, +next-event
-      click-row:num <- get t, row:offset
-      click-column:num <- get t, column:offset
-      # later exceptions for non-editor touches will go here
-      <global-touch>
-      move-cursor current-sandbox, screen, t
-      screen <- update-cursor screen, current-sandbox, env
-      loop +next-event
-    }
-    # 'resize' event - redraw editor
-    # todo: test this after supporting resize in assume-console
-    {
-      r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant
-      break-unless is-resize?
-      env, screen <- resize screen, env
-      screen <- render-all screen, env, render-without-moving-cursor
-      loop +next-event
-    }
-    # not global and not a touch event
-    {
-      render?:bool <- handle-keyboard-event screen, current-sandbox, e:event
-      # try to batch up rendering if there are more events queued up
-      render-all-on-no-more-events? <- or render-all-on-no-more-events?, render?
-      more-events?:bool <- has-more-events? console
-      {
-        break-if more-events?
-        break-unless render-all-on-no-more-events?
-        render-all-on-no-more-events? <- copy false
-        screen <- render-all screen, env, render
-      }
-      screen <- update-cursor screen, current-sandbox, env
-    }
-    loop
-  }
-]
-
-def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [
-  local-scope
-  load-inputs
-  clear-screen screen  # update screen dimensions
-  width:num <- screen-width screen
-  # update sandbox editor
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  right:num <- subtract width, 1
-  *current-sandbox <- put *current-sandbox right:offset, right
-  # reset cursor
-  *current-sandbox <- put *current-sandbox, cursor-row:offset, 1
-  *current-sandbox <- put *current-sandbox, cursor-column:offset, 0
-]
-
-# Variant of 'render' that updates cursor-row and cursor-column based on
-# before-cursor (rather than the other way around). If before-cursor moves
-# off-screen, it resets cursor-row and cursor-column.
-def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [
-  local-scope
-  load-inputs
-  return-unless editor, 1/top, 0/left
-  left:num <- get *editor, left:offset
-  screen-height:num <- screen-height screen
-  right:num <- get *editor, right:offset
-  curr:&:duplex-list:char <- get *editor, top-of-screen:offset
-  prev:&:duplex-list:char <- copy curr  # just in case curr becomes null and we can't compute prev
-  curr <- next curr
-  color:num <- copy 7/white
-  row:num <- copy 1/top
-  column:num <- copy left
-  # save before-cursor
-  old-before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  # initialze cursor-row/cursor-column/before-cursor to the top of the screen
-  # by default
-  *editor <- put *editor, cursor-row:offset, row
-  *editor <- put *editor, cursor-column:offset, column
-  top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset
-  *editor <- put *editor, before-cursor:offset, top-of-screen
-  screen <- move-cursor screen, row, column
-  {
-    +next-character
-    break-unless curr
-    off-screen?:bool <- greater-or-equal row, screen-height
-    break-if off-screen?
-    # if we find old-before-cursor still on the new resized screen, update
-    # editor.cursor-row and editor.cursor-column based on
-    # old-before-cursor
-    {
-      at-cursor?:bool <- equal old-before-cursor, prev
-      break-unless at-cursor?
-      *editor <- put *editor, cursor-row:offset, row
-      *editor <- put *editor, cursor-column:offset, column
-      *editor <- put *editor, before-cursor:offset, old-before-cursor
-    }
-    c:char <- get *curr, value:offset
-    <character-c-received>
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      clear-line-until screen, right
-      # skip to next line
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      curr <- next curr
-      prev <- next prev
-      loop +next-character
-    }
-    {
-      # at right? wrap. even if there's only one more letter left; we need
-      # room for clicking on the cursor after it.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment curr
-      loop +next-character
-    }
-    print screen, c, color
-    curr <- next curr
-    prev <- next prev
-    column <- add column, 1
-    loop
-  }
-  # save first character off-screen
-  *editor <- put *editor, bottom-of-screen:offset, curr
-  *editor <- put *editor, bottom:offset, row
-  return row, column
-]
-
-type render-recipe = (recipe (address screen) (address editor) -> number number (address screen) (address editor))
-
-def render-all screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 10, [app], [render all]
-  # top menu
-  trace 11, [app], [render top menu]
-  width:num <- screen-width screen
-  draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey
-  button-start:num <- subtract width, 20
-  button-on-screen?:bool <- greater-or-equal button-start, 0
-  assert button-on-screen?, [screen too narrow for menu]
-  screen <- move-cursor screen, 0/row, button-start
-  print screen, [ run (F4) ], 255/white, 161/reddish
-  #
-  screen <- render-sandbox-side screen, env, render-editor
-  <end-render-components>  # no early returns permitted
-  #
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  screen <- update-cursor screen, current-sandbox, env
-]
-
-# replaced in a later layer
-def render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 11, [app], [render sandboxes]
-  old-top-idx:num <- save-top-idx screen
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  left:num <- get *current-sandbox, left:offset
-  right:num <- get *current-sandbox, right:offset
-  row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox
-  # draw solid line after code (you'll see why in later layers)
-  draw-horizontal screen, row, left, right
-  row <- add row, 1
-  clear-screen-from screen, row, left, left, right
-  #
-  assert-no-scroll screen, old-top-idx
-]
-
-def update-cursor screen:&:screen, current-sandbox:&:editor, env:&:environment -> screen:&:screen [
-  local-scope
-  load-inputs
-  <update-cursor-special-cases>
-  cursor-row:num <- get *current-sandbox, cursor-row:offset
-  cursor-column:num <- get *current-sandbox, cursor-column:offset
-  screen <- move-cursor screen, cursor-row, cursor-column
-]
-
-scenario backspace-over-text [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 15/height
-  # recipes.mu is empty
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # run the code in the editors
-  assume-console [
-    type [a]
-    press backspace
-  ]
-  run [
-    event-loop screen, console, env, resources
-    10:num/raw <- get *screen, cursor-row:offset
-    11:num/raw <- get *screen, cursor-column:offset
-  ]
-  memory-should-contain [
-    10 <- 1
-    11 <- 0
-  ]
-]
diff --git a/archive/2.vm/sandbox/005-sandbox.mu b/archive/2.vm/sandbox/005-sandbox.mu
deleted file mode 100644
index 632a5df1..00000000
--- a/archive/2.vm/sandbox/005-sandbox.mu
+++ /dev/null
@@ -1,1081 +0,0 @@
-## running code from the editor and creating sandboxes
-#
-# Running code in the sandbox editor prepends its contents to a list of
-# (non-editable) sandboxes below the editor, showing the result and maybe a
-# few other things (later layers).
-#
-# This layer draws the menubar buttons in non-editable sandboxes but they
-# don't do anything yet. Later layers implement each button.
-
-def! main [
-  local-scope
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  env:&:environment <- new-programming-environment null/filesystem, null/screen
-  env <- restore-sandboxes env, null/filesystem
-  render-all null/screen, env, render
-  event-loop null/screen, null/console, env, null/filesystem
-]
-
-container environment [
-  sandbox:&:sandbox  # list of sandboxes, from top to bottom. TODO: switch to &:list:sandbox
-  render-from:num
-  number-of-sandboxes:num
-]
-
-after <programming-environment-initialization> [
-  *result <- put *result, render-from:offset, -1
-]
-
-container sandbox [
-  data:text
-  response:text
-  # coordinates to track clicks
-  # constraint: will be 0 for sandboxes at positions before env.render-from
-  starting-row-on-screen:num
-  code-ending-row-on-screen:num  # past end of code
-  screen:&:screen  # prints in the sandbox go here
-  next-sandbox:&:sandbox
-]
-
-scenario run-and-show-results [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 15/height
-  # recipes.mu is empty
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, [divide-with-remainder 11, 3]
-  render-all screen, env, render
-  # run the code in the editors
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints the results
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .divide-with-remainder 11, 3                       .
-    .3                                                 .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  screen-should-contain-in-color 7/white, [
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .divide-with-remainder 11, 3                       .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  screen-should-contain-in-color 245/grey, [
-    .                                                  .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .3                                                 .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # run another command
-  assume-console [
-    left-click 1, 80
-    type [add 2, 2]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints both sandboxes
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .divide-with-remainder 11, 3                       .
-    .3                                                 .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-after <global-keypress> [
-  # F4? load all code and run all sandboxes.
-  {
-    do-run?:bool <- equal k, 65532/F4
-    break-unless do-run?
-    screen <- update-status screen, [running...       ], 245/grey
-    error?:bool <- run-sandboxes env, resources, screen
-    # F4 might update warnings and results on both sides
-    screen <- render-all screen, env, render
-    {
-      break-if error?
-      screen <- update-status screen, [                 ], 245/grey
-    }
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [
-  local-scope
-  load-inputs
-  errors-found?:bool <- update-recipes env, resources, screen
-  # check contents of editor
-  <begin-run-sandboxes>
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  {
-    sandbox-contents:text <- editor-contents current-sandbox
-    break-unless sandbox-contents
-    # if contents exist, first save them
-    # run them and turn them into a new sandbox
-    new-sandbox:&:sandbox <- new sandbox:type
-    *new-sandbox <- put *new-sandbox, data:offset, sandbox-contents
-    # push to head of sandbox list
-    dest:&:sandbox <- get *env, sandbox:offset
-    *new-sandbox <- put *new-sandbox, next-sandbox:offset, dest
-    *env <- put *env, sandbox:offset, new-sandbox
-    # update sandbox count
-    sandbox-count:num <- get *env, number-of-sandboxes:offset
-    sandbox-count <- add sandbox-count, 1
-    *env <- put *env, number-of-sandboxes:offset, sandbox-count
-    # save all sandboxes
-    # needs to be before running them, in case we die when running
-    save-sandboxes env, resources
-    # clear sandbox editor
-    init:&:duplex-list:char <- push 167/§, null
-    *current-sandbox <- put *current-sandbox, data:offset, init
-    *current-sandbox <- put *current-sandbox, top-of-screen:offset, init
-  }
-  # run all sandboxes
-  curr:&:sandbox <- get *env, sandbox:offset
-  idx:num <- copy 0
-  {
-    break-unless curr
-    curr <- update-sandbox curr, env, idx
-    curr <- get *curr, next-sandbox:offset
-    idx <- add idx, 1
-    loop
-  }
-  <end-run-sandboxes>
-  {
-    break-if resources  # ignore this in tests
-    $system [./snapshot_lesson]
-  }
-]
-
-# load code from disk
-# replaced in a later layer (whereupon errors-found? will actually be set)
-def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, screen:&:screen [
-  local-scope
-  load-inputs
-  in:text <- slurp resources, [lesson/recipes.mu]
-  reload in
-  errors-found? <- copy false
-]
-
-# replaced in a later layer
-def update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  response:text, _, fake-screen:&:screen <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-]
-
-def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  screen <- move-cursor screen, 0, 2
-  screen <- print screen, msg, color, 238/grey/background
-]
-
-def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [
-  local-scope
-  load-inputs
-  trace 11, [app], [save sandboxes]
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  # first clear previous versions, in case we deleted some sandbox
-  $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
-  curr:&:sandbox <- get *env, sandbox:offset
-  idx:num <- copy 0
-  {
-    break-unless curr
-    resources <- save-sandbox resources, curr, idx
-    idx <- add idx, 1
-    curr <- get *curr, next-sandbox:offset
-    loop
-  }
-]
-
-def save-sandbox resources:&:resources, sandbox:&:sandbox, sandbox-index:num -> resources:&:resources [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  filename:text <- append [lesson/], sandbox-index
-  resources <- dump resources, filename, data
-  <end-save-sandbox>
-]
-
-def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [
-  local-scope
-  load-inputs
-  trace 11, [app], [render sandbox side]
-  old-top-idx:num <- save-top-idx screen
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  row:num, column:num <- copy 1, 0
-  left:num <- get *current-sandbox, left:offset
-  right:num <- get *current-sandbox, right:offset
-  # render sandbox editor
-  render-from:num <- get *env, render-from:offset
-  {
-    render-current-sandbox?:bool <- equal render-from, -1
-    break-unless render-current-sandbox?
-    row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox
-  }
-  # render sandboxes
-  draw-horizontal screen, row, left, right
-  sandbox:&:sandbox <- get *env, sandbox:offset
-  row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from, 0, env
-  clear-rest-of-screen screen, row, left, right
-  #
-  assert-no-scroll screen, old-top-idx
-]
-
-def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  env:&:environment, _/optional <- next-input
-  return-unless sandbox
-  screen-height:num <- screen-height screen
-  hidden?:bool <- lesser-than idx, render-from
-  {
-    break-if hidden?
-    # render sandbox menu
-    row <- add row, 1
-    at-bottom?:bool <- greater-or-equal row, screen-height
-    return-if at-bottom?
-    screen <- move-cursor screen, row, left
-    screen <- render-sandbox-menu screen, idx, left, right
-    # save menu row so we can detect clicks to it later
-    *sandbox <- put *sandbox, starting-row-on-screen:offset, row
-    # render sandbox contents
-    row <- add row, 1
-    screen <- move-cursor screen, row, left
-    sandbox-data:text <- get *sandbox, data:offset
-    row, screen <- render-code screen, sandbox-data, left, right, row
-    *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row
-    # render sandbox warnings, screen or response, in that order
-    sandbox-response:text <- get *sandbox, response:offset
-    <render-sandbox-results>
-    {
-      sandbox-screen:&:screen <- get *sandbox, screen:offset
-      empty-screen?:bool <- fake-screen-is-empty? sandbox-screen
-      break-if empty-screen?
-      row, screen <- render-screen screen, sandbox-screen, left, right, row
-    }
-    {
-      break-unless empty-screen?
-      <render-sandbox-response>
-      row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row
-    }
-    +render-sandbox-end
-    at-bottom?:bool <- greater-or-equal row, screen-height
-    return-if at-bottom?
-    # draw solid line after sandbox
-    draw-horizontal screen, row, left, right
-  }
-  # if hidden, reset row attributes
-  {
-    break-unless hidden?
-    *sandbox <- put *sandbox, starting-row-on-screen:offset, 0
-    *sandbox <- put *sandbox, code-ending-row-on-screen:offset, 0
-    <end-render-sandbox-reset-hidden>
-  }
-  # draw next sandbox
-  next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-  next-idx:num <- add idx, 1
-  row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx, env
-]
-
-def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [
-  local-scope
-  load-inputs
-  move-cursor-to-column screen, left
-  edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right
-  print screen, sandbox-index, 232/dark-grey, 245/grey
-  start-buttons:num <- subtract edit-button-left, 1
-  clear-line-until screen, start-buttons, 245/grey
-  print screen, [edit], 232/black, 25/background-blue
-  clear-line-until screen, edit-button-right, 25/background-blue
-  print screen, [copy], 232/black, 58/background-green
-  clear-line-until screen, copy-button-right, 58/background-green
-  print screen, [delete], 232/black, 52/background-red
-  clear-line-until screen, right, 52/background-red
-]
-
-scenario skip-rendering-sandbox-menu-past-bottom-row [
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 6/height
-  # recipes.mu is empty
-  assume-resources [
-    [lesson/0] <- [|add 2, 2|]
-    [lesson/1] <- [|add 1, 1|]
-  ]
-  # create two sandboxes such that the top one just barely fills the screen
-  env:&:environment <- new-programming-environment resources, screen, []
-  env <- restore-sandboxes env, resources
-  run [
-    render-all screen, env, render
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .──────────────────────────────────────────────────.
-  ]
-]
-
-# divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons
-# delete-button-right == right
-# all left/right pairs are inclusive
-def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [
-  local-scope
-  load-inputs
-  start-buttons:num <- add left, 4/space-for-sandbox-index
-  buttons-space:num <- subtract right, start-buttons
-  button-width:num <- divide-with-remainder buttons-space, 3  # integer division
-  buttons-wide-enough?:bool <- greater-or-equal button-width, 8
-  assert buttons-wide-enough?, [sandbox must be at least 30 or so characters wide]
-  edit-button-left:num <- copy start-buttons
-  copy-button-left:num <- add start-buttons, button-width
-  edit-button-right:num <- subtract copy-button-left, 1
-  delete-button-left:num <- subtract right, button-width
-  copy-button-right:num <- subtract delete-button-left, 1
-]
-
-# print a text 's' to 'editor' in 'color' starting at 'row'
-# clear rest of last line, move cursor to next line
-def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless s
-  column:num <- copy left
-  screen <- move-cursor screen, row, column
-  screen-height:num <- screen-height screen
-  i:num <- copy 0
-  len:num <- length *s
-  {
-    +next-character
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    c:char <- index *s, i
-    {
-      # newline? move to left rather than 0
-      newline?:bool <- equal c, 10/newline
-      break-unless newline?
-      # clear rest of line in this window
-      {
-        done?:bool <- greater-than column, right
-        break-if done?
-        space:char <- copy 32/space
-        print screen, space
-        column <- add column, 1
-        loop
-      }
-      row <- add row, 1
-      column <- copy left
-      screen <- move-cursor screen, row, column
-      i <- add i, 1
-      loop +next-character
-    }
-    {
-      # at right? wrap.
-      at-right?:bool <- equal column, right
-      break-unless at-right?
-      # print wrap icon
-      wrap-icon:char <- copy 8617/loop-back-to-left
-      print screen, wrap-icon, 245/grey
-      column <- copy left
-      row <- add row, 1
-      screen <- move-cursor screen, row, column
-      # don't increment i
-      loop +next-character
-    }
-    i <- add i, 1
-    print screen, c, color
-    column <- add column, 1
-    loop
-  }
-  was-at-left?:bool <- equal column, left
-  clear-line-until screen, right
-  {
-    break-if was-at-left?
-    row <- add row, 1
-  }
-  move-cursor screen, row, left
-]
-
-scenario render-text-wraps-barely-long-lines [
-  local-scope
-  assume-screen 5/width, 5/height
-  run [
-    render-text screen, [abcde], 0/left, 4/right, 7/white, 1/row
-  ]
-  screen-should-contain [
-    .     .
-    .abcd↩.
-    .e    .
-    .     .
-  ]
-]
-
-# assumes programming environment has no sandboxes; restores them from previous session
-def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [
-  local-scope
-  load-inputs
-  # read all scenarios, pushing them to end of a list of scenarios
-  idx:num <- copy 0
-  curr:&:sandbox <- copy null
-  prev:&:sandbox <- copy null
-  {
-    filename:text <- append [lesson/], idx
-    contents:text <- slurp resources, filename
-    break-unless contents  # stop at first error; assuming file didn't exist
-                           # todo: handle empty sandbox
-    # create new sandbox for file
-    curr <- new sandbox:type
-    *curr <- put *curr, data:offset, contents
-    <end-restore-sandbox>
-    {
-      break-if idx
-      *env <- put *env, sandbox:offset, curr
-    }
-    {
-      break-unless idx
-      *prev <- put *prev, next-sandbox:offset, curr
-    }
-    idx <- add idx, 1
-    prev <- copy curr
-    loop
-  }
-  # update sandbox count
-  *env <- put *env, number-of-sandboxes:offset, idx
-]
-
-# print the fake sandbox screen to 'screen' with appropriate delimiters
-# leave cursor at start of next line
-def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  return-unless sandbox-screen
-  # print 'screen:'
-  row <- render-text screen, [screen:], left, right, 245/grey, row
-  screen <- move-cursor screen, row, left
-  # start printing sandbox-screen
-  column:num <- copy left
-  s-width:num <- screen-width sandbox-screen
-  s-height:num <- screen-height sandbox-screen
-  buf:&:@:screen-cell <- get *sandbox-screen, data:offset
-  stop-printing:num <- add left, s-width, 3
-  max-column:num <- min stop-printing, right
-  i:num <- copy 0
-  len:num <- length *buf
-  screen-height:num <- screen-height screen
-  {
-    done?:bool <- greater-or-equal i, len
-    break-if done?
-    done? <- greater-or-equal row, screen-height
-    break-if done?
-    column <- copy left
-    screen <- move-cursor screen, row, column
-    # initial leader for each row: two spaces and a '.'
-    space:char <- copy 32/space
-    print screen, space, 245/grey
-    print screen, space, 245/grey
-    full-stop:char <- copy 46/period
-    print screen, full-stop, 245/grey
-    column <- add left, 3
-    {
-      # print row
-      row-done?:bool <- greater-or-equal column, max-column
-      break-if row-done?
-      curr:screen-cell <- index *buf, i
-      c:char <- get curr, contents:offset
-      color:num <- get curr, color:offset
-      {
-        # damp whites down to grey
-        white?:bool <- equal color, 7/white
-        break-unless white?
-        color <- copy 245/grey
-      }
-      print screen, c, color
-      column <- add column, 1
-      i <- add i, 1
-      loop
-    }
-    # print final '.'
-    print screen, full-stop, 245/grey
-    column <- add column, 1
-    {
-      # clear rest of current line
-      line-done?:bool <- greater-than column, right
-      break-if line-done?
-      print screen, space
-      column <- add column, 1
-      loop
-    }
-    row <- add row, 1
-    loop
-  }
-]
-
-scenario run-updates-results [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 12/height
-  # define a recipe (no indent for the 'add' line below so column numbers are more obvious)
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      ||
-      |recipe foo [|
-      |  local-scope|
-      |  z:num <- add 2, 2|
-      |  reply z|
-      |]|
-    ]
-  ]
-  # sandbox editor contains an instruction without storing outputs
-  env:&:environment <- new-programming-environment resources, screen, [foo]  # contents of sandbox editor
-  render-all screen, env, render
-  $clear-trace
-  # run the code in the editors
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # the new sandbox should be saved to disk
-  trace-should-contain [
-    app: save sandboxes
-  ]
-  # make a change (incrementing one of the args to 'add'), then rerun
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      ||
-      |recipe foo [|
-      |  local-scope|
-      |  z:num <- add 2, 3|
-      |  reply z|
-      |]|
-    ]
-  ]
-  $clear-trace
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen updates the result on the right
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .5                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # no need to save sandboxes all over again
-  trace-should-not-contain [
-    app: save sandboxes
-  ]
-]
-
-scenario run-instruction-manages-screen-per-sandbox [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # empty recipes
-  assume-resources [
-  ]
-  # sandbox editor contains an instruction
-  env:&:environment <- new-programming-environment resources, screen, [print screen, 4]  # contents of sandbox editor
-  render-all screen, env, render
-  # run the code in the editor
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that it prints a little toy screen
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .print screen, 4                                   .
-    .screen:                                           .
-    .  .4                             .                .
-    .  .                              .                .
-    .  .                              .                .
-    .  .                              .                .
-    .  .                              .                .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-def editor-contents editor:&:editor -> result:text [
-  local-scope
-  load-inputs
-  buf:&:buffer:char <- new-buffer 80
-  curr:&:duplex-list:char <- get *editor, data:offset
-  # skip § sentinel
-  assert curr, [editor without data is illegal; must have at least a sentinel]
-  curr <- next curr
-  return-unless curr, null
-  {
-    break-unless curr
-    c:char <- get *curr, value:offset
-    buf <- append buf, c
-    curr <- next curr
-    loop
-  }
-  result <- buffer-to-array buf
-]
-
-scenario editor-provides-edited-contents [
-  local-scope
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [abc], 0/left, 10/right
-  assume-console [
-    left-click 1, 2
-    type [def]
-  ]
-  run [
-    editor-event-loop screen, console, e
-    s:text <- editor-contents e
-    1:@:char/raw <- copy *s
-  ]
-  memory-should-contain [
-    1:array:character <- [abdefc]
-  ]
-]
-
-# scrolling through sandboxes
-
-scenario scrolling-down-past-bottom-of-sandbox-editor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # initialize
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  assume-console [
-    # create a sandbox
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down'
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .␣   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-up'
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor displays again
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-# page-down updates render-from to scroll sandboxes
-after <global-keypress> [
-  {
-    page-down?:bool <- equal k, 65518/page-down
-    break-unless page-down?
-    sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless sandbox
-    # slide down if possible
-    {
-      render-from:num <- get *env, render-from:offset
-      number-of-sandboxes:num <- get *env, number-of-sandboxes:offset
-      max:num <- subtract number-of-sandboxes, 1
-      at-end?:bool <- greater-or-equal render-from, max
-      break-if at-end?
-      render-from <- add render-from, 1
-      *env <- put *env, render-from:offset, render-from
-    }
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-# update-cursor takes render-from into account
-after <update-cursor-special-cases> [
-  {
-    render-from:num <- get *env, render-from:offset
-    scrolling?:bool <- greater-or-equal render-from, 0
-    break-unless scrolling?
-    cursor-column:num <- get *current-sandbox, left:offset
-    screen <- move-cursor screen, 2/row, cursor-column  # highlighted sandbox will always start at row 2
-    return
-  }
-]
-
-# 'page-up' is like 'page-down': updates first-sandbox-to-render when necessary
-after <global-keypress> [
-  {
-    page-up?:bool <- equal k, 65519/page-up
-    break-unless page-up?
-    render-from:num <- get *env, render-from:offset
-    at-beginning?:bool <- equal render-from, -1
-    break-if at-beginning?
-    render-from <- subtract render-from, 1
-    *env <- put *env, render-from:offset, render-from
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-# sandbox belonging to 'env' whose next-sandbox is 'in'
-# return null if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox
-def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [
-  local-scope
-  load-inputs
-  curr:&:sandbox <- get *env, sandbox:offset
-  return-unless curr, null
-  next:&:sandbox <- get *curr, next-sandbox:offset
-  {
-    return-unless next, null
-    found?:bool <- equal next, in
-    break-if found?
-    curr <- copy next
-    next <- get *curr, next-sandbox:offset
-    loop
-  }
-  return curr
-]
-
-scenario scrolling-through-multiple-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  cursor:char <- copy 9251/␣
-  print screen, cursor
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down'
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .␣   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down' again
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # just second sandbox displayed
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down' again
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-up'
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # back to displaying both sandboxes without editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # back to displaying both sandboxes as well as editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # no change
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario scrolling-manages-sandbox-index-correctly [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create a sandbox
-  assume-console [
-    press ctrl-n
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down' and 'page-up' a couple of times. sandbox index should be stable
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-up' again
-  assume-console [
-    press page-up
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # back to displaying both sandboxes as well as editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # hit 'page-down'
-  assume-console [
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # sandbox editor hidden; first sandbox displayed
-  # cursor moves to first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .  # no change
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
diff --git a/archive/2.vm/sandbox/006-sandbox-copy.mu b/archive/2.vm/sandbox/006-sandbox-copy.mu
deleted file mode 100644
index 0eae6cf7..00000000
--- a/archive/2.vm/sandbox/006-sandbox-copy.mu
+++ /dev/null
@@ -1,286 +0,0 @@
-## the 'copy' button makes it easy to duplicate a sandbox, and thence to
-## see code operate in multiple situations
-
-scenario copy-a-sandbox-to-editor [
-  local-scope
-  trace-until 50/app  # trace too long
-  assume-screen 50/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  # click at left edge of 'copy' button
-  assume-console [
-    left-click 3, 19
-  ]
-  run [
-    event-loop screen, console, env
-  ]
-  # it copies into editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .add 1, 1                                          .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .0add 1, 1                                         .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-]
-
-scenario copy-a-sandbox-to-editor-2 [
-  local-scope
-  trace-until 50/app  # trace too long
-  assume-screen 50/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  # click at right edge of 'copy' button (just before 'delete')
-  assume-console [
-    left-click 3, 33
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it copies into editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .add 1, 1                                          .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .0add 1, 1                                         .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-]
-
-after <global-touch> [
-  # support 'copy' button
-  {
-    copy?:bool <- should-attempt-copy? click-row, click-column, env
-    break-unless copy?
-    copy?, env <- try-copy-sandbox click-row, env
-    break-unless copy?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to copy a sandbox
-def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'copy' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  _, _, copy-button-left:num, copy-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right
-  return-unless copy-button-vertical-area?, false
-  # finally, is sandbox editor empty?
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  result <- empty-editor? current-sandbox
-]
-
-def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to copy, if the click was actually on the 'copy' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-copy-button? <- copy true
-  text:text <- get *sandbox, data:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  current-sandbox <- insert-text current-sandbox, text
-  # reset scroll
-  *env <- put *env, render-from:offset, -1
-]
-
-def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [
-  local-scope
-  load-inputs
-  curr-sandbox:&:sandbox <- get *env, sandbox:offset
-  {
-    break-unless curr-sandbox
-    start:num <- get *curr-sandbox, starting-row-on-screen:offset
-    found?:bool <- equal click-row, start
-    return-if found?, curr-sandbox
-    curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-    loop
-  }
-  return null/not-found
-]
-
-def click-on-sandbox-area? click-row:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  first-sandbox:&:sandbox <- get *env, sandbox:offset
-  return-unless first-sandbox, false
-  first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-  result <- greater-or-equal click-row, first-sandbox-begins
-]
-
-def empty-editor? editor:&:editor -> result:bool [
-  local-scope
-  load-inputs
-  head:&:duplex-list:char <- get *editor, data:offset
-  first:&:duplex-list:char <- next head
-  result <- not first
-]
-
-def within-range? x:num, low:num, high:num -> result:bool [
-  local-scope
-  load-inputs
-  not-too-far-left?:bool <- greater-or-equal x, low
-  not-too-far-right?:bool <- lesser-or-equal x, high
-  result <- and not-too-far-left? not-too-far-right?
-]
-
-scenario copy-fails-if-sandbox-editor-not-empty [
-  local-scope
-  trace-until 50/app  # trace too long
-  assume-screen 50/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 1, 1]  # contents of sandbox editor
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # type something into the sandbox editor, then click on the 'copy' button
-  assume-console [
-    left-click 2, 20  # put cursor in sandbox editor
-    type [0]  # type something
-    left-click 3, 20  # click 'copy' button
-  ]
-  run [
-    event-loop screen, console, env
-  ]
-  # copy doesn't happen
-  screen-should-contain [
-    .                               run (F4)           .
-    .0                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .01                                                .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
diff --git a/archive/2.vm/sandbox/007-sandbox-delete.mu b/archive/2.vm/sandbox/007-sandbox-delete.mu
deleted file mode 100644
index 01f01f42..00000000
--- a/archive/2.vm/sandbox/007-sandbox-delete.mu
+++ /dev/null
@@ -1,345 +0,0 @@
-## deleting sandboxes
-
-scenario deleting-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 15/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # run a few commands
-  assume-console [
-    type [divide-with-remainder 11, 3]
-    press F4
-    type [add 2, 2]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .divide-with-remainder 11, 3                       .
-    .3                                                 .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # delete second sandbox by clicking on left edge of 'delete' button
-  assume-console [
-    left-click 7, 34
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # delete first sandbox by clicking at right edge of 'delete' button
-  assume-console [
-    left-click 3, 49
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-after <global-touch> [
-  # support 'delete' button
-  {
-    delete?:bool <- should-attempt-delete? click-row, click-column, env
-    break-unless delete?
-    delete?, env <- try-delete-sandbox click-row, env
-    break-unless delete?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to delete a sandbox
-def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'copy' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  result <- within-range? click-column, delete-button-left, sandbox-right-margin
-]
-
-def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to delete, if the click was actually on the 'delete' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-delete-button? <- copy true
-  env <- delete-sandbox env, sandbox
-]
-
-def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [
-  local-scope
-  load-inputs
-  curr-sandbox:&:sandbox <- get *env, sandbox:offset
-  first-sandbox?:bool <- equal curr-sandbox, sandbox
-  {
-    # first sandbox? pop
-    break-unless first-sandbox?
-    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
-    *env <- put *env, sandbox:offset, next-sandbox
-  }
-  {
-    # not first sandbox?
-    break-if first-sandbox?
-    prev-sandbox:&:sandbox <- copy curr-sandbox
-    curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-    {
-      assert curr-sandbox, [sandbox not found! something is wrong.]
-      found?:bool <- equal curr-sandbox, sandbox
-      break-if found?
-      prev-sandbox <- copy curr-sandbox
-      curr-sandbox <- get *curr-sandbox, next-sandbox:offset
-      loop
-    }
-    # snip sandbox out of its list
-    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
-    *prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox
-  }
-  # update sandbox count
-  sandbox-count:num <- get *env, number-of-sandboxes:offset
-  sandbox-count <- subtract sandbox-count, 1
-  *env <- put *env, number-of-sandboxes:offset, sandbox-count
-  # reset scroll if deleted sandbox was last
-  {
-    break-if next-sandbox
-    render-from:num <- get *env, render-from:offset
-    reset-scroll?:bool <- equal render-from, sandbox-count
-    break-unless reset-scroll?
-    *env <- put *env, render-from:offset, -1
-  }
-]
-
-scenario deleting-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 6, 34
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario deleting-top-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 2, 34
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario deleting-final-sandbox-after-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # delete the second sandbox
-  assume-console [
-    left-click 2, 34
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # implicitly scroll up to first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario deleting-updates-sandbox-count [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-  ]
-  # delete the second sandbox, then try to scroll down twice
-  assume-console [
-    left-click 3, 34
-    press page-down
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # shouldn't go past last sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
diff --git a/archive/2.vm/sandbox/008-sandbox-edit.mu b/archive/2.vm/sandbox/008-sandbox-edit.mu
deleted file mode 100644
index fb3981bf..00000000
--- a/archive/2.vm/sandbox/008-sandbox-edit.mu
+++ /dev/null
@@ -1,319 +0,0 @@
-## editing sandboxes after they've been created
-
-scenario clicking-on-sandbox-edit-button-moves-it-to-editor [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click at left edge of 'edit' button
-  assume-console [
-    left-click 3, 4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it pops back into editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .add 2, 2                                          .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .0add 2, 2                                         .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario clicking-on-sandbox-edit-button-moves-it-to-editor-2 [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # empty recipes
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [add 2, 2]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click at right edge of 'edit' button (just before 'copy')
-  assume-console [
-    left-click 3, 18
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # it pops back into editor
-  screen-should-contain [
-    .                               run (F4)           .
-    .add 2, 2                                          .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [0]
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .0add 2, 2                                         .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-after <global-touch> [
-  # support 'edit' button
-  {
-    edit?:bool <- should-attempt-edit? click-row, click-column, env
-    break-unless edit?
-    edit?, env <- try-edit-sandbox click-row, env
-    break-unless edit?
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-# some preconditions for attempting to edit a sandbox
-def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [
-  local-scope
-  load-inputs
-  # are we below the sandbox editor?
-  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env
-  return-unless click-sandbox-area?, false
-  # narrower, is the click in the columns spanning the 'edit' button?
-  first-sandbox:&:editor <- get *env, current-sandbox:offset
-  assert first-sandbox, [!!]
-  sandbox-left-margin:num <- get *first-sandbox, left:offset
-  sandbox-right-margin:num <- get *first-sandbox, right:offset
-  edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
-  edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right
-  return-unless edit-button-vertical-area?, false
-  # finally, is sandbox editor empty?
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  result <- empty-editor? current-sandbox
-]
-
-def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [
-  local-scope
-  load-inputs
-  # identify the sandbox to edit, if the click was actually on the 'edit' button
-  sandbox:&:sandbox <- find-sandbox env, click-row
-  return-unless sandbox, false
-  clicked-on-edit-button? <- copy true
-  # 'edit' button = 'copy' button + 'delete' button
-  text:text <- get *sandbox, data:offset
-  current-sandbox:&:editor <- get *env, current-sandbox:offset
-  current-sandbox <- insert-text current-sandbox, text
-  env <- delete-sandbox env, sandbox
-  # reset scroll
-  *env <- put *env, render-from:offset, -1
-]
-
-scenario sandbox-with-print-can-be-edited [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # empty recipes
-  assume-resources [
-  ]
-  # right editor contains a print instruction
-  env:&:environment <- new-programming-environment resources, screen, [print screen, 4]
-  render-all screen, env, render
-  # run the sandbox
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .print screen, 4                                   .
-    .screen:                                           .
-    .  .4                             .                .
-    .  .                              .                .
-    .  .                              .                .
-    .  .                              .                .
-    .  .                              .                .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # edit the sandbox
-  assume-console [
-    left-click 3, 18
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .print screen, 4                                   .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-  ]
-]
-
-scenario editing-sandbox-after-scrolling-resets-scroll [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes and scroll to second
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-    press page-down
-    press page-down
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # edit the second sandbox
-  assume-console [
-    left-click 2, 10
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # second sandbox shows in editor; scroll resets to display first sandbox
-  screen-should-contain [
-    .                               run (F4)           .
-    .add 2, 2                                          .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario editing-sandbox-updates-sandbox-count [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # initialize environment
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  # create 2 sandboxes
-  assume-console [
-    press ctrl-n
-    type [add 2, 2]
-    press F4
-    type [add 1, 1]
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-  ]
-  # edit the second sandbox, then resave
-  assume-console [
-    left-click 3, 10
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change in contents
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 1, 1                                          .
-    .2                                                 .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-  ]
-  # now try to scroll past end
-  assume-console [
-    press page-down
-    press page-down
-    press page-down
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # screen should show just final sandbox with the right index (1)
-  screen-should-contain [
-    .                               run (F4)           .
-    .──────────────────────────────────────────────────.
-    .1   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
diff --git a/archive/2.vm/sandbox/009-sandbox-test.mu b/archive/2.vm/sandbox/009-sandbox-test.mu
deleted file mode 100644
index c22916a7..00000000
--- a/archive/2.vm/sandbox/009-sandbox-test.mu
+++ /dev/null
@@ -1,233 +0,0 @@
-## clicking on sandbox results to 'fix' them and turn sandboxes into tests
-
-scenario sandbox-click-on-result-toggles-color-to-green [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # basic recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  reply 4|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  # run it
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click on the '4' in the result
-  $clear-trace
-  assume-console [
-    left-click 5, 21
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # color toggles to green
-  screen-should-contain-in-color 2/green, [
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .4                                                 .
-    .                                                  .
-  ]
-  # don't render entire sandbox side
-  check-trace-count-for-label-lesser-than 250, [print-character]  # say 5 sandbox lines
-  # cursor should remain unmoved
-  run [
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # now change the result
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  reply 3|
-      |]|
-    ]
-  ]
-  # then rerun
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # result turns red
-  screen-should-contain-in-color 1/red, [
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .3                                                 .
-    .                                                  .
-  ]
-]
-
-# this requires tracking a couple more things
-container sandbox [
-  response-starting-row-on-screen:num
-  expected-response:text
-]
-
-# include expected response when saving or restoring a sandbox
-before <end-save-sandbox> [
-  {
-    expected-response:text <- get *sandbox, expected-response:offset
-    break-unless expected-response
-    filename <- append filename, [.out]
-    resources <- dump resources, filename, expected-response
-  }
-]
-
-before <end-restore-sandbox> [
-  {
-    filename <- append filename, [.out]
-    contents <- slurp resources, filename
-    break-unless contents
-    *curr <- put *curr, expected-response:offset, contents
-  }
-]
-
-# clicks on sandbox responses save it as 'expected'
-after <global-touch> [
-  # check if it's inside the output of any sandbox
-  {
-    sandbox-left-margin:num <- get *current-sandbox, left:offset
-    click-column:num <- get t, column:offset
-    on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
-    break-unless on-sandbox-side?
-    first-sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless first-sandbox
-    first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-    click-row:num <- get t, row:offset
-    below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
-    break-unless below-sandbox-editor?
-    # identify the sandbox whose output is being clicked on
-    sandbox:&:sandbox, sandbox-index:num <- find-click-in-sandbox-output env, click-row
-    break-unless sandbox
-    # update it
-    sandbox <- toggle-expected-response sandbox
-    # minimal update to disk
-    save-sandbox resources, sandbox, sandbox-index
-    # minimal update to screen
-    sandbox-right-margin:num <- get *current-sandbox, right:offset
-    row:num <- render-sandbox-response screen, sandbox, sandbox-left-margin, sandbox-right-margin
-    {
-      height:num <- screen-height screen
-      at-bottom?:bool <- greater-or-equal row, height
-      break-if at-bottom?
-      draw-horizontal screen, row, sandbox-left-margin, sandbox-right-margin
-    }
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox, sandbox-index:num [
-  local-scope
-  load-inputs
-  # assert click-row >= sandbox.starting-row-on-screen
-  sandbox:&:sandbox <- get *env, sandbox:offset
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
-  assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
-  # while click-row < sandbox.next-sandbox.starting-row-on-screen
-  sandbox-index <- copy 0
-  {
-    next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-    break-unless next-sandbox
-    next-start:num <- get *next-sandbox, starting-row-on-screen:offset
-    found?:bool <- lesser-than click-row, next-start
-    break-if found?
-    sandbox <- copy next-sandbox
-    sandbox-index <- add sandbox-index, 1
-    loop
-  }
-  # return sandbox if click is in its output region
-  response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset
-  return-unless response-starting-row, null/no-click-in-sandbox-output, 0/sandbox-index
-  click-in-response?:bool <- greater-or-equal click-row, response-starting-row
-  return-unless click-in-response?, null/no-click-in-sandbox-output, 0/sandbox-index
-  return sandbox, sandbox-index
-]
-
-def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  expected-response:text <- get *sandbox, expected-response:offset
-  {
-    # if expected-response is set, reset
-    break-unless expected-response
-    *sandbox <- put *sandbox, expected-response:offset, null
-  }
-  {
-    # if not, set expected response to the current response
-    break-if expected-response
-    response:text <- get *sandbox, response:offset
-    *sandbox <- put *sandbox, expected-response:offset, response
-  }
-]
-
-# when rendering a sandbox, color it in red/green if expected response exists
-after <render-sandbox-response> [
-  {
-    break-unless sandbox-response
-    *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row
-    row <- render-sandbox-response screen, sandbox, left, right
-    jump +render-sandbox-end
-  }
-]
-
-def render-sandbox-response screen:&:screen, sandbox:&:sandbox, left:num, right:num -> row:num, screen:&:screen [
-  local-scope
-  load-inputs
-  sandbox-response:text <- get *sandbox, response:offset
-  expected-response:text <- get *sandbox, expected-response:offset
-  row:num <- get *sandbox response-starting-row-on-screen:offset
-  {
-    break-if expected-response
-    row <- render-text screen, sandbox-response, left, right, 245/grey, row
-    return
-  }
-  response-is-expected?:bool <- equal expected-response, sandbox-response
-  {
-    break-if response-is-expected?
-    row <- render-text screen, sandbox-response, left, right, 1/red, row
-  }
-  {
-    break-unless response-is-expected?:bool
-    row <- render-text screen, sandbox-response, left, right, 2/green, row
-  }
-]
-
-before <end-render-sandbox-reset-hidden> [
-  *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0
-]
diff --git a/archive/2.vm/sandbox/010-sandbox-trace.mu b/archive/2.vm/sandbox/010-sandbox-trace.mu
deleted file mode 100644
index d544dd8c..00000000
--- a/archive/2.vm/sandbox/010-sandbox-trace.mu
+++ /dev/null
@@ -1,243 +0,0 @@
-## clicking on the code typed into a sandbox toggles its trace
-
-scenario sandbox-click-on-code-toggles-app-trace [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # run a stash instruction
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [stash [abc]]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash [abc]                                       .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click on the code in the sandbox
-  assume-console [
-    left-click 4, 21
-  ]
-  run [
-    event-loop screen, console, env, resources
-    cursor:char <- copy 9251/␣
-    print screen, cursor
-  ]
-  # trace now printed and cursor shouldn't have budged
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash [abc]                                       .
-    .abc                                               .
-  ]
-  screen-should-contain-in-color 245/grey, [
-    .                                                  .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-    .                                                  .
-    .abc                                               .
-  ]
-  # click again on the same region
-  assume-console [
-    left-click 4, 25
-  ]
-  run [
-    event-loop screen, console, env, resources
-    print screen, cursor
-  ]
-  # trace hidden again
-  screen-should-contain [
-    .                               run (F4)           .
-    .␣                                                 .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash [abc]                                       .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario sandbox-shows-app-trace-and-result [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  # run a stash instruction and some code
-  assume-resources [
-  ]
-  test-sandbox:text <- new [stash [abc]
-add 2, 2]
-  env:&:environment <- new-programming-environment resources, screen, test-sandbox
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash [abc]                                       .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click on the code in the sandbox
-  assume-console [
-    left-click 4, 21
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # trace now printed above result
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash [abc]                                       .
-    .add 2, 2                                          .
-    .abc                                               .
-    .7 instructions run                                .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-  ]
-]
-
-scenario clicking-on-app-trace-does-nothing [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [stash 123456789]
-  render-all screen, env, render
-  # create and expand the trace
-  assume-console [
-    press F4
-    left-click 4, 1
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash 123456789                                   .
-    .123456789                                         .
-  ]
-  # click on the stash under the edit-button region (or any of the other buttons, really)
-  assume-console [
-    left-click 5, 7
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # no change; doesn't die
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .stash 123456789                                   .
-    .123456789                                         .
-  ]
-]
-
-container sandbox [
-  trace:text
-  display-trace?:bool
-]
-
-# replaced in a later layer
-def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  data:text <- get *sandbox, data:offset
-  response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-  *sandbox <- put *sandbox, trace:offset, trace
-]
-
-# clicks on sandbox code toggle its display-trace? flag
-after <global-touch> [
-  # check if it's inside the code of any sandbox
-  {
-    sandbox-left-margin:num <- get *current-sandbox, left:offset
-    click-column:num <- get t, column:offset
-    on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
-    break-unless on-sandbox-side?
-    first-sandbox:&:sandbox <- get *env, sandbox:offset
-    break-unless first-sandbox
-    first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
-    click-row:num <- get t, row:offset
-    below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
-    break-unless below-sandbox-editor?
-    # identify the sandbox whose code is being clicked on
-    sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row
-    break-unless sandbox
-    # toggle its display-trace? property
-    x:bool <- get *sandbox, display-trace?:offset
-    x <- not x
-    *sandbox <- put *sandbox, display-trace?:offset, x
-    screen <- render-sandbox-side screen, env, render
-    screen <- update-cursor screen, current-sandbox, env
-    loop +next-event
-  }
-]
-
-def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [
-  local-scope
-  load-inputs
-  # assert click-row >= sandbox.starting-row-on-screen
-  sandbox <- get *env, sandbox:offset
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
-  assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
-  # while click-row < sandbox.next-sandbox.starting-row-on-screen
-  {
-    next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
-    break-unless next-sandbox
-    next-start:num <- get *next-sandbox, starting-row-on-screen:offset
-    found?:bool <- lesser-than click-row, next-start
-    break-if found?
-    sandbox <- copy next-sandbox
-    loop
-  }
-  # return sandbox if click is in its code region
-  code-ending-row:num <- get *sandbox, code-ending-row-on-screen:offset
-  click-above-response?:bool <- lesser-than click-row, code-ending-row
-  start:num <- get *sandbox, starting-row-on-screen:offset
-  click-below-menu?:bool <- greater-than click-row, start
-  click-on-sandbox-code?:bool <- and click-above-response?, click-below-menu?
-  {
-    break-if click-on-sandbox-code?
-    return null/no-click-in-sandbox-output
-  }
-  return sandbox
-]
-
-# when rendering a sandbox, dump its trace before response/warning if display-trace? property is set
-after <render-sandbox-results> [
-  {
-    display-trace?:bool <- get *sandbox, display-trace?:offset
-    break-unless display-trace?
-    sandbox-trace:text <- get *sandbox, trace:offset
-    break-unless sandbox-trace  # nothing to print; move on
-    row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row
-  }
-  <render-sandbox-trace-done>
-]
diff --git a/archive/2.vm/sandbox/011-errors.mu b/archive/2.vm/sandbox/011-errors.mu
deleted file mode 100644
index 2f59d1fe..00000000
--- a/archive/2.vm/sandbox/011-errors.mu
+++ /dev/null
@@ -1,687 +0,0 @@
-## handling malformed programs
-
-container environment [
-  recipe-errors:text
-]
-
-# load code from disk, save any errors
-def! update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, screen:&:screen [
-  local-scope
-  load-inputs
-  in:text <- slurp resources, [lesson/recipes.mu]
-  recipe-errors:text <- reload in
-  *env <- put *env, recipe-errors:offset, recipe-errors
-  # if recipe editor has errors, stop
-  {
-    break-unless recipe-errors
-    update-status screen, [errors found     ], 1/red
-    errors-found? <- copy true
-    return
-  }
-  errors-found? <- copy false
-]
-
-before <end-render-components> [
-  trace 11, [app], [render status]
-  recipe-errors:text <- get *env, recipe-errors:offset
-  {
-    break-unless recipe-errors
-    update-status screen, [errors found     ], 1/red
-  }
-]
-
-container environment [
-  error-index:num  # index of first sandbox with an error (or -1 if none)
-]
-
-after <programming-environment-initialization> [
-  *result <- put *result, error-index:offset, -1
-]
-
-after <begin-run-sandboxes> [
-  *env <- put *env, error-index:offset, -1
-]
-
-before <end-run-sandboxes> [
-  {
-    error-index:num <- get *env, error-index:offset
-    sandboxes-completed-successfully?:bool <- equal error-index, -1
-    break-if sandboxes-completed-successfully?
-    errors-found? <- copy true
-  }
-]
-
-before <end-render-components> [
-  {
-    break-if recipe-errors
-    error-index:num <- get *env, error-index:offset
-    sandboxes-completed-successfully?:bool <- equal error-index, -1
-    break-if sandboxes-completed-successfully?
-    error-index-text:text <- to-text error-index
-    status:text <- interpolate [errors found (_)    ], error-index-text
-    update-status screen, status, 1/red
-  }
-]
-
-container sandbox [
-  errors:text
-]
-
-def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
-  local-scope
-  load-inputs
-  {
-    recipe-errors:text <- get *env, recipe-errors:offset
-    break-unless recipe-errors
-    *sandbox <- put *sandbox, errors:offset, recipe-errors
-    return
-  }
-  data:text <- get *sandbox, data:offset
-  response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data
-  *sandbox <- put *sandbox, response:offset, response
-  *sandbox <- put *sandbox, errors:offset, errors
-  *sandbox <- put *sandbox, screen:offset, fake-screen
-  *sandbox <- put *sandbox, trace:offset, trace
-  {
-    break-if errors
-    break-if completed?
-    errors <- new [took too long!
-]
-    *sandbox <- put *sandbox, errors:offset, errors
-  }
-  {
-    break-unless errors
-    error-index:num <- get *env, error-index:offset
-    error-not-set?:bool <- equal error-index, -1
-    break-unless error-not-set?
-    *env <- put *env, error-index:offset, idx
-  }
-]
-
-# make sure we render any trace
-after <render-sandbox-trace-done> [
-  {
-    sandbox-errors:text <- get *sandbox, errors:offset
-    break-unless sandbox-errors
-    *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0  # no response
-    {
-      break-unless env
-      recipe-errors:text <- get *env, recipe-errors:offset
-      row, screen <- render-text screen, recipe-errors, left, right, 1/red, row
-    }
-    row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row
-    # don't try to print anything more for this sandbox
-    jump +render-sandbox-end
-  }
-]
-
-scenario run-shows-errors-in-get [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  get 123:num, foo:offset|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  screen-should-contain [
-    .                               run (F4)           .
-    .foo                                               .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: unknown element 'foo' in container 'number'  .
-    .foo: first ingredient of 'get' should be a contai↩.
-    .ner, but got '123:num'                            .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .  errors found                                    .
-    .                                                  .
-  ]
-]
-
-scenario run-updates-status-with-first-erroneous-sandbox [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    # create invalid sandbox 1
-    type [get foo, x:offset]
-    press F4
-    # create invalid sandbox 0
-    type [get foo, x:offset]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # status line shows that error is in first sandbox
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-  ]
-]
-
-scenario run-updates-status-with-first-erroneous-sandbox-2 [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, []
-  render-all screen, env, render
-  assume-console [
-    # create invalid sandbox 2
-    type [get foo, x:offset]
-    press F4
-    # create invalid sandbox 1
-    type [get foo, x:offset]
-    press F4
-    # create valid sandbox 0
-    type [add 2, 2]
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # status line shows that error is in second sandbox
-  screen-should-contain [
-    .  errors found (1)             run (F4)           .
-  ]
-]
-
-scenario run-hides-errors-from-past-sandboxes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset]  # invalid
-  render-all screen, env, render
-  assume-console [
-    press F4  # generate error
-  ]
-  event-loop screen, console, env, resources
-  assume-console [
-    left-click 3, 10
-    press ctrl-k
-    type [add 2, 2]  # valid code
-    press F4  # update sandbox
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # error should disappear
-  screen-should-contain [
-    .                               run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .add 2, 2                                          .
-    .4                                                 .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario run-updates-errors-for-shape-shifting-recipes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # define a shape-shifting recipe with an error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo x:_elem -> z:_elem [|
-      |  local-scope|
-      |  load-ingredients|
-      |  y:&:num <- copy null|
-      |  z <- add x, y|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo 2]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo 2                                             .
-    .foo_2: 'add' requires number ingredients, but got↩.
-    . 'y'                                              .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # now rerun everything
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # error should remain unchanged
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo 2                                             .
-    .foo_3: 'add' requires number ingredients, but got↩.
-    . 'y'                                              .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # overload a well-known shape-shifting recipe
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe length l:&:list:_elem -> n:num [|
-      |]|
-    ]
-  ]
-  # call code that uses other variants of it, but not it itself
-  test-sandbox:text <- new [x:&:list:num <- copy null
-to-text x]
-  env:&:environment <- new-programming-environment resources, screen, test-sandbox
-  render-all screen, env, render
-  # run it once
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  # no errors anywhere on screen (can't check anything else, since to-text will return an address)
-  screen-should-contain-in-color 1/red, [
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .             <-                                   .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-  # rerun everything
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # still no errors
-  screen-should-contain-in-color 1/red, [
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .             <-                                   .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-  ]
-]
-
-scenario run-shows-missing-type-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  x <- copy 0|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: missing type for 'x' in 'x <- copy 0'        .
-  ]
-]
-
-scenario run-shows-unbalanced-bracket-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # recipe is incomplete (unbalanced '[')
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo \\\[|
-      |  x <- copy 0|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .9: unbalanced '\\[' for recipe                      .
-    .9: unbalanced '\\[' for recipe                      .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario run-shows-get-on-non-container-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:&:point <- new point:type|
-      |  get x:&:point, 1:offset|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: first ingredient of 'get' should be a contai↩.
-    .ner, but got 'x:&:point'                          .
-  ]
-]
-
-scenario run-shows-non-literal-get-argument-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:num <- copy 0|
-      |  y:&:point <- new point:type|
-      |  get *y:&:point, x:num|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: second ingredient of 'get' should have type ↩.
-    .'offset', but got 'x:num'                         .
-  ]
-]
-
-scenario run-shows-errors-every-time [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # try to run a file with an error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  x:num <- copy y:num|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: tried to read ingredient 'y' in 'x:num <- co↩.
-    .py y:num' but it hasn't been written to yet       .
-  ]
-  # rerun the file, check for the same error
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found                 run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo                                               .
-    .foo: tried to read ingredient 'y' in 'x:num <- co↩.
-    .py y:num' but it hasn't been written to yet       .
-  ]
-]
-
-scenario run-instruction-and-print-errors [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 15/height
-  assume-resources [
-  ]
-  # editor contains an illegal instruction
-  env:&:environment <- new-programming-environment resources, screen, [get 1:&:point, 1:offset]
-  render-all screen, env, render
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints error message in red
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .get 1:&:point, 1:offset                           .
-    .first ingredient of 'get' should be a container, ↩.
-    .but got '1:&:point'                               .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  screen-should-contain-in-color 1/red, [
-    .  errors found (0)                                .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .                                                  .
-    .first ingredient of 'get' should be a container,  .
-    .but got '1:&:point'                               .
-    .                                                  .
-    .                                                  .
-  ]
-]
-
-scenario run-instruction-and-print-errors-only-once [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 10/height
-  assume-resources [
-  ]
-  # editor contains an illegal instruction
-  env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset]
-  render-all screen, env, render
-  # run the code in the editors multiple times
-  assume-console [
-    press F4
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # check that screen prints error message just once
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .get 1234:num, foo:offset                          .
-    .unknown element 'foo' in container 'number'       .
-    .first ingredient of 'get' should be a container, ↩.
-    .but got '1234:num'                                .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario sandbox-can-handle-infinite-loop [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  assume-resources [
-  ]
-  # editor contains an infinite loop
-  test-sandbox:text <- new [{
-loop
-}]
-  env:&:environment <- new-programming-environment resources, screen, test-sandbox
-  render-all screen, env, render
-  # run the sandbox
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .{                                                 .
-    .loop                                              .
-    .}                                                 .
-    .took too long!                                    .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
-
-scenario sandbox-with-errors-shows-trace [
-  local-scope
-  trace-until 100/app  # trace too long
-  assume-screen 50/width, 20/height
-  # generate a stash and a error
-  assume-resources [
-    [lesson/recipes.mu] <- [
-      |recipe foo [|
-      |  local-scope|
-      |  a:num <- next-ingredient|
-      |  b:num <- next-ingredient|
-      |  stash [dividing by], b|
-      |  _, c:num <- divide-with-remainder a, b|
-      |  reply b|
-      |]|
-    ]
-  ]
-  env:&:environment <- new-programming-environment resources, screen, [foo 4, 0]
-  render-all screen, env, render
-  # run
-  assume-console [
-    press F4
-  ]
-  event-loop screen, console, env, resources
-  # screen prints error message
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo 4, 0                                          .
-    .foo: divide by zero in '_, c:num <- divide-with-r↩.
-    .emainder a, b'                                    .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-  # click on the call in the sandbox
-  assume-console [
-    left-click 4, 15
-  ]
-  run [
-    event-loop screen, console, env, resources
-  ]
-  # screen should expand trace
-  screen-should-contain [
-    .  errors found (0)             run (F4)           .
-    .                                                  .
-    .──────────────────────────────────────────────────.
-    .0   edit           copy           delete          .
-    .foo 4, 0                                          .
-    .dividing by 0                                     .
-    .14 instructions run                               .
-    .foo: divide by zero in '_, c:num <- divide-with-r↩.
-    .emainder a, b'                                    .
-    .──────────────────────────────────────────────────.
-    .                                                  .
-  ]
-]
diff --git a/archive/2.vm/sandbox/012-editor-undo.mu b/archive/2.vm/sandbox/012-editor-undo.mu
deleted file mode 100644
index 69afd207..00000000
--- a/archive/2.vm/sandbox/012-editor-undo.mu
+++ /dev/null
@@ -1,1907 +0,0 @@
-## undo/redo
-
-# for every undoable event, create a type of *operation* that contains all the
-# information needed to reverse it
-exclusive-container operation [
-  typing:insert-operation
-  move:move-operation
-  delete:delete-operation
-]
-
-container insert-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate
-  insert-from:&:duplex-list:char
-  insert-until:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (enter+indent)
-    # 1: regular alphanumeric characters
-]
-
-container move-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (touch events, etc)
-    # 1: left arrow
-    # 2: right arrow
-    # 3: up arrow
-    # 4: down arrow
-]
-
-container delete-operation [
-  before-row:num
-  before-column:num
-  before-top-of-screen:&:duplex-list:char
-  after-row:num
-  after-column:num
-  after-top-of-screen:&:duplex-list:char
-  deleted-text:&:duplex-list:char
-  delete-from:&:duplex-list:char
-  delete-until:&:duplex-list:char
-  tag:num  # event causing this operation; might be used to coalesce runs of similar events
-    # 0: no coalesce (ctrl-k, ctrl-u)
-    # 1: backspace
-    # 2: delete
-]
-
-# every editor accumulates a list of operations to undo/redo
-container editor [
-  undo:&:list:&:operation
-  redo:&:list:&:operation
-]
-
-# ctrl-z - undo operation
-after <handle-special-character> [
-  {
-    undo?:bool <- equal c, 26/ctrl-z
-    break-unless undo?
-    undo:&:list:&:operation <- get *editor, undo:offset
-    break-unless undo
-    op:&:operation <- first undo
-    undo <- rest undo
-    *editor <- put *editor, undo:offset, undo
-    redo:&:list:&:operation <- get *editor, redo:offset
-    redo <- push op, redo
-    *editor <- put *editor, redo:offset, redo
-    <handle-undo>
-    return true/go-render
-  }
-]
-
-# ctrl-y - redo operation
-after <handle-special-character> [
-  {
-    redo?:bool <- equal c, 25/ctrl-y
-    break-unless redo?
-    redo:&:list:&:operation <- get *editor, redo:offset
-    break-unless redo
-    op:&:operation <- first redo
-    redo <- rest redo
-    *editor <- put *editor, redo:offset, redo
-    undo:&:list:&:operation <- get *editor, undo:offset
-    undo <- push op, undo
-    *editor <- put *editor, undo:offset, undo
-    <handle-redo>
-    return true/go-render
-  }
-]
-
-# undo typing
-
-scenario editor-can-undo-typing [
-  local-scope
-  # create an editor and type a character
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [0]
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # character should be gone
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# save operation to undo
-after <begin-insert-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset
-]
-before <end-insert-character> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  undo:&:list:&:operation <- get *editor, undo:offset
-  {
-    # if previous operation was an insert, coalesce this operation with it
-    break-unless undo
-    op:&:operation <- first undo
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    previous-coalesce-tag:num <- get typing, tag:offset
-    break-unless previous-coalesce-tag
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    insert-until:&:duplex-list:char <- next before-cursor
-    typing <- put typing, insert-until:offset, insert-until
-    typing <- put typing, after-row:offset, cursor-row
-    typing <- put typing, after-column:offset, cursor-column
-    typing <- put typing, after-top-of-screen:offset, top-after
-    *op <- merge 0/insert-operation, typing
-    break +done-adding-insert-operation
-  }
-  # if not, create a new operation
-  insert-from:&:duplex-list:char <- next cursor-before
-  insert-to:&:duplex-list:char <- next insert-from
-  op:&:operation <- new operation:type
-  *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 1/coalesce
-  editor <- add-operation editor, op
-  +done-adding-insert-operation
-]
-
-# enter operations never coalesce with typing before or after
-after <begin-insert-enter> [
-  cursor-row-before:num <- copy cursor-row
-  cursor-column-before:num <- copy cursor-column
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset
-]
-before <end-insert-enter> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-row:offset
-  # never coalesce
-  insert-from:&:duplex-list:char <- next cursor-before
-  before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-  insert-to:&:duplex-list:char <- next before-cursor
-  op:&:operation <- new operation:type
-  *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce
-  editor <- add-operation editor, op
-]
-
-# Everytime you add a new operation to the undo stack, be sure to clear the
-# redo stack, because it's now obsolete.
-# Beware: since we're counting cursor moves as operations, this means just
-# moving the cursor can lose work on the undo stack.
-def add-operation editor:&:editor, op:&:operation -> editor:&:editor [
-  local-scope
-  load-inputs
-  undo:&:list:&:operation <- get *editor, undo:offset
-  undo <- push op undo
-  *editor <- put *editor, undo:offset, undo
-  redo:&:list:&:operation <- get *editor, redo:offset
-  redo <- copy null
-  *editor <- put *editor, redo:offset, redo
-]
-
-after <handle-undo> [
-  {
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    start:&:duplex-list:char <- get typing, insert-from:offset
-    end:&:duplex-list:char <- get typing, insert-until:offset
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    before-cursor:&:duplex-list:char <- prev start
-    *editor <- put *editor, before-cursor:offset, before-cursor
-    remove-between before-cursor, end
-    cursor-row <- get typing, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get typing, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get typing, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-can-undo-typing-multiple [
-  local-scope
-  # create an editor and type multiple characters
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be gone
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-can-undo-typing-multiple-2 [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [a], 0/left, 10/right
-  editor-render screen, e
-  # type some characters
-  assume-console [
-    type [012]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .012a      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # back to original text
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .3a        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-can-undo-typing-enter [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [  abc], 0/left, 10/right
-  editor-render screen, e
-  # new line
-  assume-console [
-    left-click 1, 8
-    press enter
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .  abc     .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # line is indented
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 5
-  ]
-  # back to original text
-  screen-should-contain [
-    .          .
-    .  abc     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be at end of line
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .  abc1    .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# redo typing
-
-scenario editor-redo-typing [
-  local-scope
-  # create an editor, type something, undo
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [a], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be back
-  screen-should-contain [
-    .          .
-    .012a      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0123a     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <handle-redo> [
-  {
-    typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant
-    break-unless is-insert?
-    before-cursor <- get *editor, before-cursor:offset
-    insert-from:&:duplex-list:char <- get typing, insert-from:offset  # ignore insert-to because it's already been spliced away
-    # assert insert-to matches next(before-cursor)
-    splice before-cursor, insert-from
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get typing, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get typing, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get typing, after-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-redo-typing-empty [
-  local-scope
-  # create an editor, type something, undo
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [012]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # all characters must be back
-  screen-should-contain [
-    .          .
-    .012       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [3]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .0123      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-scenario editor-work-clears-redo-stack [
-  local-scope
-  # create an editor with some text, do some work, undo
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [1]
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  # do some more work
-  assume-console [
-    type [0]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # nothing should happen
-  screen-should-contain [
-    .          .
-    .0abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-redo-typing-and-enter-and-tab [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and tabs, hit enter, some more text and tabs
-  assume-console [
-    press tab
-    type [ab]
-    press tab
-    type [cd]
-    press enter
-    press tab
-    type [efg]
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .    efg   .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 7
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # typing in second line deleted, but not indent
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # indent and newline deleted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 8
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # empty screen
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 8
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # newline and indent inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # indent and newline deleted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 7
-  ]
-  screen-should-contain [
-    .          .
-    .  ab  cd  .
-    .    efg   .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# undo cursor movement
-
-scenario editor-can-undo-touch [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # click undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1abc      .
-    .def       .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-after <begin-move-cursor> [
-  cursor-row-before:num <- get *editor, cursor-row:offset
-  cursor-column-before:num <- get *editor, cursor-column:offset
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-move-cursor> [
-  top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-  cursor-row:num <- get *editor, cursor-row:offset
-  cursor-column:num <- get *editor, cursor-column:offset
-  {
-    break-unless undo-coalesce-tag
-    # if previous operation was also a move, and also had the same coalesce
-    # tag, coalesce with it
-    undo:&:list:&:operation <- get *editor, undo:offset
-    break-unless undo
-    op:&:operation <- first undo
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    previous-coalesce-tag:num <- get move, tag:offset
-    coalesce?:bool <- equal undo-coalesce-tag, previous-coalesce-tag
-    break-unless coalesce?
-    move <- put move, after-row:offset, cursor-row
-    move <- put move, after-column:offset, cursor-column
-    move <- put move, after-top-of-screen:offset, top-after
-    *op <- merge 1/move-operation, move
-    break +done-adding-move-operation
-  }
-  op:&:operation <- new operation:type
-  *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag
-  editor <- add-operation editor, op
-  +done-adding-move-operation
-]
-
-after <handle-undo> [
-  {
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get move, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get move, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get move, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-can-undo-left-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-    press left-arrow
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-up-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 3, 1
-    press up-arrow
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-down-arrow [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 2, 1
-    press down-arrow
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-ctrl-a [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press ctrl-a
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-home [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press home
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-ctrl-e [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press ctrl-e
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-end [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor, then to start of line
-  assume-console [
-    left-click 2, 1
-    press end
-  ]
-  editor-event-loop screen, console, e
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves back
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .d1ef      .
-    .ghi       .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-scenario editor-can-undo-multiple-arrows-in-the-same-direction [
-  local-scope
-  # create an editor with some text
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # move the cursor
-  assume-console [
-    left-click 2, 1
-    press right-arrow
-    press right-arrow
-    press up-arrow
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # up-arrow is undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 3
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # both right-arrows are undone
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 2
-    4 <- 1
-  ]
-]
-
-# redo cursor movement
-
-scenario editor-redo-touch [
-  local-scope
-  # create an editor with some text, click on a character, undo
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def
-ghi]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    left-click 3, 1
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # cursor moves to left-click
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 3
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .g1hi      .
-    .┈┈┈┈┈┈┈┈┈┈.
-  ]
-]
-
-after <handle-redo> [
-  {
-    move:move-operation, is-move?:bool <- maybe-convert *op, move:variant
-    break-unless is-move?
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get move, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get move, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get move, after-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-scenario editor-separates-undo-insert-from-undo-cursor-move [
-  local-scope
-  # create an editor, type some text, move the cursor, type some more text
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  assume-console [
-    type [abc]
-    left-click 1, 1
-    type [d]
-  ]
-  editor-event-loop screen, console, e
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  screen-should-contain [
-    .          .
-    .adbc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # last letter typed is deleted
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # no change to screen; cursor moves
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # undo again
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen empty
-  screen-should-contain [
-    .          .
-    .          .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # first insert
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # cursor moves
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # cursor moves
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # redo again
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # second insert
-  screen-should-contain [
-    .          .
-    .adbc      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-]
-
-# undo backspace
-
-scenario editor-can-undo-and-redo-backspace [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit backspace
-  assume-console [
-    type [abc]
-    press backspace
-    press backspace
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .a         .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-# save operation to undo
-after <begin-backspace-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-backspace-character> [
-  {
-    break-unless backspaced-cell  # backspace failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-row:offset
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    undo:&:list:&:operation <- get *editor, undo:offset
-    {
-      # if previous operation was an insert, coalesce this operation with it
-      break-unless undo
-      op:&:operation <- first undo
-      deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-      break-unless is-delete?
-      previous-coalesce-tag:num <- get deletion, tag:offset
-      coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace
-      break-unless coalesce?
-      deletion <- put deletion, delete-from:offset, before-cursor
-      backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset
-      splice backspaced-cell, backspaced-so-far
-      deletion <- put deletion, deleted-text:offset, backspaced-cell
-      deletion <- put deletion, after-row:offset, cursor-row
-      deletion <- put deletion, after-column:offset, cursor-column
-      deletion <- put deletion, after-top-of-screen:offset, top-after
-      *op <- merge 2/delete-operation, deletion
-      break +done-adding-backspace-operation
-    }
-    # if not, create a new operation
-    op:&:operation <- new operation:type
-    deleted-until:&:duplex-list:char <- next before-cursor
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, 1/coalesce-backspace
-    editor <- add-operation editor, op
-    +done-adding-backspace-operation
-  }
-]
-
-after <handle-undo> [
-  {
-    deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-    break-unless is-delete?
-    anchor:&:duplex-list:char <- get deletion, delete-from:offset
-    break-unless anchor
-    deleted:&:duplex-list:char <- get deletion, deleted-text:offset
-    old-cursor:&:duplex-list:char <- last deleted
-    splice anchor, deleted
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    before-cursor <- copy old-cursor
-    cursor-row <- get deletion, before-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get deletion, before-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get deletion, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-after <handle-redo> [
-  {
-    deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-    break-unless is-delete?
-    start:&:duplex-list:char <- get deletion, delete-from:offset
-    end:&:duplex-list:char <- get deletion, delete-until:offset
-    data:&:duplex-list:char <- get *editor, data:offset
-    remove-between start, end
-    # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    cursor-row <- get deletion, after-row:offset
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    cursor-column <- get deletion, after-column:offset
-    *editor <- put *editor, cursor-column:offset, cursor-column
-    top:&:duplex-list:char <- get deletion, before-top-of-screen:offset
-    *editor <- put *editor, top-of-screen:offset, top
-  }
-]
-
-# undo delete
-
-scenario editor-can-undo-and-redo-delete [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    type [abcdef]
-    left-click 1, 2
-    press delete
-    press backspace
-    press delete
-    press delete
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .af        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo deletes
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .adef      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo backspace
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abdef     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # undo first delete
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abcdef    .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo first delete
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  screen-should-contain [
-    .          .
-    .abdef     .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo backspace
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .adef      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # redo deletes
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  screen-should-contain [
-    .          .
-    .af        .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-character> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-character> [
-  {
-    break-unless deleted-cell  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    undo:&:list:&:operation <- get *editor, undo:offset
-    {
-      # if previous operation was an insert, coalesce this operation with it
-      break-unless undo
-      op:&:operation <- first undo
-      deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant
-      break-unless is-delete?
-      previous-coalesce-tag:num <- get deletion, tag:offset
-      coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete
-      break-unless coalesce?
-      delete-until:&:duplex-list:char <- next before-cursor
-      deletion <- put deletion, delete-until:offset, delete-until
-      deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset
-      deleted-so-far <- append deleted-so-far, deleted-cell
-      deletion <- put deletion, deleted-text:offset, deleted-so-far
-      deletion <- put deletion, after-row:offset, cursor-row
-      deletion <- put deletion, after-column:offset, cursor-column
-      deletion <- put deletion, after-top-of-screen:offset, top-after
-      *op <- merge 2/delete-operation, deletion
-      break +done-adding-delete-operation
-    }
-    # if not, create a new operation
-    op:&:operation <- new operation:type
-    deleted-until:&:duplex-list:char <- next before-cursor
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, 2/coalesce-delete
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-# undo ctrl-k
-
-scenario editor-can-undo-and-redo-ctrl-k [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    left-click 1, 1
-    press ctrl-k
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .a         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  screen-should-contain [
-    .          .
-    .a         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 1
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .a1        .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-to-end-of-line> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-to-end-of-line> [
-  {
-    break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    deleted-until:&:duplex-list:char <- next before-cursor
-    op:&:operation <- new operation:type
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-# undo ctrl-u
-
-scenario editor-can-undo-and-redo-ctrl-u [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  contents:text <- new [abc
-def]
-  e:&:editor <- new-editor contents, 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    left-click 1, 2
-    press ctrl-u
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .c         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # undo
-  assume-console [
-    press ctrl-z
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .abc       .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  # redo
-  assume-console [
-    press ctrl-y
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  # first line inserted
-  screen-should-contain [
-    .          .
-    .c         .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  3:num/raw <- get *e, cursor-row:offset
-  4:num/raw <- get *e, cursor-column:offset
-  memory-should-contain [
-    3 <- 1
-    4 <- 0
-  ]
-  # cursor should be in the right place
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .1c        .
-    .def       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
-
-after <begin-delete-to-start-of-line> [
-  top-before:&:duplex-list:char <- get *editor, top-of-screen:offset
-]
-before <end-delete-to-start-of-line> [
-  {
-    break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:&:duplex-list:char <- get *editor, top-of-screen:offset
-    op:&:operation <- new operation:type
-    before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset
-    deleted-until:&:duplex-list:char <- next before-cursor
-    cursor-row:num <- get *editor, cursor-row:offset
-    cursor-column:num <- get *editor, cursor-column:offset
-    *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce
-    editor <- add-operation editor, op
-    +done-adding-delete-operation
-  }
-]
-
-scenario editor-can-undo-and-redo-ctrl-u-2 [
-  local-scope
-  # create an editor
-  assume-screen 10/width, 5/height
-  e:&:editor <- new-editor [], 0/left, 10/right
-  editor-render screen, e
-  # insert some text and hit delete and backspace a few times
-  assume-console [
-    type [abc]
-    press ctrl-u
-    press ctrl-z
-  ]
-  editor-event-loop screen, console, e
-  screen-should-contain [
-    .          .
-    .abc       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-]
diff --git a/archive/2.vm/sandbox/Readme.md b/archive/2.vm/sandbox/Readme.md
deleted file mode 100644
index e8acd78b..00000000
--- a/archive/2.vm/sandbox/Readme.md
+++ /dev/null
@@ -1,33 +0,0 @@
-Variant of [the Mu programming environment](../edit) that runs just the sandbox.
-
-Suitable for people who want to run their favorite terminal-based editor with
-Mu. Just run editor and sandbox inside split panes atop tmux. For example,
-here's Mu running alongside vim:
-
-<img alt='tmux+vim example' src='../html/tmux-vim-sandbox.png'>
-
-To set this up:
-
-  a) copy the lines in tmux.conf into `$HOME/.tmux.conf`.
-
-  b) copy the file `mu_run` somewhere in your `$PATH`.
-
-Now when you start tmux, split it into two vertical panes, run `./mu sandbox`
-on the right pane and your editor on the left. You should be able to hit F4 in
-either side to run the sandbox.
-
-Known issues: you have to explicitly save inside your editor before hitting
-F4, unlike with `./mu edit`.
-
----
-
-Appendix: keyboard shortcuts
-
-  _moving_
-  - `ctrl-a` or `home`: move cursor to start of line
-  - `ctrl-e` or `end`: move cursor to end of line
-
-  _modifying text_
-  - `ctrl-k`: delete text from cursor to end of line
-  - `ctrl-u`: delete text from start of line until just before cursor
-  - `ctrl-/`: comment/uncomment current line (using a special leader to ignore real comments https://www.reddit.com/r/vim/comments/4ootmz/_/d4ehmql)
diff --git a/archive/2.vm/sandbox/mu_run b/archive/2.vm/sandbox/mu_run
deleted file mode 100755
index b96cfd1c..00000000
--- a/archive/2.vm/sandbox/mu_run
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/zsh
-# Little bit of glue to support running Mu from Vim over tmux.
-
-export ALREADY_FOCUSED=0
-tmux list-panes |grep "^1.*active" -q && export ALREADY_FOCUSED=1
-if [[ $ALREADY_FOCUSED -eq 0 ]]
-then
-  tmux select-pane -t 1
-fi
-
-tmux send-keys 'F4'
-
-if [[ $ALREADY_FOCUSED -eq 0 ]]
-then
-  tmux last-pane
-fi
diff --git a/archive/2.vm/sandbox/tmux.conf b/archive/2.vm/sandbox/tmux.conf
deleted file mode 100644
index 7816b1eb..00000000
--- a/archive/2.vm/sandbox/tmux.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-# Hotkey for running Mu over tmux
-# Assumes exactly two panes, with vim running on the left side and `./mu sandbox` running on the right side.
-bind-key -n F4 run mu_run
diff --git a/archive/2.vm/screen.mu b/archive/2.vm/screen.mu
deleted file mode 100644
index 58ecaa60..00000000
--- a/archive/2.vm/screen.mu
+++ /dev/null
@@ -1,29 +0,0 @@
-# example program: managing the display using 'screen' objects
-
-# The zero screen below means 'use the real screen'. Tests can also use fake
-# screens.
-def main [
-  open-console
-  clear-screen null/screen  # non-scrolling app
-  10:char <- copy 97/a
-  print null/screen, 10:char/a, 1/red, 2/green
-  1:num/raw, 2:num/raw <- cursor-position null/screen
-  wait-for-event null/console
-  clear-screen null/screen
-  move-cursor null/screen, 0/row, 4/column
-  10:char <- copy 98/b
-  print null/screen, 10:char
-  wait-for-event null/console
-  move-cursor null/screen, 0/row, 0/column
-  clear-line null/screen
-  wait-for-event null/console
-  cursor-down null/screen
-  wait-for-event null/console
-  cursor-right null/screen
-  wait-for-event null/console
-  cursor-left null/screen
-  wait-for-event null/console
-  cursor-up null/screen
-  wait-for-event null/console
-  close-console
-]
diff --git a/archive/2.vm/snapshot_lesson b/archive/2.vm/snapshot_lesson
deleted file mode 100755
index cd4723c1..00000000
--- a/archive/2.vm/snapshot_lesson
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-# Hacky little helper called from edit/ and sandbox/ apps to save a snapshot
-# of lesson/ using git.
-set -e
-
-test -d lesson/.git || exit 0  # give up if it's not a git repo
-
-cd lesson
-# explicitly say '--all' for git 1.9
-git add --all .
-# bug in git: git diff -q messes up --exit-code
-git diff HEAD --exit-code >/dev/null || git commit -a -m . >/dev/null
diff --git a/archive/2.vm/static-dispatch.mu b/archive/2.vm/static-dispatch.mu
deleted file mode 100644
index a0157d13..00000000
--- a/archive/2.vm/static-dispatch.mu
+++ /dev/null
@@ -1,29 +0,0 @@
-# Example program showing how multiple functions with the same name can
-# coexist, and how we select between them.
-#
-# Expected output:
-#   4
-#   7
-#   7
-
-def test a:num -> b:num [
-  local-scope
-  load-inputs
-  b <- add a, 1
-]
-
-def test a:num, b:num -> c:num [
-  local-scope
-  load-inputs
-  c <- add a, b
-]
-
-def main [
-  local-scope
-  a:num <- test 3  # selects single-input version
-  $print a, 10/newline
-  b:num <- test 3, 4  # selects double-input version
-  $print b, 10/newline
-  c:num <- test 3, 4, 5  # prefers double- to single-input version
-  $print c, 10/newline
-]
diff --git a/archive/2.vm/tangle.mu b/archive/2.vm/tangle.mu
deleted file mode 100644
index 91f12dea..00000000
--- a/archive/2.vm/tangle.mu
+++ /dev/null
@@ -1,36 +0,0 @@
-# example program: constructing functions out of order
-#
-# We construct a factorial function with separate base and recursive cases.
-# Compare factorial.mu.
-#
-# This isn't a very tasteful example, just a basic demonstration of
-# possibilities.
-
-def factorial n:num -> result:num [
-  local-scope
-  load-inputs
-  <factorial-cases>
-]
-
-after <factorial-cases> [
-  # if n=0 return 1
-  return-unless n, 1
-]
-
-after <factorial-cases> [
-  # return n * factorial(n - 1)
-  {
-    break-unless n
-    x:num <- subtract n, 1
-    subresult:num <- factorial x
-    result <- multiply subresult, n
-    return result
-  }
-]
-
-def main [
-  1:num <- factorial 5
-  # trailing space in next line is to help with syntax highlighting
-  $print [result: ], 1:num, [ 
-]
-]
diff --git a/archive/2.vm/termbox/COPYING b/archive/2.vm/termbox/COPYING
deleted file mode 100644
index e9bb4eac..00000000
--- a/archive/2.vm/termbox/COPYING
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (C) 2010-2013 nsf <no.smile.face@gmail.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/archive/2.vm/termbox/Readme b/archive/2.vm/termbox/Readme
deleted file mode 100644
index d97cae4e..00000000
--- a/archive/2.vm/termbox/Readme
+++ /dev/null
@@ -1,2 +0,0 @@
-Fork of https://github.com/nsf/termbox as of 2015-06-05
-git hash 252bef01264a2aeef22ebe5bae0b5893a58947f3
diff --git a/archive/2.vm/termbox/bytebuffer.inl b/archive/2.vm/termbox/bytebuffer.inl
deleted file mode 100644
index aae8f073..00000000
--- a/archive/2.vm/termbox/bytebuffer.inl
+++ /dev/null
@@ -1,79 +0,0 @@
-struct bytebuffer {
-  char *buf;
-  int len;
-  int cap;
-};
-
-static void bytebuffer_reserve(struct bytebuffer *b, int cap) {
-  if (b->cap >= cap) {
-    return;
-  }
-
-  // prefer doubling capacity
-  if (b->cap * 2 >= cap) {
-    cap = b->cap * 2;
-  }
-
-  char *newbuf = malloc(cap);
-  if (b->len > 0) {
-    // copy what was there, b->len > 0 assumes b->buf != null
-    memcpy(newbuf, b->buf, b->len);
-  }
-  if (b->buf) {
-    // in case there was an allocated buffer, free it
-    free(b->buf);
-  }
-  b->buf = newbuf;
-  b->cap = cap;
-}
-
-static void bytebuffer_init(struct bytebuffer *b, int cap) {
-  b->cap = 0;
-  b->len = 0;
-  b->buf = 0;
-
-  if (cap > 0) {
-    b->cap = cap;
-    b->buf = malloc(cap); // just assume malloc works always
-  }
-}
-
-static void bytebuffer_free(struct bytebuffer *b) {
-  if (b->buf)
-    free(b->buf);
-}
-
-static void bytebuffer_clear(struct bytebuffer *b) {
-  b->len = 0;
-}
-
-static void bytebuffer_append(struct bytebuffer *b, const char *data, int len) {
-  bytebuffer_reserve(b, b->len + len);
-  memcpy(b->buf + b->len, data, len);
-  b->len += len;
-}
-
-static void bytebuffer_puts(struct bytebuffer *b, const char *str) {
-  bytebuffer_append(b, str, strlen(str));
-}
-
-static void bytebuffer_resize(struct bytebuffer *b, int len) {
-  bytebuffer_reserve(b, len);
-  b->len = len;
-}
-
-static void bytebuffer_flush(struct bytebuffer *b, int fd) {
-  int yyy = write(fd, b->buf, b->len);
-  (void) yyy;
-  bytebuffer_clear(b);
-}
-
-static void bytebuffer_truncate(struct bytebuffer *b, int n) {
-  if (n <= 0)
-    return;
-  if (n > b->len)
-    n = b->len;
-  const int nmove = b->len - n;
-  memmove(b->buf, b->buf+n, nmove);
-  b->len -= n;
-}
diff --git a/archive/2.vm/termbox/input.inl b/archive/2.vm/termbox/input.inl
deleted file mode 100644
index 83b4bb8c..00000000
--- a/archive/2.vm/termbox/input.inl
+++ /dev/null
@@ -1,185 +0,0 @@
-// if s1 starts with s2 returns true, else false
-// len is the length of s1
-// s2 should be null-terminated
-static bool starts_with(const char *s1, int len, const char *s2)
-{
-  int n = 0;
-  while (*s2 && n < len) {
-    if (*s1++ != *s2++)
-      return false;
-    n++;
-  }
-  return *s2 == 0;
-}
-
-#define FOO(...) { \
-  FILE* f = fopen("log", "a+"); \
-  fprintf(f, __VA_ARGS__); \
-  fclose(f); \
-}
-
-// convert escape sequence to event, and return consumed bytes on success (failure == 0)
-static int parse_escape_seq(struct tb_event *event, const char *buf, int len)
-{
-  static int parse_attempts = 0;
-  static const int MAX_PARSE_ATTEMPTS = 2;
-
-//?   int x = 0;
-//?   FOO("-- %d\n", len);
-//?   for (x = 0; x < len; ++x) {
-//?     FOO("%d\n", (unsigned char)buf[x]);
-//?   }
-  if (len >= 6 && starts_with(buf, len, "\033[M")) {
-
-    switch (buf[3] & 3) {
-    case 0:
-      if (buf[3] == 0x60)
-        event->key = TB_KEY_MOUSE_WHEEL_UP;
-      else
-        event->key = TB_KEY_MOUSE_LEFT;
-      break;
-    case 1:
-      if (buf[3] == 0x61)
-        event->key = TB_KEY_MOUSE_WHEEL_DOWN;
-      else
-        event->key = TB_KEY_MOUSE_MIDDLE;
-      break;
-    case 2:
-      event->key = TB_KEY_MOUSE_RIGHT;
-      break;
-    case 3:
-      event->key = TB_KEY_MOUSE_RELEASE;
-      break;
-    default:
-      parse_attempts = 0;
-      return -6;
-    }
-    event->type = TB_EVENT_MOUSE; // TB_EVENT_KEY by default
-
-    // the coord is 1,1 for upper left
-    event->x = (uint8_t)buf[4] - 1 - 32;
-    event->y = (uint8_t)buf[5] - 1 - 32;
-
-    parse_attempts = 0;
-    return 6;
-  }
-
-  // it's pretty simple here, find 'starts_with' match and return
-  // success, else return failure
-  int i;
-  for (i = 0; keys[i]; i++) {
-    if (starts_with(buf, len, keys[i])) {
-      event->ch = 0;
-      event->key = 0xFFFF-i;
-      parse_attempts = 0;
-      return strlen(keys[i]);
-    }
-  }
-
-  if (starts_with(buf, len, "\033[200~")) {
-    event->ch = 0;
-    event->key = TB_KEY_START_PASTE;
-    parse_attempts = 0;
-    return strlen("\033[200~");
-  }
-  if (starts_with(buf, len, "\033[201~")) {
-    event->ch = 0;
-    event->key = TB_KEY_END_PASTE;
-    parse_attempts = 0;
-    return strlen("\033[201~");
-  }
-  if (starts_with(buf, len, "\033[1;5A")) {
-    event->ch = 0;
-    event->key = TB_KEY_CTRL_ARROW_UP;
-    parse_attempts = 0;
-    return strlen("\033[1;5A");
-  }
-  if (starts_with(buf, len, "\033[1;5B")) {
-    event->ch = 0;
-    event->key = TB_KEY_CTRL_ARROW_DOWN;
-    parse_attempts = 0;
-    return strlen("\033[1;5B");
-  }
-  if (starts_with(buf, len, "\033[1;5C")) {
-    event->ch = 0;
-    event->key = TB_KEY_CTRL_ARROW_RIGHT;
-    parse_attempts = 0;
-    return strlen("\033[1;5C");
-  }
-  if (starts_with(buf, len, "\033[1;5D")) {
-    event->ch = 0;
-    event->key = TB_KEY_CTRL_ARROW_LEFT;
-    parse_attempts = 0;
-    return strlen("\033[1;5D");
-  }
-  if (starts_with(buf, len, "\033[Z")) {
-    event->ch = 0;
-    event->key = TB_KEY_SHIFT_TAB;
-    parse_attempts = 0;
-    return strlen("\033[Z");
-  }
-
-  // no escape sequence recognized? wait a bit in case our buffer is incomplete
-  ++parse_attempts;
-  if (parse_attempts < MAX_PARSE_ATTEMPTS) return 0;
-  // still nothing? give up and consume just the esc
-  event->ch = 0;
-  event->key = TB_KEY_ESC;
-  parse_attempts = 0;
-  return 1;
-}
-
-static bool extract_event(struct tb_event *event, struct bytebuffer *inbuf)
-{
-  const char *buf = inbuf->buf;
-  const int len = inbuf->len;
-  if (len == 0)
-    return false;
-
-//?   int x = 0;
-//?   FOO("== %d\n", len);
-//?   for (x = 0; x < len; ++x) {
-//?     FOO("%x\n", (unsigned char)buf[x]);
-//?   }
-  if (buf[0] == '\033') {
-    int n = parse_escape_seq(event, buf, len);
-    if (n == 0) return false;
-//?     FOO("parsed: %u %u %u %u\n", n, (unsigned int)event->type, (unsigned int)event->key, event->ch);
-    bool success = true;
-    if (n < 0) {
-      success = false;
-      n = -n;
-    }
-    bytebuffer_truncate(inbuf, n);
-    return success;
-  }
-
-  // if we're here, this is not an escape sequence and not an alt sequence
-  // so, it's a FUNCTIONAL KEY or a UNICODE character
-
-  // first of all check if it's a functional key
-  if ((unsigned char)buf[0] <= TB_KEY_SPACE ||
-      (unsigned char)buf[0] == TB_KEY_BACKSPACE2)
-  {
-    // fill event, pop buffer, return success */
-    event->ch = 0;
-    event->key = (uint16_t)buf[0];
-    bytebuffer_truncate(inbuf, 1);
-    return true;
-  }
-
-  // feh... we got utf8 here
-
-  // check if there is all bytes
-  if (len >= tb_utf8_char_length(buf[0])) {
-    /* everything ok, fill event, pop buffer, return success */
-    tb_utf8_char_to_unicode(&event->ch, buf);
-    event->key = 0;
-    bytebuffer_truncate(inbuf, tb_utf8_char_length(buf[0]));
-    return true;
-  }
-
-  // event isn't recognized, perhaps there is not enough bytes in utf8
-  // sequence
-  return false;
-}
diff --git a/archive/2.vm/termbox/output.inl b/archive/2.vm/termbox/output.inl
deleted file mode 100644
index d87049ef..00000000
--- a/archive/2.vm/termbox/output.inl
+++ /dev/null
@@ -1,320 +0,0 @@
-enum {
-  T_ENTER_CA,
-  T_EXIT_CA,
-  T_SHOW_CURSOR,
-  T_HIDE_CURSOR,
-  T_CLEAR_SCREEN,
-  T_SGR0,
-  T_UNDERLINE,
-  T_BOLD,
-  T_BLINK,
-  T_REVERSE,
-  T_ENTER_KEYPAD,
-  T_EXIT_KEYPAD,
-  T_ENTER_MOUSE,
-  T_EXIT_MOUSE,
-  T_ENTER_BRACKETED_PASTE,
-  T_EXIT_BRACKETED_PASTE,
-  T_FUNCS_NUM,
-};
-
-#define EUNSUPPORTED_TERM -1
-
-// rxvt-256color
-static const char *rxvt_256color_keys[] = {
-  "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
-};
-static const char *rxvt_256color_funcs[] = {
-  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
-};
-
-// Eterm
-static const char *eterm_keys[] = {
-  "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
-};
-static const char *eterm_funcs[] = {
-  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "", "", "",
-};
-
-// screen
-static const char *screen_keys[] = {
-  "\033OP", "\033OQ", "\033OR", "\033OS", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[1~", "\033[4~", "\033[5~", "\033[6~", "\033OA", "\033OB", "\033OD", "\033OC", 0
-};
-static const char *screen_funcs[] = {
-  "\033[?1049h", "\033[?1049l", "\033[34h\033[?25h", "\033[?25l", "\033[H\033[J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
-};
-
-// rxvt-unicode
-static const char *rxvt_unicode_keys[] = {
-  "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
-};
-static const char *rxvt_unicode_funcs[] = {
-  "\033[?1049h", "\033[r\033[?1049l", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m\033(B", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
-};
-
-// linux
-static const char *linux_keys[] = {
-  "\033[[A", "\033[[B", "\033[[C", "\033[[D", "\033[[E", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[1~", "\033[4~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
-};
-static const char *linux_funcs[] = {
-  "", "", "\033[?25h\033[?0c", "\033[?25l\033[?1c", "\033[H\033[J", "\033[0;10m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "", "", "",
-};
-
-// xterm
-static const char *xterm_keys[] = {
-  "\033OP", "\033OQ", "\033OR", "\033OS", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033OH", "\033OF", "\033[5~", "\033[6~", "\033OA", "\033OB", "\033OD", "\033OC", 0
-};
-static const char *xterm_funcs[] = {
-  "\033[?1049h", "\033[?1049l", "\033[?12l\033[?25h", "\033[?25l", "\033[H\033[2J", "\033(B\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
-};
-
-static struct term {
-  const char *name;
-  const char **keys;
-  const char **funcs;
-} terms[] = {
-  {"rxvt-256color", rxvt_256color_keys, rxvt_256color_funcs},
-  {"Eterm", eterm_keys, eterm_funcs},
-  {"screen", screen_keys, screen_funcs},
-  {"rxvt-unicode", rxvt_unicode_keys, rxvt_unicode_funcs},
-  {"linux", linux_keys, linux_funcs},
-  {"xterm", xterm_keys, xterm_funcs},
-  {0, 0, 0},
-};
-
-static bool init_from_terminfo = false;
-static const char **keys;
-static const char **funcs;
-
-static int try_compatible(const char *term, const char *name,
-        const char **tkeys, const char **tfuncs)
-{
-  if (strstr(term, name)) {
-    keys = tkeys;
-    funcs = tfuncs;
-    return 0;
-  }
-
-  return EUNSUPPORTED_TERM;
-}
-
-static int init_term_builtin(void)
-{
-  int i;
-  const char *term = getenv("TERM");
-
-  if (term) {
-    for (i = 0; terms[i].name; i++) {
-      if (!strcmp(terms[i].name, term)) {
-        keys = terms[i].keys;
-        funcs = terms[i].funcs;
-        return 0;
-      }
-    }
-
-    /* let's do some heuristic, maybe it's a compatible terminal */
-    if (try_compatible(term, "xterm", xterm_keys, xterm_funcs) == 0)
-      return 0;
-    if (try_compatible(term, "rxvt", rxvt_unicode_keys, rxvt_unicode_funcs) == 0)
-      return 0;
-    if (try_compatible(term, "linux", linux_keys, linux_funcs) == 0)
-      return 0;
-    if (try_compatible(term, "Eterm", eterm_keys, eterm_funcs) == 0)
-      return 0;
-    if (try_compatible(term, "screen", screen_keys, screen_funcs) == 0)
-      return 0;
-    /* let's assume that 'cygwin' is xterm compatible */
-    if (try_compatible(term, "cygwin", xterm_keys, xterm_funcs) == 0)
-      return 0;
-  }
-
-  return EUNSUPPORTED_TERM;
-}
-
-//----------------------------------------------------------------------
-// terminfo
-//----------------------------------------------------------------------
-
-static char *read_file(const char *file) {
-  FILE *f = fopen(file, "rb");
-  if (!f)
-    return 0;
-
-  struct stat st;
-  if (fstat(fileno(f), &st) != 0) {
-    fclose(f);
-    return 0;
-  }
-
-  char *data = malloc(st.st_size);
-  if (!data) {
-    fclose(f);
-    return 0;
-  }
-
-  if (fread(data, 1, st.st_size, f) != (size_t)st.st_size) {
-    fclose(f);
-    free(data);
-    return 0;
-  }
-
-  fclose(f);
-  return data;
-}
-
-static char *terminfo_try_path(const char *path, const char *term) {
-  char tmp[4096];
-  // snprintf guarantee for older compilers
-  assert(sizeof(tmp) > sizeof(path)+sizeof("/x/")+sizeof(term)+1);
-  snprintf(tmp, sizeof(tmp), "%s/%c/%s", path, term[0], term);
-  char *data = read_file(tmp);
-  if (data) {
-    return data;
-  }
-
-  // fallback to darwin specific dirs structure
-  // snprintf guarantee above still applies
-  snprintf(tmp, sizeof(tmp), "%s/%x/%s", path, term[0], term);
-  return read_file(tmp);
-}
-
-void string_copy(char* dest, const char* src, int dest_capacity) {
-  strncpy(dest, src, dest_capacity);
-  dest[dest_capacity-1] = '\0';
-}
-
-void string_append(char* dest, const char* src, int dest_capacity) {
-  strncat(dest, src, dest_capacity);
-  dest[dest_capacity-1] = '\0';
-}
-
-static char *load_terminfo(void) {
-  char tmp[4096];
-  const char *term = getenv("TERM");
-  if (!term) {
-    return 0;
-  }
-
-  // if TERMINFO is set, no other directory should be searched
-  const char *terminfo = getenv("TERMINFO");
-  if (terminfo) {
-    return terminfo_try_path(terminfo, term);
-  }
-
-  // next, consider ~/.terminfo
-  const char *home = getenv("HOME");
-  if (home) {
-    // snprintf guarantee for older compilers
-    assert(sizeof(tmp) > sizeof(home)+sizeof("/.terminfo")+1);
-    string_copy(tmp, home, sizeof(tmp));
-    string_append(tmp, "/.terminfo", sizeof(tmp));
-    char *data = terminfo_try_path(tmp, term);
-    if (data)
-      return data;
-  }
-
-  // next, TERMINFO_DIRS
-  const char *dirs = getenv("TERMINFO_DIRS");
-  if (dirs) {
-    // snprintf guarantee for older compilers
-    assert(sizeof(tmp) > sizeof(dirs));
-    strncpy(tmp, dirs, sizeof(tmp));
-    char *dir = strtok(tmp, ":");
-    while (dir) {
-      const char *cdir = dir;
-      if (strcmp(cdir, "") == 0) {
-        cdir = "/usr/share/terminfo";
-      }
-      char *data = terminfo_try_path(cdir, term);
-      if (data)
-        return data;
-      dir = strtok(0, ":");
-    }
-  }
-
-  // fallback to /usr/share/terminfo
-  return terminfo_try_path("/usr/share/terminfo", term);
-}
-
-#define TI_MAGIC 0432
-#define TI_HEADER_LENGTH 12
-#define TB_KEYS_NUM 22
-
-static const char *terminfo_copy_string(char *data, int str, int table) {
-  const int16_t off = *(int16_t*)(data + str);
-  const char *src = data + table + off;
-  int len = strlen(src);
-  char *dst = malloc(len+1);
-  string_copy(dst, src, len+1);
-  return dst;
-}
-
-static const int16_t ti_funcs[] = {
-  28, 40, 16, 13, 5, 39, 36, 27, 26, 34, 89, 88,
-};
-
-static const int16_t ti_keys[] = {
-  66, 68 /* apparently not a typo; 67 is F10 for whatever reason */, 69,
-  70, 71, 72, 73, 74, 75, 67, 216, 217, 77, 59, 76, 164, 82, 81, 87, 61,
-  79, 83,
-};
-
-static int init_term(void) {
-  int i;
-  char *data = load_terminfo();
-  if (!data) {
-    init_from_terminfo = false;
-    return init_term_builtin();
-  }
-
-  int16_t *header = (int16_t*)data;
-  if ((header[1] + header[2]) % 2) {
-    // old quirk to align everything on word boundaries
-    header[2] += 1;
-  }
-
-  const int str_offset = TI_HEADER_LENGTH +
-    header[1] + header[2] + 2 * header[3];
-  const int table_offset = str_offset + 2 * header[4];
-
-  keys = malloc(sizeof(const char*) * (TB_KEYS_NUM+1));
-  for (i = 0; i < TB_KEYS_NUM; i++) {
-    keys[i] = terminfo_copy_string(data,
-      str_offset + 2 * ti_keys[i], table_offset);
-  }
-  keys[TB_KEYS_NUM] = 0;
-
-  funcs = malloc(sizeof(const char*) * T_FUNCS_NUM);
-  // the last four entries are reserved for mouse, bracketed paste. because the table offset is
-  // not there, the two entries have to fill in manually
-  for (i = 0; i < T_FUNCS_NUM-4; i++) {
-    funcs[i] = terminfo_copy_string(data,
-      str_offset + 2 * ti_funcs[i], table_offset);
-  }
-
-  funcs[T_FUNCS_NUM-4] = "\033[?1000h";
-  funcs[T_FUNCS_NUM-3] = "\033[?1000l";
-  funcs[T_FUNCS_NUM-2] = "\033[?2004h";
-  funcs[T_FUNCS_NUM-1] = "\033[?2004l";
-
-  init_from_terminfo = true;
-  free(data);
-  return 0;
-}
-
-static void shutdown_term(void) {
-  if (init_from_terminfo) {
-    int i;
-    for (i = 0; i < TB_KEYS_NUM; i++) {
-      free((void*)keys[i]);
-    }
-    // the last four entries are reserved for mouse, bracketed paste. because the table offset
-    // is not there, the two entries have to fill in manually and do not
-    // need to be freed.
-    for (i = 0; i < T_FUNCS_NUM-4; i++) {
-      free((void*)funcs[i]);
-    }
-    free(keys);
-    free(funcs);
-  }
-}
diff --git a/archive/2.vm/termbox/termbox.c b/archive/2.vm/termbox/termbox.c
deleted file mode 100644
index c97f03d5..00000000
--- a/archive/2.vm/termbox/termbox.c
+++ /dev/null
@@ -1,397 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <termios.h>
-#include <unistd.h>
-#include <wchar.h>
-/* hack: we can't define _XOPEN_SOURCE because that causes OpenBSD to not
- * include SIGWINCH. But then this prototype is not included on Linux,
- * triggering a warning. */
-extern int wcwidth (wchar_t);
-
-#include "termbox.h"
-
-#include "bytebuffer.inl"
-#include "output.inl"
-#include "input.inl"
-
-#define LAST_COORD_INIT -1
-
-static struct termios orig_tios;
-
-static struct bytebuffer output_buffer;
-static struct bytebuffer input_buffer;
-
-static int termw = -1;
-static int termh = -1;
-
-static int inout;
-static int winch_fds[2];
-
-static int cursor_x = 0;
-static int cursor_y = 0;
-
-static uint16_t background = TB_BLACK;
-static uint16_t foreground = TB_WHITE;
-
-static void update_size(void);
-static void update_term_size(void);
-static void send_attr(uint16_t fg, uint16_t bg);
-static void send_clear(void);
-static void sigwinch_handler(int xxx);
-static int wait_fill_event(struct tb_event *event, struct timeval *timeout);
-
-/* may happen in a different thread */
-static volatile int buffer_size_change_request;
-
-/* -------------------------------------------------------- */
-
-int tb_init(void)
-{
-  inout = open("/dev/tty", O_RDWR);
-  if (inout == -1) {
-    return TB_EFAILED_TO_OPEN_TTY;
-  }
-
-  if (init_term() < 0) {
-    close(inout);
-    return TB_EUNSUPPORTED_TERMINAL;
-  }
-
-  if (pipe(winch_fds) < 0) {
-    close(inout);
-    return TB_EPIPE_TRAP_ERROR;
-  }
-
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(sa));
-  sa.sa_handler = sigwinch_handler;
-  sa.sa_flags = 0;
-  sigaction(SIGWINCH, &sa, 0);
-
-  tcgetattr(inout, &orig_tios);
-
-  struct termios tios;
-  memcpy(&tios, &orig_tios, sizeof(tios));
-
-  tios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
-                           | INLCR | IGNCR | ICRNL | IXON);
-  tios.c_oflag &= ~OPOST;
-  tios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
-  tios.c_cflag &= ~(CSIZE | PARENB);
-  tios.c_cflag |= CS8;
-  tios.c_cc[VMIN] = 0;
-  tios.c_cc[VTIME] = 0;
-  tcsetattr(inout, TCSAFLUSH, &tios);
-
-  bytebuffer_init(&input_buffer, 128);
-  bytebuffer_init(&output_buffer, 32 * 1024);
-
-  bytebuffer_puts(&output_buffer, funcs[T_ENTER_KEYPAD]);
-  bytebuffer_puts(&output_buffer, funcs[T_ENTER_MOUSE]);
-  bytebuffer_puts(&output_buffer, funcs[T_ENTER_BRACKETED_PASTE]);
-  bytebuffer_flush(&output_buffer, inout);
-
-  update_term_size();
-  return 0;
-}
-
-void tb_shutdown(void)
-{
-  if (termw == -1) return;
-
-  bytebuffer_puts(&output_buffer, funcs[T_SGR0]);
-  bytebuffer_puts(&output_buffer, funcs[T_EXIT_KEYPAD]);
-  bytebuffer_puts(&output_buffer, funcs[T_EXIT_MOUSE]);
-  bytebuffer_puts(&output_buffer, funcs[T_EXIT_BRACKETED_PASTE]);
-  bytebuffer_flush(&output_buffer, inout);
-  tcsetattr(inout, TCSAFLUSH, &orig_tios);
-
-  shutdown_term();
-  close(inout);
-  close(winch_fds[0]);
-  close(winch_fds[1]);
-
-  bytebuffer_free(&output_buffer);
-  bytebuffer_free(&input_buffer);
-  termw = termh = -1;
-}
-
-int tb_is_active(void)
-{
-  return termw != -1;
-}
-
-void tb_print(uint32_t ch, uint16_t fg, uint16_t bg)
-{
-  assert(termw != -1);
-  send_attr(fg, bg);
-  if (ch == 0) {
-    // replace 0 with whitespace
-    bytebuffer_puts(&output_buffer, " ");
-  }
-  else {
-    char buf[7];
-    int bw = tb_utf8_unicode_to_char(buf, ch);
-    buf[bw] = '\0';
-    bytebuffer_puts(&output_buffer, buf);
-  }
-  bytebuffer_flush(&output_buffer, inout);
-}
-
-int tb_poll_event(struct tb_event *event)
-{
-  assert(termw != -1);
-  return wait_fill_event(event, 0);
-}
-
-int tb_peek_event(struct tb_event *event, int timeout)
-{
-  struct timeval tv;
-  tv.tv_sec = timeout / 1000;
-  tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
-  assert(termw != -1);
-  return wait_fill_event(event, &tv);
-}
-
-int tb_width(void)
-{
-  assert(termw != -1);
-  return termw;
-}
-
-int tb_height(void)
-{
-  assert(termw != -1);
-  return termh;
-}
-
-void tb_clear(void)
-{
-  assert(termw != -1);
-  if (buffer_size_change_request) {
-    update_size();
-    buffer_size_change_request = 0;
-  }
-  send_clear();
-}
-
-void tb_set_clear_attributes(uint16_t fg, uint16_t bg)
-{
-  assert(termw != -1);
-  foreground = fg;
-  background = bg;
-}
-
-/* -------------------------------------------------------- */
-
-static int convertnum(uint32_t num, char* buf) {
-  int i, l = 0;
-  int ch;
-  do {
-    buf[l++] = '0' + (num % 10);
-    num /= 10;
-  } while (num);
-  for(i = 0; i < l / 2; i++) {
-    ch = buf[i];
-    buf[i] = buf[l - 1 - i];
-    buf[l - 1 - i] = ch;
-  }
-  return l;
-}
-
-#define WRITE_LITERAL(X) bytebuffer_append(&output_buffer, (X), sizeof(X)-1)
-#define WRITE_INT(X) bytebuffer_append(&output_buffer, buf, convertnum((X), buf))
-
-void tb_set_cursor(int x, int y) {
-  char buf[32];
-  WRITE_LITERAL("\033[");
-  WRITE_INT(y+1);
-  WRITE_LITERAL(";");
-  WRITE_INT(x+1);
-  WRITE_LITERAL("H");
-  bytebuffer_flush(&output_buffer, inout);
-}
-
-static void get_term_size(int *w, int *h)
-{
-  struct winsize sz;
-  memset(&sz, 0, sizeof(sz));
-
-  ioctl(inout, TIOCGWINSZ, &sz);
-
-  if (w) *w = sz.ws_col;
-  if (h) *h = sz.ws_row;
-}
-
-static void update_term_size(void)
-{
-  struct winsize sz;
-  memset(&sz, 0, sizeof(sz));
-
-  ioctl(inout, TIOCGWINSZ, &sz);
-
-  termw = sz.ws_col;
-  termh = sz.ws_row;
-}
-
-static void send_attr(uint16_t fg, uint16_t bg)
-{
-#define LAST_ATTR_INIT 0xFFFF
-  static uint16_t lastfg = LAST_ATTR_INIT, lastbg = LAST_ATTR_INIT;
-  if (fg != lastfg || bg != lastbg) {
-    bytebuffer_puts(&output_buffer, funcs[T_SGR0]);
-
-    uint16_t fgcol = fg & 0xFF;
-    uint16_t bgcol = bg & 0xFF;
-
-    if (fg & TB_BOLD)
-      bytebuffer_puts(&output_buffer, funcs[T_BOLD]);
-    if (bg & TB_BOLD)
-      bytebuffer_puts(&output_buffer, funcs[T_BLINK]);
-    if (fg & TB_UNDERLINE)
-      bytebuffer_puts(&output_buffer, funcs[T_UNDERLINE]);
-    if ((fg & TB_REVERSE) || (bg & TB_REVERSE))
-      bytebuffer_puts(&output_buffer, funcs[T_REVERSE]);
-    char buf[32];
-    WRITE_LITERAL("\033[38;5;");
-    WRITE_INT(fgcol);
-    WRITE_LITERAL("m");
-    WRITE_LITERAL("\033[48;5;");
-    WRITE_INT(bgcol);
-    WRITE_LITERAL("m");
-    bytebuffer_flush(&output_buffer, inout);
-    lastfg = fg;
-    lastbg = bg;
-  }
-}
-
-const char* to_unicode(uint32_t c)
-{
-  static char buf[7];
-  int bw = tb_utf8_unicode_to_char(buf, c);
-  buf[bw] = '\0';
-  return buf;
-}
-
-static void send_clear(void)
-{
-  send_attr(foreground, background);
-  bytebuffer_puts(&output_buffer, funcs[T_CLEAR_SCREEN]);
-  tb_set_cursor(cursor_x, cursor_y);
-  bytebuffer_flush(&output_buffer, inout);
-}
-
-static void sigwinch_handler(int xxx)
-{
-  (void) xxx;
-  const int zzz = 1;
-  int yyy = write(winch_fds[1], &zzz, sizeof(int));
-  (void) yyy;
-}
-
-static void update_size(void)
-{
-  update_term_size();
-  send_clear();
-}
-
-static int read_up_to(int n) {
-  assert(n > 0);
-  const int prevlen = input_buffer.len;
-  bytebuffer_resize(&input_buffer, prevlen + n);
-
-  int read_n = 0;
-  while (read_n <= n) {
-    ssize_t r = 0;
-    if (read_n < n) {
-      r = read(inout, input_buffer.buf + prevlen + read_n, n - read_n);
-    }
-#ifdef __CYGWIN__
-    // While linux man for tty says when VMIN == 0 && VTIME == 0, read
-    // should return 0 when there is nothing to read, cygwin's read returns
-    // -1. Not sure why and if it's correct to ignore it, but let's pretend
-    // it's zero.
-    if (r < 0) r = 0;
-#endif
-    if (r < 0) {
-      // EAGAIN / EWOULDBLOCK shouldn't occur here
-      assert(errno != EAGAIN && errno != EWOULDBLOCK);
-      return -1;
-    } else if (r > 0) {
-      read_n += r;
-    } else {
-      bytebuffer_resize(&input_buffer, prevlen + read_n);
-      return read_n;
-    }
-  }
-  assert(!"unreachable");
-  return 0;
-}
-
-int tb_event_ready(void)
-{
-  return input_buffer.len > 0;
-}
-
-static int wait_fill_event(struct tb_event *event, struct timeval *timeout)
-{
-  // ;-)
-#define ENOUGH_DATA_FOR_PARSING 64
-  fd_set events;
-  memset(event, 0, sizeof(struct tb_event));
-
-  // try to extract event from input buffer, return on success
-  event->type = TB_EVENT_KEY;
-  if (extract_event(event, &input_buffer))
-    return event->type;
-
-  // it looks like input buffer is incomplete, let's try the short path,
-  // but first make sure there is enough space
-  int n = read_up_to(ENOUGH_DATA_FOR_PARSING);
-  if (n < 0)
-    return -1;
-  if (n > 0 && extract_event(event, &input_buffer))
-    return event->type;
-
-  // n == 0, or not enough data, let's go to select
-  while (1) {
-    FD_ZERO(&events);
-    FD_SET(inout, &events);
-    FD_SET(winch_fds[0], &events);
-    int maxfd = (winch_fds[0] > inout) ? winch_fds[0] : inout;
-    int result = select(maxfd+1, &events, 0, 0, timeout);
-    if (!result)
-      return 0;
-
-    if (FD_ISSET(inout, &events)) {
-      event->type = TB_EVENT_KEY;
-      n = read_up_to(ENOUGH_DATA_FOR_PARSING);
-      if (n < 0)
-        return -1;
-
-      if (n == 0)
-        continue;
-
-      if (extract_event(event, &input_buffer))
-        return event->type;
-    }
-    if (FD_ISSET(winch_fds[0], &events)) {
-      event->type = TB_EVENT_RESIZE;
-      int zzz = 0;
-      int yyy = read(winch_fds[0], &zzz, sizeof(int));
-      (void) yyy;
-      buffer_size_change_request = 1;
-      get_term_size(&event->w, &event->h);
-      return TB_EVENT_RESIZE;
-    }
-  }
-}
diff --git a/archive/2.vm/termbox/termbox.h b/archive/2.vm/termbox/termbox.h
deleted file mode 100644
index 43b326cb..00000000
--- a/archive/2.vm/termbox/termbox.h
+++ /dev/null
@@ -1,190 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*** 1. Controlling the screen. */
-
-/* Names for some foreground/background colors. */
-#define TB_BLACK 232
-#define TB_WHITE 255
-
-/* Some attributes of screen cells that can be combined with colors using
- * bitwise-OR. */
-#define TB_BOLD      0x0100
-#define TB_UNDERLINE 0x0200
-#define TB_REVERSE   0x0400
-
-/* Initialize screen and keyboard. */
-int tb_init(void);
-/* Possible error codes returned by tb_init() */
-#define TB_EUNSUPPORTED_TERMINAL -1
-#define TB_EFAILED_TO_OPEN_TTY   -2
-/* Termbox uses unix pipes in order to deliver a message from a signal handler
- * (SIGWINCH) to the main event reading loop. */
-#define TB_EPIPE_TRAP_ERROR      -3
-
-/* Restore terminal mode. */
-void tb_shutdown(void);
-
-int tb_is_active(void);
-
-/* Size of the screen. Return negative values before tb_init() or after
- * tb_shutdown() */
-int tb_width(void);
-int tb_height(void);
-
-/* Clear the screen using either TB_DEFAULT or the color/attributes set by
- * tb_set_clear_attributes(). */
-void tb_clear(void);
-void tb_set_clear_attributes(uint16_t fg, uint16_t bg);
-
-/* Move the cursor. Upper-left character is (0, 0). */
-void tb_set_cursor(int cx, int cy);
-
-/* Modify the screen at the cursor. */
-void tb_print(uint32_t ch, uint16_t fg, uint16_t bg);
-
-/*** 2. Controlling keyboard events. */
-
-struct tb_event {
-  uint8_t type;
-  /* fields for type TB_EVENT_KEY. At most one of 'key' and 'ch' will be set at
-   * any time. */
-  uint16_t key;
-  uint32_t ch;
-  /* fields for type TB_EVENT_RESIZE */
-  int32_t w;
-  int32_t h;
-  /* fields for type TB_EVENT_MOUSE */
-  int32_t x;
-  int32_t y;
-};
-
-/* Possible values for tb_event.type. */
-#define TB_EVENT_KEY    1
-#define TB_EVENT_RESIZE 2
-#define TB_EVENT_MOUSE  3
-
-/* Possible values for tb_event.key. */
-#define TB_KEY_F1               (0xFFFF-0)
-#define TB_KEY_F2               (0xFFFF-1)
-#define TB_KEY_F3               (0xFFFF-2)
-#define TB_KEY_F4               (0xFFFF-3)
-#define TB_KEY_F5               (0xFFFF-4)
-#define TB_KEY_F6               (0xFFFF-5)
-#define TB_KEY_F7               (0xFFFF-6)
-#define TB_KEY_F8               (0xFFFF-7)
-#define TB_KEY_F9               (0xFFFF-8)
-#define TB_KEY_F10              (0xFFFF-9)
-#define TB_KEY_F11              (0xFFFF-10)
-#define TB_KEY_F12              (0xFFFF-11)
-#define TB_KEY_INSERT           (0xFFFF-12)
-#define TB_KEY_DELETE           (0xFFFF-13)
-#define TB_KEY_HOME             (0xFFFF-14)
-#define TB_KEY_END              (0xFFFF-15)
-#define TB_KEY_PGUP             (0xFFFF-16)
-#define TB_KEY_PGDN             (0xFFFF-17)
-#define TB_KEY_ARROW_UP         (0xFFFF-18)
-#define TB_KEY_ARROW_DOWN       (0xFFFF-19)
-#define TB_KEY_ARROW_LEFT       (0xFFFF-20)
-#define TB_KEY_ARROW_RIGHT      (0xFFFF-21)
-#define TB_KEY_MOUSE_LEFT       (0xFFFF-22)
-#define TB_KEY_MOUSE_RIGHT      (0xFFFF-23)
-#define TB_KEY_MOUSE_MIDDLE     (0xFFFF-24)
-#define TB_KEY_MOUSE_RELEASE    (0xFFFF-25)
-#define TB_KEY_MOUSE_WHEEL_UP   (0xFFFF-26)
-#define TB_KEY_MOUSE_WHEEL_DOWN (0xFFFF-27)
-#define TB_KEY_START_PASTE      (0xFFFF-28)
-#define TB_KEY_END_PASTE        (0xFFFF-29)
-#define TB_KEY_CTRL_ARROW_UP    (0xFFFF-30)
-#define TB_KEY_CTRL_ARROW_DOWN  (0xFFFF-31)
-#define TB_KEY_CTRL_ARROW_LEFT  (0xFFFF-32)
-#define TB_KEY_CTRL_ARROW_RIGHT (0xFFFF-33)
-#define TB_KEY_SHIFT_TAB        (0xFFFF-34)
-
-/* Names for some of the possible values for tb_event.ch. */
-/* These are all ASCII code points below SPACE character and a BACKSPACE key. */
-#define TB_KEY_CTRL_TILDE       0x00
-#define TB_KEY_CTRL_2           0x00 /* clash with 'CTRL_TILDE' */
-#define TB_KEY_CTRL_A           0x01
-#define TB_KEY_CTRL_B           0x02
-#define TB_KEY_CTRL_C           0x03
-#define TB_KEY_CTRL_D           0x04
-#define TB_KEY_CTRL_E           0x05
-#define TB_KEY_CTRL_F           0x06
-#define TB_KEY_CTRL_G           0x07
-#define TB_KEY_BACKSPACE        0x08
-#define TB_KEY_CTRL_H           0x08 /* clash with 'CTRL_BACKSPACE' */
-#define TB_KEY_TAB              0x09
-#define TB_KEY_CTRL_I           0x09 /* clash with 'TAB' */
-#define TB_KEY_CTRL_J           0x0A
-#define TB_KEY_CTRL_K           0x0B
-#define TB_KEY_CTRL_L           0x0C
-#define TB_KEY_ENTER            0x0D
-#define TB_KEY_CTRL_M           0x0D /* clash with 'ENTER' */
-#define TB_KEY_CTRL_N           0x0E
-#define TB_KEY_CTRL_O           0x0F
-#define TB_KEY_CTRL_P           0x10
-#define TB_KEY_CTRL_Q           0x11
-#define TB_KEY_CTRL_R           0x12
-#define TB_KEY_CTRL_S           0x13
-#define TB_KEY_CTRL_T           0x14
-#define TB_KEY_CTRL_U           0x15
-#define TB_KEY_CTRL_V           0x16
-#define TB_KEY_CTRL_W           0x17
-#define TB_KEY_CTRL_X           0x18
-#define TB_KEY_CTRL_Y           0x19
-#define TB_KEY_CTRL_Z           0x1A
-#define TB_KEY_ESC              0x1B
-#define TB_KEY_CTRL_LSQ_BRACKET 0x1B /* clash with 'ESC' */
-#define TB_KEY_CTRL_3           0x1B /* clash with 'ESC' */
-#define TB_KEY_CTRL_4           0x1C
-#define TB_KEY_CTRL_BACKSLASH   0x1C /* clash with 'CTRL_4' */
-#define TB_KEY_CTRL_5           0x1D
-#define TB_KEY_CTRL_RSQ_BRACKET 0x1D /* clash with 'CTRL_5' */
-#define TB_KEY_CTRL_6           0x1E
-#define TB_KEY_CTRL_7           0x1F
-#define TB_KEY_CTRL_SLASH       0x1F /* clash with 'CTRL_7' */
-#define TB_KEY_CTRL_UNDERSCORE  0x1F /* clash with 'CTRL_7' */
-#define TB_KEY_SPACE            0x20
-#define TB_KEY_BACKSPACE2       0x7F
-#define TB_KEY_CTRL_8           0x7F /* clash with 'DELETE' */
-/* These are non-existing ones.
- *
- * #define TB_KEY_CTRL_1 clash with '1'
- * #define TB_KEY_CTRL_9 clash with '9'
- * #define TB_KEY_CTRL_0 clash with '0'
- */
-/* Some aliases */
-#define TB_KEY_NEWLINE TB_KEY_CTRL_J
-#define TB_KEY_CARRIAGE_RETURN TB_KEY_CTRL_M
-
-/* Wait for an event up to 'timeout' milliseconds and fill the 'event'
- * structure with it, when the event is available. Returns the type of the
- * event (one of TB_EVENT_* constants) or -1 if there was an error or 0 in case
- * there were no event during 'timeout' period.
- */
-int tb_peek_event(struct tb_event *event, int timeout);
-
-/* Wait for an event forever and fill the 'event' structure with it, when the
- * event is available. Returns the type of the event (one of TB_EVENT_*
- * constants) or -1 if there was an error.
- */
-int tb_poll_event(struct tb_event *event);
-
-int tb_event_ready(void);
-
-/*** 3. Utility utf8 functions. */
-#define TB_EOF -1
-int tb_utf8_char_length(char c);
-int tb_utf8_char_to_unicode(uint32_t *out, const char *c);
-int tb_utf8_unicode_to_char(char *out, uint32_t c);
-const char* to_unicode(uint32_t c);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/archive/2.vm/termbox/utf8.c b/archive/2.vm/termbox/utf8.c
deleted file mode 100644
index 26c0c27b..00000000
--- a/archive/2.vm/termbox/utf8.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "termbox.h"
-
-static const unsigned char utf8_length[256] = {
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-static const unsigned char utf8_mask[6] = {
-  0x7F,
-  0x1F,
-  0x0F,
-  0x07,
-  0x03,
-  0x01
-};
-
-int tb_utf8_char_length(char c)
-{
-  return utf8_length[(unsigned char)c];
-}
-
-int tb_utf8_char_to_unicode(uint32_t *out, const char *c)
-{
-  if (*c == 0)
-    return TB_EOF;
-
-  int i;
-  unsigned char len = tb_utf8_char_length(*c);
-  unsigned char mask = utf8_mask[len-1];
-  uint32_t result = c[0] & mask;
-  for (i = 1; i < len; ++i) {
-    result <<= 6;
-    result |= c[i] & 0x3f;
-  }
-
-  *out = result;
-  return (int)len;
-}
-
-int tb_utf8_unicode_to_char(char *out, uint32_t c)
-{
-  int len = 0;
-  int first;
-  int i;
-
-  if (c < 0x80) {
-    first = 0;
-    len = 1;
-  } else if (c < 0x800) {
-    first = 0xc0;
-    len = 2;
-  } else if (c < 0x10000) {
-    first = 0xe0;
-    len = 3;
-  } else if (c < 0x200000) {
-    first = 0xf0;
-    len = 4;
-  } else if (c < 0x4000000) {
-    first = 0xf8;
-    len = 5;
-  } else {
-    first = 0xfc;
-    len = 6;
-  }
-
-  for (i = len - 1; i > 0; --i) {
-    out[i] = (c & 0x3f) | 0x80;
-    c >>= 6;
-  }
-  out[0] = c | first;
-
-  return len;
-}
diff --git a/archive/2.vm/test_layers b/archive/2.vm/test_layers
deleted file mode 100755
index 47cb01b0..00000000
--- a/archive/2.vm/test_layers
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-# Repeatedly stop building until successive layers, and run all tests built,
-# while checking for undefined behavior using both UBSan and Valgrind.
-#
-# Requires Linux.
-#
-# Usage:
-#   Test all layers:
-#     test_layers
-#   Test non-app layers after x:
-#     test_layers x
-#   Test layers after x and until y (inclusive):
-#     test_layers x y
-#   Test all layers for a specific app:
-#     test_layers app
-set -e
-
-test "$BUILD" || export BUILD=build3
-
-if [[ $1 == one-off ]]
-then
-  ./$BUILD
-  ./mu_bin test || exit 1
-  exit 0
-fi
-
-# Core layers atop Valgrind
-for f in [0-9]*
-do
-  if [[ $f < $1 ]]; then continue; fi
-  if [[ $2 && $f > $2 ]]; then exit 0; fi
-  echo "=== $f"
-  ./clean top-level  # preserve subsidiary tools like tangle and cleave
-  ./$BUILD --until $f || exit 1
-  # valgrind requires Linux
-  valgrind --leak-check=yes --num-callers=40 -q --error-exitcode=1 ./mu_bin test || exit 1
-  # run on Mac OS without valgrind, and with a hacky fix for the coarser clock
-#?   ./mu_bin test || exit 1
-#?   sleep 1
-done
-
-# Layers for Mu apps without Valgrind
-./clean
-./$BUILD
-
-if [[ ! $1 || $1 == chessboard ]]
-then
-  echo "=== chessboard"
-  ./mu_bin test chessboard.mu || exit 1
-fi
-
-# slices of edit/ for Travis CI
-if [[ ! $1 || $1 == edit ]]
-then
-  echo "=== edit: until 001"
-  ./mu_bin test edit/001* || exit 1
-  echo "=== edit: until 002"
-  ./mu_bin test edit/00[1-2]* || exit 1
-  echo "=== edit: until 003"
-  ./mu_bin test edit/00[1-3]* || exit 1
-fi
-if [[ ! $1 || $1 == edit2 ]]
-then
-  echo "=== edit: until 004"
-  ./mu_bin test edit/00[1-4]* || exit 1
-  echo "=== edit: until 005"
-  ./mu_bin test edit/00[1-5]* || exit 1
-  echo "=== edit: until 006"
-  ./mu_bin test edit/00[1-6]* || exit 1
-fi
-if [[ ! $1 || $1 == edit3 ]]
-then
-  echo "=== edit: until 007"
-  ./mu_bin test edit/00[1-7]* || exit 1
-  echo "=== edit: until 008"
-  ./mu_bin test edit/00[1-8]* || exit 1
-  echo "=== edit: until 009"
-  ./mu_bin test edit/00* || exit 1
-fi
-if [[ ! $1 || $1 == edit4 ]]
-then
-  echo "=== edit: until 010"
-  ./mu_bin test edit/00* edit/010* || exit 1
-  echo "=== edit: until 011"
-  ./mu_bin test edit/00* edit/01[01]* || exit 1
-  echo "=== edit: until 012"
-  ./mu_bin test edit/00* edit/01[0-2]* || exit 1
-fi
diff --git a/archive/2.vm/vimrc.vim b/archive/2.vm/vimrc.vim
deleted file mode 100644
index c63a8941..00000000
--- a/archive/2.vm/vimrc.vim
+++ /dev/null
@@ -1,31 +0,0 @@
-" Highlighting literate directives in C++ sources.
-function! HighlightTangledFile()
-  " Tangled comments only make sense in the sources and are stripped out of
-  " the generated .cc file. They're highlighted same as regular comments.
-  syntax match tangledComment /\/\/:.*/ | highlight link tangledComment Comment
-  syntax match tangledSalientComment /\/\/::.*/ | highlight link tangledSalientComment SalientComment
-  set comments-=://
-  set comments-=n://
-  set comments+=n://:,n://
-
-  " Inside tangle scenarios.
-  syntax region tangleDirective start=+:(+ skip=+".*"+ end=+)+
-  highlight link tangleDirective Delimiter
-  syntax match traceContains /^+.*/
-  highlight traceContains ctermfg=22
-  syntax match traceAbsent /^-.*/
-  highlight traceAbsent ctermfg=darkred
-  syntax match tangleScenarioSetup /^\s*% .*/ | highlight link tangleScenarioSetup SpecialChar
-  highlight Special ctermfg=160
-endfunction
-augroup LocalVimrc
-  autocmd BufRead,BufNewFile *.cc call HighlightTangledFile()
-  autocmd BufRead,BufNewFile *.mu set ft=mu
-augroup END
-
-" Scenarios considered:
-"   opening or starting vim with a new or existing file without an extension (should interpret as C++)
-"   opening or starting vim with a new or existing file with a .mu extension
-"   starting vim or opening a buffer without a file name (ok to do nothing)
-"   opening a second file in a new or existing window (shouldn't mess up existing highlighting)
-"   reloading an existing file (shouldn't mess up existing highlighting)
diff --git a/archive/2.vm/x.mu b/archive/2.vm/x.mu
deleted file mode 100644
index f53a86ba..00000000
--- a/archive/2.vm/x.mu
+++ /dev/null
@@ -1,8 +0,0 @@
-# example program: add two numbers
-
-def main [
-  11:num <- copy 1
-  12:num <- copy 3
-  13:num <- add 11:num, 12:num
-  $dump-memory
-]