Rename `actor` to `spawn` in syndicate.js

similarly for actor* and during actor
This commit is contained in:
Sam Caldwell 2017-02-16 14:38:56 -05:00
parent 9c1e9719ba
commit 1134ed0eff
19 changed files with 65 additions and 65 deletions

View File

@ -86,10 +86,10 @@ function buildCaseEvent(eventPattern, body) {
} }
var modifiedSourceActions = { var modifiedSourceActions = {
ActorStatement_noReact: function(_actorStar, _namedOpt, nameExpOpt, block) { ActorStatement_noReact: function(_spawnStar, _namedOpt, nameExpOpt, block) {
return buildActor(nameExpOpt, block, false); return buildActor(nameExpOpt, block, false);
}, },
ActorStatement_withReact: function(_actor, _namedOpt, nameExpOpt, block) { ActorStatement_withReact: function(_spawn, _namedOpt, nameExpOpt, block) {
return buildActor(nameExpOpt, block, true); return buildActor(nameExpOpt, block, true);
}, },
@ -197,7 +197,7 @@ var modifiedSourceActions = {
[], [],
'{}')) + '}'); '{}')) + '}');
}, },
ActorEndpointStatement_duringActor: function(_during, pattern, _actor, _named, nameExpOpt, block) ActorEndpointStatement_duringSpawn: function(_during, pattern, _spawn, _named, nameExpOpt, block)
{ {
var cachedAssertionVar = gensym('cachedAssertion'); var cachedAssertionVar = gensym('cachedAssertion');
var actorBlock = { var actorBlock = {

View File

@ -25,17 +25,17 @@ assertion type present(who);
assertion type rendered(who, isPresent); assertion type rendered(who, isPresent);
ground dataspace { ground dataspace {
actor { spawn {
assert user('one'); assert user('one');
assert present('one'); assert present('one');
} }
actor { spawn {
assert user('two'); assert user('two');
// assert present('two'); // assert present('two');
} }
actor { spawn {
during user($who) { during user($who) {
field this.isPresent = false; field this.isPresent = false;
on asserted present(who) { on asserted present(who) {
@ -50,7 +50,7 @@ ground dataspace {
} }
} }
actor { spawn {
during rendered($who, $isPresent) { during rendered($who, $isPresent) {
on start { console.log('+ render', who, isPresent); } on start { console.log('+ render', who, isPresent); }
on stop { console.log('- render', who, isPresent); } on stop { console.log('- render', who, isPresent); }

View File

@ -6,7 +6,7 @@ assertion type account(balance);
message type deposit(amount); message type deposit(amount);
ground dataspace { ground dataspace {
actor { spawn {
field this.balance = 0; field this.balance = 0;
assert account(this.balance); assert account(this.balance);
dataflow { dataflow {
@ -17,13 +17,13 @@ ground dataspace {
} }
} }
actor { spawn {
on asserted account($balance) { on asserted account($balance) {
console.log("Balance is now", balance); console.log("Balance is now", balance);
} }
} }
actor { spawn {
on start { on start {
console.log("Waiting for account."); console.log("Waiting for account.");
} }

View File

@ -19,7 +19,7 @@ var Dataspace = Syndicate.Dataspace;
assertion type foo(x, y); assertion type foo(x, y);
ground dataspace { ground dataspace {
actor { spawn {
field this.x = 123; field this.x = 123;
assert foo(this.x, 999); assert foo(this.x, 999);

View File

@ -22,7 +22,7 @@ ground dataspace {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// The file system actor // The file system actor
actor { spawn {
this.files = {}; this.files = {};
during Syndicate.observe(file($name, _)) { during Syndicate.observe(file($name, _)) {
on start { on start {
@ -44,7 +44,7 @@ ground dataspace {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// A simple demo client of the file system // A simple demo client of the file system
actor { spawn {
on asserted file("hello.txt", $content) { on asserted file("hello.txt", $content) {
console.log("hello.txt has content", JSON.stringify(content)); console.log("hello.txt has content", JSON.stringify(content));
} }
@ -54,14 +54,14 @@ ground dataspace {
} }
} }
actor { spawn {
stop on asserted Syndicate.observe(saveFile(_, _)) { stop on asserted Syndicate.observe(saveFile(_, _)) {
:: saveFile("hello.txt", "a"); :: saveFile("hello.txt", "a");
:: deleteFile("hello.txt"); :: deleteFile("hello.txt");
:: saveFile("hello.txt", "c"); :: saveFile("hello.txt", "c");
:: saveFile("hello.txt", "quit demo"); :: saveFile("hello.txt", "quit demo");
:: saveFile("hello.txt", "final contents"); :: saveFile("hello.txt", "final contents");
actor { spawn {
stop on asserted file("hello.txt", $content) { stop on asserted file("hello.txt", $content) {
console.log("second observer sees that hello.txt content is", console.log("second observer sees that hello.txt content is",
JSON.stringify(content)); JSON.stringify(content));

View File

@ -59,7 +59,7 @@ assertion type show();
assertion type view(str); assertion type view(str);
ground dataspace { ground dataspace {
actor { spawn {
field this.title = "first"; field this.title = "first";
assert todo(this.title); assert todo(this.title);
on message 3 { on message 3 {
@ -67,11 +67,11 @@ ground dataspace {
} }
} }
actor { spawn {
assert show(); assert show();
} }
actor { spawn {
field this.editing = false; field this.editing = false;
during todo($title) { during todo($title) {
@ -95,14 +95,14 @@ ground dataspace {
} }
} }
actor { spawn {
on start { :: 0; } on start { :: 0; }
stop on message 0 { stop on message 0 {
:: 1; :: 1;
} }
} }
actor { spawn {
field this.count = 0; field this.count = 0;
on retracted view($x) { console.log('VIEW--', x); } on retracted view($x) { console.log('VIEW--', x); }
on asserted view($x) { on asserted view($x) {

View File

@ -14,7 +14,7 @@ assertion type ready(what);
assertion type entry(key, val); assertion type entry(key, val);
ground dataspace { ground dataspace {
actor named 'listener' { spawn named 'listener' {
assert ready('listener'); assert ready('listener');
on asserted entry($key, _) { on asserted entry($key, _) {
console.log('key asserted', key); console.log('key asserted', key);
@ -28,7 +28,7 @@ ground dataspace {
} }
} }
actor named 'other-listener' { spawn named 'other-listener' {
assert ready('other-listener'); assert ready('other-listener');
during entry($key, _) { during entry($key, _) {
on start { console.log('(other-listener) key asserted', key); } on start { console.log('(other-listener) key asserted', key); }
@ -50,7 +50,7 @@ ground dataspace {
} }
} }
actor named 'driver' { spawn named 'driver' {
stop on asserted ready('listener') { stop on asserted ready('listener') {
react { react {
stop on asserted ready('other-listener') { stop on asserted ready('other-listener') {

View File

@ -18,8 +18,8 @@ Syndicate <: ES5 {
FunctionBodyBlock = "{" FunctionBody "}" // odd that this isn't in es5.ohm somewhere FunctionBodyBlock = "{" FunctionBody "}" // odd that this isn't in es5.ohm somewhere
ActorStatement ActorStatement
= actorStar (named Expression<withIn>)? FunctionBodyBlock -- noReact = spawnStar (named Expression<withIn>)? FunctionBodyBlock -- noReact
| actor (named Expression<withIn>)? FunctionBodyBlock -- withReact | spawn (named Expression<withIn>)? FunctionBodyBlock -- withReact
DataspaceStatement DataspaceStatement
= ground dataspace identifier? FunctionBodyBlock -- ground = ground dataspace identifier? FunctionBodyBlock -- ground
@ -38,7 +38,7 @@ Syndicate <: ES5 {
| stop on FacetTransitionEventPattern #(sc) -- stopOnNoCont | stop on FacetTransitionEventPattern #(sc) -- stopOnNoCont
| dataflow FunctionBodyBlock -- dataflow | dataflow FunctionBodyBlock -- dataflow
| during FacetPattern FunctionBodyBlock -- during | during FacetPattern FunctionBodyBlock -- during
| during FacetPattern actor (named Expression<withIn>)? FunctionBodyBlock -- duringActor | during FacetPattern spawn (named Expression<withIn>)? FunctionBodyBlock -- duringSpawn
AssertWhenClause = when "(" Expression<withIn> ")" AssertWhenClause = when "(" Expression<withIn> ")"
@ -69,8 +69,8 @@ Syndicate <: ES5 {
// we don't want to make them unavailable to programs as // we don't want to make them unavailable to programs as
// identifiers. // identifiers.
actorStar = "actor*" ~identifierPart spawnStar = "spawn*" ~identifierPart
actor = "actor" ~("*" | identifierPart) spawn = "spawn" ~("*" | identifierPart)
assert = "assert" ~identifierPart assert = "assert" ~identifierPart
asserted = "asserted" ~identifierPart asserted = "asserted" ~identifierPart
assertion = "assertion" ~identifierPart assertion = "assertion" ~identifierPart

View File

@ -1,7 +1,7 @@
ground dataspace { ground dataspace {
Syndicate.UI.spawnUIDriver(); Syndicate.UI.spawnUIDriver();
actor { spawn {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
field this.counter = 0; field this.counter = 0;
assert ui.html('#button-label', '' + this.counter); assert ui.html('#button-label', '' + this.counter);

View File

@ -15,7 +15,7 @@ function spawnChatApp() {
$("#nym_form").submit(function (e) { e.preventDefault(); return false; }); $("#nym_form").submit(function (e) { e.preventDefault(); return false; });
if (!($("#nym").val())) { $("#nym").val("nym" + Math.floor(Math.random() * 65536)); } if (!($("#nym").val())) { $("#nym").val("nym" + Math.floor(Math.random() * 65536)); }
actor { spawn {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
field this.nym; field this.nym;
field this.status; field this.status;
@ -82,8 +82,8 @@ function outputUtterance(who, what) {
assertion type inputValue(selector, value); assertion type inputValue(selector, value);
function spawnInputChangeMonitor() { function spawnInputChangeMonitor() {
actor { spawn {
during Syndicate.observe(inputValue($selector, _)) actor { during Syndicate.observe(inputValue($selector, _)) spawn {
field this.value = $(selector).val(); field this.value = $(selector).val();
assert inputValue(selector, this.value); assert inputValue(selector, this.value);
on message Syndicate.UI.globalEvent(selector, 'change', $e) { on message Syndicate.UI.globalEvent(selector, 'change', $e) {

View File

@ -9,7 +9,7 @@ assertion type componentPresent(name);
// TV // TV
function spawnTV() { function spawnTV() {
actor { spawn {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
during tvAlert($text) { during tvAlert($text) {
assert ui.context(text).html('#tv', Mustache.render($('#alert_template').html(), { text: text })); assert ui.context(text).html('#tv', Mustache.render($('#alert_template').html(), { text: text }));
@ -21,7 +21,7 @@ function spawnTV() {
// Remote control and listener // Remote control and listener
function spawnRemoteControl() { function spawnRemoteControl() {
actor { spawn {
assert componentPresent('remote control'); assert componentPresent('remote control');
on message Syndicate.UI.globalEvent('#remote-control', 'click', _) { on message Syndicate.UI.globalEvent('#remote-control', 'click', _) {
:: remoteClick(); :: remoteClick();
@ -30,7 +30,7 @@ function spawnRemoteControl() {
} }
function spawnRemoteListener() { function spawnRemoteListener() {
actor { spawn {
this.stoveIsOn = false; this.stoveIsOn = false;
// In principle, we should start up in "power undefined" state and // In principle, we should start up in "power undefined" state and
// count clicks we get in that state; when we then learn the real // count clicks we get in that state; when we then learn the real
@ -53,7 +53,7 @@ function spawnRemoteListener() {
// Stove switch and power draw monitor // Stove switch and power draw monitor
function spawnStoveSwitch() { function spawnStoveSwitch() {
actor { spawn {
field this.powerOn = false; field this.powerOn = false;
this.ui = new Syndicate.UI.Anchor(); this.ui = new Syndicate.UI.Anchor();
@ -77,7 +77,7 @@ function spawnStoveSwitch() {
} }
function spawnPowerDrawMonitor() { function spawnPowerDrawMonitor() {
actor { spawn {
field this.watts = 0; field this.watts = 0;
this.ui = new Syndicate.UI.Anchor(); this.ui = new Syndicate.UI.Anchor();
@ -99,7 +99,7 @@ function spawnPowerDrawMonitor() {
// Timeout listener // Timeout listener
function spawnTimeoutListener() { function spawnTimeoutListener() {
actor { spawn {
during powerDraw($watts) { during powerDraw($watts) {
on start { on start {
if (watts > 0) { if (watts > 0) {
@ -119,7 +119,7 @@ function spawnTimeoutListener() {
} }
// function spawnTimeoutListener() { // function spawnTimeoutListener() {
// actor { // spawn {
// on asserted powerDraw($watts) { // on asserted powerDraw($watts) {
// if (watts > 0) { // if (watts > 0) {
// var powerOnTime = Date.now(); // var powerOnTime = Date.now();
@ -135,7 +135,7 @@ function spawnTimeoutListener() {
// } // }
// function spawnTimeoutListener() { // function spawnTimeoutListener() {
// actor { // spawn {
// this.mostRecentTime = 0; // this.mostRecentTime = 0;
// this.powerOnTime = null; // this.powerOnTime = null;
// on asserted powerDraw($watts) { // on asserted powerDraw($watts) {
@ -153,7 +153,7 @@ function spawnTimeoutListener() {
// Failure monitor // Failure monitor
function spawnFailureMonitor() { function spawnFailureMonitor() {
actor { spawn {
on retracted componentPresent($who) { on retracted componentPresent($who) {
react { react {
assert tvAlert('FAILURE: ' + who); assert tvAlert('FAILURE: ' + who);
@ -167,7 +167,7 @@ function spawnFailureMonitor() {
// Chaos Monkey // Chaos Monkey
function spawnChaosMonkey() { function spawnChaosMonkey() {
actor* { spawn* {
monitorComponent('power draw monitor', monitorComponent('power draw monitor',
'#spawn-power-draw-monitor', '#spawn-power-draw-monitor',
'#kill-power-draw-monitor', '#kill-power-draw-monitor',

View File

@ -10,7 +10,7 @@ ground dataspace G {
Syndicate.Timer.spawnTimerDriver(); Syndicate.Timer.spawnTimerDriver();
Syndicate.Broker.spawnBrokerClientDriver(); Syndicate.Broker.spawnBrokerClientDriver();
actor { spawn {
var id = Syndicate.RandomID.randomId(4, true); var id = Syndicate.RandomID.randomId(4, true);
var email_element = document.getElementById('my_email'); var email_element = document.getElementById('my_email');

View File

@ -9,7 +9,7 @@ ground dataspace G {
Syndicate.Timer.spawnTimerDriver(); Syndicate.Timer.spawnTimerDriver();
Syndicate.Broker.spawnBrokerClientDriver(); Syndicate.Broker.spawnBrokerClientDriver();
actor { spawn {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
var color = tinycolor('hsl ' + (Math.random() * 360 | 0) + ' 100% 50%').toHexString(); var color = tinycolor('hsl ' + (Math.random() * 360 | 0) + ' 100% 50%').toHexString();
var x = 0; var x = 0;

View File

@ -3,7 +3,7 @@ assertion type beep(counter);
ground dataspace { ground dataspace {
console.log('starting ground boot'); console.log('starting ground boot');
actor { spawn {
stop on asserted Syndicate.observe(beep(_)) { stop on asserted Syndicate.observe(beep(_)) {
field this.counter = 0; field this.counter = 0;
react { react {
@ -18,7 +18,7 @@ ground dataspace {
} }
} }
actor { spawn {
on message beep($counter) { on message beep($counter) {
console.log("beep!", counter); console.log("beep!", counter);
} }

View File

@ -2,7 +2,7 @@ ground dataspace G {
Syndicate.UI.spawnUIDriver(); Syndicate.UI.spawnUIDriver();
Syndicate.Timer.spawnTimerDriver(); Syndicate.Timer.spawnTimerDriver();
actor { spawn {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
field this.angle; field this.angle;
field this.handX; field this.handX;

View File

@ -2,7 +2,7 @@ assertion type person(id, firstName, lastName, address, age);
message type setSortColumn(number); message type setSortColumn(number);
function newRow(id, firstName, lastName, address, age) { function newRow(id, firstName, lastName, address, age) {
actor named ('model' + id) { spawn named ('model' + id) {
assert person(id, firstName, lastName, address, age); assert person(id, firstName, lastName, address, age);
} }
} }
@ -16,7 +16,7 @@ function spawnModel() {
} }
function spawnView() { function spawnView() {
actor named 'view' { spawn named 'view' {
var ui = new Syndicate.UI.Anchor(); var ui = new Syndicate.UI.Anchor();
field this.orderColumn = 2; field this.orderColumn = 2;
@ -37,7 +37,7 @@ function spawnView() {
} }
function spawnController() { function spawnController() {
actor named 'controller' { spawn named 'controller' {
on message Syndicate.UI.globalEvent('table#the-table th', 'click', $e) { on message Syndicate.UI.globalEvent('table#the-table th', 'click', $e) {
:: setSortColumn(JSON.parse(e.target.dataset.column)); :: setSortColumn(JSON.parse(e.target.dataset.column));
} }

View File

@ -25,7 +25,7 @@ function piece(text, pos, lo, hi, cls) {
} }
function spawnGui() { function spawnGui() {
actor { spawn {
field this.text = ''; field this.text = '';
field this.pos = 0; field this.pos = 0;
field this.highlightState = false; field this.highlightState = false;
@ -78,7 +78,7 @@ function spawnGui() {
// Textfield Model // Textfield Model
function spawnModel() { function spawnModel() {
actor { spawn {
field this.fieldValue = "initial"; field this.fieldValue = "initial";
field this.cursorPos = this.fieldValue.length; /* positions address gaps between characters */ field this.cursorPos = this.fieldValue.length; /* positions address gaps between characters */
@ -119,7 +119,7 @@ function spawnModel() {
// Search engine // Search engine
function spawnSearch() { function spawnSearch() {
actor { spawn {
field this.searchtext = document.getElementById("searchBox").value; field this.searchtext = document.getElementById("searchBox").value;
field this.fieldValue = ""; field this.fieldValue = "";
field this.highlight = false; field this.highlight = false;

View File

@ -24,7 +24,7 @@ assertion type show(completed);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
function todoListItemModel(initialId, initialTitle, initialCompleted) { function todoListItemModel(initialId, initialTitle, initialCompleted) {
actor { spawn {
field this.id = initialId; field this.id = initialId;
field this.title = initialTitle; field this.title = initialTitle;
field this.completed = initialCompleted; field this.completed = initialCompleted;
@ -54,7 +54,7 @@ function getTemplate(id) {
} }
function todoListItemView(id) { function todoListItemView(id) {
actor { spawn {
stop on retracted todo(id, _, _); stop on retracted todo(id, _, _);
this.ui = new Syndicate.UI.Anchor(); this.ui = new Syndicate.UI.Anchor();
@ -109,7 +109,7 @@ function todoListItemView(id) {
ground dataspace G { ground dataspace G {
Syndicate.UI.spawnUIDriver(); Syndicate.UI.spawnUIDriver();
actor { spawn {
on message Syndicate.UI.globalEvent('.new-todo', 'change', $e) { on message Syndicate.UI.globalEvent('.new-todo', 'change', $e) {
var newTitle = e.target.value.trim(); var newTitle = e.target.value.trim();
if (newTitle) :: createTodo(newTitle); if (newTitle) :: createTodo(newTitle);
@ -117,7 +117,7 @@ ground dataspace G {
} }
} }
actor { spawn {
this.ui = new Syndicate.UI.Anchor(); this.ui = new Syndicate.UI.Anchor();
during activeTodoCount($count) { during activeTodoCount($count) {
@ -150,7 +150,7 @@ ground dataspace G {
} }
} }
actor { spawn {
field this.completedCount = 0; field this.completedCount = 0;
field this.activeCount = 0; field this.activeCount = 0;
on asserted todo($id, _, $c) { if (c) this.completedCount++; else this.activeCount++; } on asserted todo($id, _, $c) { if (c) this.completedCount++; else this.activeCount++; }
@ -161,7 +161,7 @@ ground dataspace G {
assert allCompleted() when (this.completedCount > 0 && this.activeCount === 0); assert allCompleted() when (this.completedCount > 0 && this.activeCount === 0);
} }
actor { spawn {
during Syndicate.UI.locationHash($hash) { during Syndicate.UI.locationHash($hash) {
assert Syndicate.UI.uiAttribute('ul.filters > li > a[href="#'+hash+'"]', assert Syndicate.UI.uiAttribute('ul.filters > li > a[href="#'+hash+'"]',
'class', 'selected'); 'class', 'selected');
@ -179,7 +179,7 @@ ground dataspace G {
} }
} }
actor { spawn {
var db; var db;
if ('todos-syndicate' in localStorage) { if ('todos-syndicate' in localStorage) {

View File

@ -76,7 +76,7 @@ assertion type splitProposal(title, price, contribution, accepted);
/// core library. /// core library.
/// ///
function whileRelevantAssert(P) { function whileRelevantAssert(P) {
actor { spawn {
assert P; assert P;
stop on retracted Syndicate.observe(P); stop on retracted Syndicate.observe(P);
} }
@ -85,7 +85,7 @@ function whileRelevantAssert(P) {
/// ### Implementation: SELLER /// ### Implementation: SELLER
function seller() { function seller() {
actor { spawn {
/// We give our actor two state variables: a dictionary recording our /// We give our actor two state variables: a dictionary recording our
/// inventory of books (mapping title to price), and a counter /// inventory of books (mapping title to price), and a counter
@ -150,7 +150,7 @@ function seller() {
/// ### Implementation: SPLIT-PROPOSER and book-quote-requestor /// ### Implementation: SPLIT-PROPOSER and book-quote-requestor
function buyerA() { function buyerA() {
actor* { spawn* {
var self = this; var self = this;
/// Our actor remembers which books remain on its shopping list, and /// Our actor remembers which books remain on its shopping list, and
@ -238,7 +238,7 @@ function buyerA() {
/// ### Implementation: SPLIT-DISPOSER and BUYER /// ### Implementation: SPLIT-DISPOSER and BUYER
function buyerB() { function buyerB() {
actor { spawn {
/// This actor maintains a record of the amount of money it has left /// This actor maintains a record of the amount of money it has left
/// to spend. /// to spend.
@ -276,7 +276,7 @@ function buyerB() {
remainingFunds+" remaining funds"); remainingFunds+" remaining funds");
this.funds = remainingFunds; this.funds = remainingFunds;
actor { spawn {
/// While waiting for order confirmation, take the opportunity to /// While waiting for order confirmation, take the opportunity to
/// signal to our SPLIT-PROPOSER that we accepted their proposal. /// signal to our SPLIT-PROPOSER that we accepted their proposal.