A program leaves one window and finishes in another

A line typed at one prompt binds a name, moves to another prompt part way through, and prints the name’s value there. What moved is the running program itself, with its stack and its names, not a copy of the text.

You need: the command line host, and two terminals, both in the directory it was built in. You have it when a prompt answers : 23.

1. A prompt that runs what arrives

In the first terminal, open a prompt and give it a port:

./o.se -f o.se.osen/osen.ose
> (17793) /o/serve
(
 /socket : 3
)

/o/serve opens the port and runs every bundle that arrives on it, after saying what arrived. The prompt is free for more lines; the port is watched behind it.

2. A line that leaves

In the second terminal, open another prompt and type one line:

> /n : (20, 22) /o/add, ("127.0.0.1:17793") /continue/at, (/n) /o/println
: []

The first part ran here: /n is bound to 42. /continue/at then packed up the running line, the binding included, and sent it to the address. What this prompt answers is the empty result of a line that went away.

3. Where it finished

The first terminal:

(
 /bytes : 844,
 /from : "127.0.0.1"
)
: 42

The first lines are /o/serve saying what came: a machine of a few hundred bytes, from this computer. Then (/n) /o/println ran, here, with /n bound as it was.

Ask the second prompt for the name:

> /n
Caught exception: /n is not bound. Did you mean /and?

It left with the program.

What happened

If something goes wrong

what you see do
Address already in use after /o/serve another prompt holds the port: leave it with ctrl-C, or pick another port in both lines
the first terminal prints nothing after the line in step 2 the port in the two lines differs, or macOS asked whether o.se may accept connections and was told no: allow it and type the line again
: 42 prints in the second terminal the address was missing or mistyped, so the line ran here throughout

Examples · Between hosts · Command line