Design doc: JS + Tuplespace
Mike Stay
2018-10-11
This document is still very much a placeholder draft.
JS tuplespace Use Babel to introduce new syntax key <identifier>; translates to let <identifier> = new Key(); where class Key { constructor() { // use protobuf to get new internal id from CPRNG } combineWith(...keys) { // use protobufs to form [this.id, ...keys.map(_ => _.id)] } get r { // use protobuf to form bundle-{this.id} // How to return the proper key safely without // exposing the ability to forge names to users? // Delete constructor property on new instances? } get w { // use protobuf to form bundle+{this.id} } get o { // use protobuf to form bundle0{this.id} } bang(json, nonlinear) { // convert JSON to RÇON // produce into tuplespace } fork(pattern, closure, nonlinear) { // closure is only provided if serialization succeeds (see below) // consume from tuplespace } } <keyID>!(JSON with keys) translates to key.bang(JSON, false) <keyID>!!(JSON with keys) translates to key.bang(JSON, true) // Fork semantics. Primitives have built-in serialization. // Runtime error if free var is not serializable. // Matches go to microtask queue. // Patterns are JSON with keys and free vars. for(<pattern> <- <key>) fork { <statements> } translates to key.fork(pattern, closure, false) for(<pattern> <= <key>) fork { <statements> } translates to key.fork(pattern, closure, true) Closure is an AST for the statements and an environment map from free vars to their serialized values. Translated pattern is an AST?