Portal is a unified REPL and command server for Clojure.
Portal uses netstrings to encode messages1. This makes client implementations as simple as possible. The format of an individual message is as follows:
id type data
The id
is a string identifier used to determine which evaluation context to use. The context is
used to maintain state across multiple commands and has a unique stdin, stdout and stderr from other
contexts. It is helpful to think of each context as executing in a dedicated thread, though actually
agents are used to implement contexts, so a thread pool is shared among all contexts.
In addition, all commands within a given context are serialized so they happen in the order they are received, and one command cannot start until the previous command for that context finishes. Of course, you can call commands asynchronously though by using unique ids.
For client requests type
can be one of:
eval
- Evaluate the forms provided indata
.stdin
- Write the string provided indata
to*in*
.clear
- Clear the context forid
.fork
- Associate the context forid
with the id provided indata
.
For server responses type
can be one of:
result
- Evaluation completed with no errors. The results are provided indata
error
- There was an exception during evaluation. The error type and message are provided indata
.read-error
- There was an error while reading the forms. The error message is provided indata
.stdout
- The string indata
was printed to*out*
during evaluation.stderr
- The string indata
was printed to*err*
during evaluation.
- Ruby
- Clojure (coming soon)
- elisp (coming soon)
- Haskell (coming soon)
- Your favorite language (patches welcome...)
- Thanks to James Reeves for this suggestion. ↩