diff --git a/js/compiler/compiler.js b/js/compiler/compiler.js index 5eaa12f..01ec599 100644 --- a/js/compiler/compiler.js +++ b/js/compiler/compiler.js @@ -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 = { diff --git a/js/compiler/demo-bad-this.js b/js/compiler/demo-bad-this.js index 8a5990c..a83d6a8 100644 --- a/js/compiler/demo-bad-this.js +++ b/js/compiler/demo-bad-this.js @@ -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); } diff --git a/js/compiler/demo-bankaccount.js b/js/compiler/demo-bankaccount.js index 3e71079..c803ca1 100644 --- a/js/compiler/demo-bankaccount.js +++ b/js/compiler/demo-bankaccount.js @@ -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."); } diff --git a/js/compiler/demo-during-criterion-snapshotting.js b/js/compiler/demo-during-criterion-snapshotting.js index 39cae50..3f98697 100644 --- a/js/compiler/demo-during-criterion-snapshotting.js +++ b/js/compiler/demo-during-criterion-snapshotting.js @@ -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); diff --git a/js/compiler/demo-filesystem.js b/js/compiler/demo-filesystem.js index 94103f0..e1627de 100644 --- a/js/compiler/demo-filesystem.js +++ b/js/compiler/demo-filesystem.js @@ -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)); diff --git a/js/compiler/demo-nested-during.js b/js/compiler/demo-nested-during.js index 55e4799..ccbe5ee 100644 --- a/js/compiler/demo-nested-during.js +++ b/js/compiler/demo-nested-during.js @@ -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) { diff --git a/js/compiler/demo-proper-interest-tracking.js b/js/compiler/demo-proper-interest-tracking.js index 03fb922..a44dd98 100644 --- a/js/compiler/demo-proper-interest-tracking.js +++ b/js/compiler/demo-proper-interest-tracking.js @@ -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') { diff --git a/js/compiler/syndicate.ohm b/js/compiler/syndicate.ohm index be3320d..6c3e569 100644 --- a/js/compiler/syndicate.ohm +++ b/js/compiler/syndicate.ohm @@ -18,8 +18,8 @@ Syndicate <: ES5 { FunctionBodyBlock = "{" FunctionBody "}" // odd that this isn't in es5.ohm somewhere ActorStatement - = actorStar (named Expression)? FunctionBodyBlock -- noReact - | actor (named Expression)? FunctionBodyBlock -- withReact + = spawnStar (named Expression)? FunctionBodyBlock -- noReact + | spawn (named Expression)? 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)? FunctionBodyBlock -- duringActor + | during FacetPattern spawn (named Expression)? FunctionBodyBlock -- duringSpawn AssertWhenClause = when "(" Expression ")" @@ -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 diff --git a/js/examples/button/index.js b/js/examples/button/index.js index 5e90a6d..362d101 100644 --- a/js/examples/button/index.js +++ b/js/examples/button/index.js @@ -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); diff --git a/js/examples/chat/index.js b/js/examples/chat/index.js index 8546d36..d470d2b 100644 --- a/js/examples/chat/index.js +++ b/js/examples/chat/index.js @@ -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) { diff --git a/js/examples/iot/index.js b/js/examples/iot/index.js index 1ba5d79..27f8620 100644 --- a/js/examples/iot/index.js +++ b/js/examples/iot/index.js @@ -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', diff --git a/js/examples/location/index.js b/js/examples/location/index.js index ec9b60e..76fd28c 100644 --- a/js/examples/location/index.js +++ b/js/examples/location/index.js @@ -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'); diff --git a/js/examples/motion/index.js b/js/examples/motion/index.js index 1b488d9..598a8f8 100644 --- a/js/examples/motion/index.js +++ b/js/examples/motion/index.js @@ -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; diff --git a/js/examples/smoketest-dsl/index.js b/js/examples/smoketest-dsl/index.js index ad74a34..13178dd 100644 --- a/js/examples/smoketest-dsl/index.js +++ b/js/examples/smoketest-dsl/index.js @@ -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); } diff --git a/js/examples/svg/index.js b/js/examples/svg/index.js index d50c738..527367c 100644 --- a/js/examples/svg/index.js +++ b/js/examples/svg/index.js @@ -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; diff --git a/js/examples/table/index.js b/js/examples/table/index.js index 124f7fe..b3cece2 100644 --- a/js/examples/table/index.js +++ b/js/examples/table/index.js @@ -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)); } diff --git a/js/examples/textfield-dsl/index.js b/js/examples/textfield-dsl/index.js index 18d3d2b..b24980e 100644 --- a/js/examples/textfield-dsl/index.js +++ b/js/examples/textfield-dsl/index.js @@ -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; diff --git a/js/examples/todo/index.js b/js/examples/todo/index.js index 1b1e354..2940ce8 100644 --- a/js/examples/todo/index.js +++ b/js/examples/todo/index.js @@ -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) { diff --git a/js/examples/two-buyer-protocol/index.js b/js/examples/two-buyer-protocol/index.js index 8505604..b101563 100644 --- a/js/examples/two-buyer-protocol/index.js +++ b/js/examples/two-buyer-protocol/index.js @@ -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.