Don't prevent run-code from clobbering existing functions, but warn
because it makes traces easier to read if the different sections of a
test can be distinguished.
For now we want to parse two labels:
'run', identifying call stack, op and args
'mem', distinguishing reads and writes
This should give us fodder for a few weeks, to build both a folding UI
for individual statements and descending the call stack, and also a
query engine that can figure out sources and sinks in the trace graph.
But now that we've added the keyboard parameter to process-keys,
modifying it in a recursive call also clobbers it in the caller. All
because of my weird, non-standard use of shared scope.
Swap printing generalized objects using arc's infrastructure to be the
$-prefixed debug helper, while the erstwhile $print-key-to-host becomes
the primitive print-character to host.
process-key is extracted to work on a given character, but its helpers
for parsing strings and comments still read keys directly from keyboard.
Still, this took long enough to get working that it's worth saving.
Milestones:
a) figuring out how to debug without dumping trace crap on the screen
in cursor mode.
b) realizing you can't assign directly to result in the up case. Have
to let the recursive call do it.
c) replacing continuations in 'process-key'.
You can't just extract the array from inside a buffer. Its length isn't
right. Only reason we didn't catch this sooner is I think that arc's
simulated memory is initialized to all nils, which has some
serendipitous properties.
I should initialize memory to random values one of these days and see
what shakes out.
We'll make 'buffer' properly generic at some point. Basically need to
support multi-word types.
x:list:integer <- copy y:list:integer # ok
x:list <- copy y:list:integer # ok
x:list:integer <- copy y:list # error
We'll need a separate runtime operator like maybe-coerce for the third
case.