Rename `actor` to `spawn` in syndicate.js
similarly for actor* and during actor
This commit is contained in:
parent
9c1e9719ba
commit
1134ed0eff
|
@ -86,10 +86,10 @@ function buildCaseEvent(eventPattern, body) {
|
|||
}
|
||||
|
||||
var modifiedSourceActions = {
|
||||
ActorStatement_noReact: function(_actorStar, _namedOpt, nameExpOpt, block) {
|
||||
ActorStatement_noReact: function(_spawnStar, _namedOpt, nameExpOpt, block) {
|
||||
return buildActor(nameExpOpt, block, false);
|
||||
},
|
||||
ActorStatement_withReact: function(_actor, _namedOpt, nameExpOpt, block) {
|
||||
ActorStatement_withReact: function(_spawn, _namedOpt, nameExpOpt, block) {
|
||||
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 actorBlock = {
|
||||
|
|
|
@ -25,17 +25,17 @@ assertion type present(who);
|
|||
assertion type rendered(who, isPresent);
|
||||
|
||||
ground dataspace {
|
||||
actor {
|
||||
spawn {
|
||||
assert user('one');
|
||||
assert present('one');
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
assert user('two');
|
||||
// assert present('two');
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
during user($who) {
|
||||
field this.isPresent = false;
|
||||
on asserted present(who) {
|
||||
|
@ -50,7 +50,7 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
during rendered($who, $isPresent) {
|
||||
on start { console.log('+ render', who, isPresent); }
|
||||
on stop { console.log('- render', who, isPresent); }
|
||||
|
|
|
@ -6,7 +6,7 @@ assertion type account(balance);
|
|||
message type deposit(amount);
|
||||
|
||||
ground dataspace {
|
||||
actor {
|
||||
spawn {
|
||||
field this.balance = 0;
|
||||
assert account(this.balance);
|
||||
dataflow {
|
||||
|
@ -17,13 +17,13 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on asserted account($balance) {
|
||||
console.log("Balance is now", balance);
|
||||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on start {
|
||||
console.log("Waiting for account.");
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ var Dataspace = Syndicate.Dataspace;
|
|||
assertion type foo(x, y);
|
||||
|
||||
ground dataspace {
|
||||
actor {
|
||||
spawn {
|
||||
field this.x = 123;
|
||||
|
||||
assert foo(this.x, 999);
|
||||
|
|
|
@ -22,7 +22,7 @@ ground dataspace {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// The file system actor
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
this.files = {};
|
||||
during Syndicate.observe(file($name, _)) {
|
||||
on start {
|
||||
|
@ -44,7 +44,7 @@ ground dataspace {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// A simple demo client of the file system
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on asserted file("hello.txt", $content) {
|
||||
console.log("hello.txt has content", JSON.stringify(content));
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
stop on asserted Syndicate.observe(saveFile(_, _)) {
|
||||
:: saveFile("hello.txt", "a");
|
||||
:: deleteFile("hello.txt");
|
||||
:: saveFile("hello.txt", "c");
|
||||
:: saveFile("hello.txt", "quit demo");
|
||||
:: saveFile("hello.txt", "final contents");
|
||||
actor {
|
||||
spawn {
|
||||
stop on asserted file("hello.txt", $content) {
|
||||
console.log("second observer sees that hello.txt content is",
|
||||
JSON.stringify(content));
|
||||
|
|
|
@ -59,7 +59,7 @@ assertion type show();
|
|||
assertion type view(str);
|
||||
|
||||
ground dataspace {
|
||||
actor {
|
||||
spawn {
|
||||
field this.title = "first";
|
||||
assert todo(this.title);
|
||||
on message 3 {
|
||||
|
@ -67,11 +67,11 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
assert show();
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
field this.editing = false;
|
||||
|
||||
during todo($title) {
|
||||
|
@ -95,14 +95,14 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on start { :: 0; }
|
||||
stop on message 0 {
|
||||
:: 1;
|
||||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
field this.count = 0;
|
||||
on retracted view($x) { console.log('VIEW--', x); }
|
||||
on asserted view($x) {
|
||||
|
|
|
@ -14,7 +14,7 @@ assertion type ready(what);
|
|||
assertion type entry(key, val);
|
||||
|
||||
ground dataspace {
|
||||
actor named 'listener' {
|
||||
spawn named 'listener' {
|
||||
assert ready('listener');
|
||||
on asserted entry($key, _) {
|
||||
console.log('key asserted', key);
|
||||
|
@ -28,7 +28,7 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor named 'other-listener' {
|
||||
spawn named 'other-listener' {
|
||||
assert ready('other-listener');
|
||||
during entry($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') {
|
||||
react {
|
||||
stop on asserted ready('other-listener') {
|
||||
|
|
|
@ -18,8 +18,8 @@ Syndicate <: ES5 {
|
|||
FunctionBodyBlock = "{" FunctionBody "}" // odd that this isn't in es5.ohm somewhere
|
||||
|
||||
ActorStatement
|
||||
= actorStar (named Expression<withIn>)? FunctionBodyBlock -- noReact
|
||||
| actor (named Expression<withIn>)? FunctionBodyBlock -- withReact
|
||||
= spawnStar (named Expression<withIn>)? FunctionBodyBlock -- noReact
|
||||
| spawn (named Expression<withIn>)? FunctionBodyBlock -- withReact
|
||||
|
||||
DataspaceStatement
|
||||
= ground dataspace identifier? FunctionBodyBlock -- ground
|
||||
|
@ -38,7 +38,7 @@ Syndicate <: ES5 {
|
|||
| stop on FacetTransitionEventPattern #(sc) -- stopOnNoCont
|
||||
| dataflow FunctionBodyBlock -- dataflow
|
||||
| during FacetPattern FunctionBodyBlock -- during
|
||||
| during FacetPattern actor (named Expression<withIn>)? FunctionBodyBlock -- duringActor
|
||||
| during FacetPattern spawn (named Expression<withIn>)? FunctionBodyBlock -- duringSpawn
|
||||
|
||||
AssertWhenClause = when "(" Expression<withIn> ")"
|
||||
|
||||
|
@ -69,8 +69,8 @@ Syndicate <: ES5 {
|
|||
// we don't want to make them unavailable to programs as
|
||||
// identifiers.
|
||||
|
||||
actorStar = "actor*" ~identifierPart
|
||||
actor = "actor" ~("*" | identifierPart)
|
||||
spawnStar = "spawn*" ~identifierPart
|
||||
spawn = "spawn" ~("*" | identifierPart)
|
||||
assert = "assert" ~identifierPart
|
||||
asserted = "asserted" ~identifierPart
|
||||
assertion = "assertion" ~identifierPart
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ground dataspace {
|
||||
Syndicate.UI.spawnUIDriver();
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
field this.counter = 0;
|
||||
assert ui.html('#button-label', '' + this.counter);
|
||||
|
|
|
@ -15,7 +15,7 @@ function spawnChatApp() {
|
|||
$("#nym_form").submit(function (e) { e.preventDefault(); return false; });
|
||||
if (!($("#nym").val())) { $("#nym").val("nym" + Math.floor(Math.random() * 65536)); }
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
field this.nym;
|
||||
field this.status;
|
||||
|
@ -82,8 +82,8 @@ function outputUtterance(who, what) {
|
|||
assertion type inputValue(selector, value);
|
||||
|
||||
function spawnInputChangeMonitor() {
|
||||
actor {
|
||||
during Syndicate.observe(inputValue($selector, _)) actor {
|
||||
spawn {
|
||||
during Syndicate.observe(inputValue($selector, _)) spawn {
|
||||
field this.value = $(selector).val();
|
||||
assert inputValue(selector, this.value);
|
||||
on message Syndicate.UI.globalEvent(selector, 'change', $e) {
|
||||
|
|
|
@ -9,7 +9,7 @@ assertion type componentPresent(name);
|
|||
// TV
|
||||
|
||||
function spawnTV() {
|
||||
actor {
|
||||
spawn {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
during tvAlert($text) {
|
||||
assert ui.context(text).html('#tv', Mustache.render($('#alert_template').html(), { text: text }));
|
||||
|
@ -21,7 +21,7 @@ function spawnTV() {
|
|||
// Remote control and listener
|
||||
|
||||
function spawnRemoteControl() {
|
||||
actor {
|
||||
spawn {
|
||||
assert componentPresent('remote control');
|
||||
on message Syndicate.UI.globalEvent('#remote-control', 'click', _) {
|
||||
:: remoteClick();
|
||||
|
@ -30,7 +30,7 @@ function spawnRemoteControl() {
|
|||
}
|
||||
|
||||
function spawnRemoteListener() {
|
||||
actor {
|
||||
spawn {
|
||||
this.stoveIsOn = false;
|
||||
// In principle, we should start up in "power undefined" state and
|
||||
// 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
|
||||
|
||||
function spawnStoveSwitch() {
|
||||
actor {
|
||||
spawn {
|
||||
field this.powerOn = false;
|
||||
this.ui = new Syndicate.UI.Anchor();
|
||||
|
||||
|
@ -77,7 +77,7 @@ function spawnStoveSwitch() {
|
|||
}
|
||||
|
||||
function spawnPowerDrawMonitor() {
|
||||
actor {
|
||||
spawn {
|
||||
field this.watts = 0;
|
||||
this.ui = new Syndicate.UI.Anchor();
|
||||
|
||||
|
@ -99,7 +99,7 @@ function spawnPowerDrawMonitor() {
|
|||
// Timeout listener
|
||||
|
||||
function spawnTimeoutListener() {
|
||||
actor {
|
||||
spawn {
|
||||
during powerDraw($watts) {
|
||||
on start {
|
||||
if (watts > 0) {
|
||||
|
@ -119,7 +119,7 @@ function spawnTimeoutListener() {
|
|||
}
|
||||
|
||||
// function spawnTimeoutListener() {
|
||||
// actor {
|
||||
// spawn {
|
||||
// on asserted powerDraw($watts) {
|
||||
// if (watts > 0) {
|
||||
// var powerOnTime = Date.now();
|
||||
|
@ -135,7 +135,7 @@ function spawnTimeoutListener() {
|
|||
// }
|
||||
|
||||
// function spawnTimeoutListener() {
|
||||
// actor {
|
||||
// spawn {
|
||||
// this.mostRecentTime = 0;
|
||||
// this.powerOnTime = null;
|
||||
// on asserted powerDraw($watts) {
|
||||
|
@ -153,7 +153,7 @@ function spawnTimeoutListener() {
|
|||
// Failure monitor
|
||||
|
||||
function spawnFailureMonitor() {
|
||||
actor {
|
||||
spawn {
|
||||
on retracted componentPresent($who) {
|
||||
react {
|
||||
assert tvAlert('FAILURE: ' + who);
|
||||
|
@ -167,7 +167,7 @@ function spawnFailureMonitor() {
|
|||
// Chaos Monkey
|
||||
|
||||
function spawnChaosMonkey() {
|
||||
actor* {
|
||||
spawn* {
|
||||
monitorComponent('power draw monitor',
|
||||
'#spawn-power-draw-monitor',
|
||||
'#kill-power-draw-monitor',
|
||||
|
|
|
@ -10,7 +10,7 @@ ground dataspace G {
|
|||
Syndicate.Timer.spawnTimerDriver();
|
||||
Syndicate.Broker.spawnBrokerClientDriver();
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var id = Syndicate.RandomID.randomId(4, true);
|
||||
|
||||
var email_element = document.getElementById('my_email');
|
||||
|
|
|
@ -9,7 +9,7 @@ ground dataspace G {
|
|||
Syndicate.Timer.spawnTimerDriver();
|
||||
Syndicate.Broker.spawnBrokerClientDriver();
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
var color = tinycolor('hsl ' + (Math.random() * 360 | 0) + ' 100% 50%').toHexString();
|
||||
var x = 0;
|
||||
|
|
|
@ -3,7 +3,7 @@ assertion type beep(counter);
|
|||
ground dataspace {
|
||||
console.log('starting ground boot');
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
stop on asserted Syndicate.observe(beep(_)) {
|
||||
field this.counter = 0;
|
||||
react {
|
||||
|
@ -18,7 +18,7 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on message beep($counter) {
|
||||
console.log("beep!", counter);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ ground dataspace G {
|
|||
Syndicate.UI.spawnUIDriver();
|
||||
Syndicate.Timer.spawnTimerDriver();
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
field this.angle;
|
||||
field this.handX;
|
||||
|
|
|
@ -2,7 +2,7 @@ assertion type person(id, firstName, lastName, address, age);
|
|||
message type setSortColumn(number);
|
||||
|
||||
function newRow(id, firstName, lastName, address, age) {
|
||||
actor named ('model' + id) {
|
||||
spawn named ('model' + id) {
|
||||
assert person(id, firstName, lastName, address, age);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ function spawnModel() {
|
|||
}
|
||||
|
||||
function spawnView() {
|
||||
actor named 'view' {
|
||||
spawn named 'view' {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
field this.orderColumn = 2;
|
||||
|
||||
|
@ -37,7 +37,7 @@ function spawnView() {
|
|||
}
|
||||
|
||||
function spawnController() {
|
||||
actor named 'controller' {
|
||||
spawn named 'controller' {
|
||||
on message Syndicate.UI.globalEvent('table#the-table th', 'click', $e) {
|
||||
:: setSortColumn(JSON.parse(e.target.dataset.column));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ function piece(text, pos, lo, hi, cls) {
|
|||
}
|
||||
|
||||
function spawnGui() {
|
||||
actor {
|
||||
spawn {
|
||||
field this.text = '';
|
||||
field this.pos = 0;
|
||||
field this.highlightState = false;
|
||||
|
@ -78,7 +78,7 @@ function spawnGui() {
|
|||
// Textfield Model
|
||||
|
||||
function spawnModel() {
|
||||
actor {
|
||||
spawn {
|
||||
field this.fieldValue = "initial";
|
||||
field this.cursorPos = this.fieldValue.length; /* positions address gaps between characters */
|
||||
|
||||
|
@ -119,7 +119,7 @@ function spawnModel() {
|
|||
// Search engine
|
||||
|
||||
function spawnSearch() {
|
||||
actor {
|
||||
spawn {
|
||||
field this.searchtext = document.getElementById("searchBox").value;
|
||||
field this.fieldValue = "";
|
||||
field this.highlight = false;
|
||||
|
|
|
@ -24,7 +24,7 @@ assertion type show(completed);
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function todoListItemModel(initialId, initialTitle, initialCompleted) {
|
||||
actor {
|
||||
spawn {
|
||||
field this.id = initialId;
|
||||
field this.title = initialTitle;
|
||||
field this.completed = initialCompleted;
|
||||
|
@ -54,7 +54,7 @@ function getTemplate(id) {
|
|||
}
|
||||
|
||||
function todoListItemView(id) {
|
||||
actor {
|
||||
spawn {
|
||||
stop on retracted todo(id, _, _);
|
||||
|
||||
this.ui = new Syndicate.UI.Anchor();
|
||||
|
@ -109,7 +109,7 @@ function todoListItemView(id) {
|
|||
ground dataspace G {
|
||||
Syndicate.UI.spawnUIDriver();
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
on message Syndicate.UI.globalEvent('.new-todo', 'change', $e) {
|
||||
var newTitle = e.target.value.trim();
|
||||
if (newTitle) :: createTodo(newTitle);
|
||||
|
@ -117,7 +117,7 @@ ground dataspace G {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
this.ui = new Syndicate.UI.Anchor();
|
||||
|
||||
during activeTodoCount($count) {
|
||||
|
@ -150,7 +150,7 @@ ground dataspace G {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
field this.completedCount = 0;
|
||||
field this.activeCount = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
during Syndicate.UI.locationHash($hash) {
|
||||
assert Syndicate.UI.uiAttribute('ul.filters > li > a[href="#'+hash+'"]',
|
||||
'class', 'selected');
|
||||
|
@ -179,7 +179,7 @@ ground dataspace G {
|
|||
}
|
||||
}
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
var db;
|
||||
|
||||
if ('todos-syndicate' in localStorage) {
|
||||
|
|
|
@ -76,7 +76,7 @@ assertion type splitProposal(title, price, contribution, accepted);
|
|||
/// core library.
|
||||
///
|
||||
function whileRelevantAssert(P) {
|
||||
actor {
|
||||
spawn {
|
||||
assert P;
|
||||
stop on retracted Syndicate.observe(P);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ function whileRelevantAssert(P) {
|
|||
/// ### Implementation: SELLER
|
||||
|
||||
function seller() {
|
||||
actor {
|
||||
spawn {
|
||||
|
||||
/// We give our actor two state variables: a dictionary recording our
|
||||
/// inventory of books (mapping title to price), and a counter
|
||||
|
@ -150,7 +150,7 @@ function seller() {
|
|||
/// ### Implementation: SPLIT-PROPOSER and book-quote-requestor
|
||||
|
||||
function buyerA() {
|
||||
actor* {
|
||||
spawn* {
|
||||
var self = this;
|
||||
|
||||
/// Our actor remembers which books remain on its shopping list, and
|
||||
|
@ -238,7 +238,7 @@ function buyerA() {
|
|||
/// ### Implementation: SPLIT-DISPOSER and BUYER
|
||||
|
||||
function buyerB() {
|
||||
actor {
|
||||
spawn {
|
||||
|
||||
/// This actor maintains a record of the amount of money it has left
|
||||
/// to spend.
|
||||
|
@ -276,7 +276,7 @@ function buyerB() {
|
|||
remainingFunds+" remaining funds");
|
||||
this.funds = remainingFunds;
|
||||
|
||||
actor {
|
||||
spawn {
|
||||
|
||||
/// While waiting for order confirmation, take the opportunity to
|
||||
/// signal to our SPLIT-PROPOSER that we accepted their proposal.
|
||||
|
|
Loading…
Reference in New Issue