What the host supplies: everything about a PurePy run that is not pure.
PurePy is a pure language, but a RUN is not a pure thing: it prints, it
reads its arguments, it loads modules, and -- when it is embedded -- it
calls out to whatever the application wants to expose. Those four are the
whole of it, and they are all here, so an embedder can see the surface at
once instead of discovering it a call at a time.
- Output. write receives what print produced, one call per
print, while the run is still going. A host that streams to a
terminal writes it out; a host that wants a transcript accumulates.
- Arguments. argv is what sys.argv reads. argv[0] is the
program's own name, as in Python.
- Modules. modules are importable modules the host defines, beyond
the five the specification predefines. Their members are values, and a
member may be a function the host implements.
- Foreign calls. call answers a call to one of those functions. It
is given the name the host registered and the arguments the guest
passed, and returns an Outcome: a value, an abort, or -- for
anything it does not recognise or cannot do -- an operation the
semantics does not cover.It is async, so it may also answer LATER: a host that has to read a
socket, await a promise or ask a person suspends, and the whole run
parks where it stood -- mid-expression, inside a call, anywhere -- and
resumes on the value the host eventually supplies. Nothing about the
guest changes: PurePy has no await, and a program cannot tell a call
that answered late from one that answered at once. See run_with for
how a synchronous embedder drives a run that can park.
Everything else about a run is already a value: the program is a
SourceTree, so a host that keeps its guest code in a database, a zip file
or a string never touches the filesystem.
Note what is NOT here. There is no way for the host to mutate a guest
value, because there is no mutation; no way to install a callback the guest
invokes implicitly, because there are no hooks; and no ambient authority at
all -- a guest can reach exactly the modules the host handed it. A host
that gives no modules gives a program that can only compute and print.
Suspension adds nothing to that list. A parked run is not a concurrent
one: there is one guest, it is at exactly one point, and the host holds
the only continuation. Resuming it twice is the host resuming it twice,
which is the host's bug and not an escape from the semantics.