private vars
This commit is contained in:
@@ -56,13 +56,13 @@ var hello = use('examples/hello')
|
||||
|
||||
log.console(hello.greet('Cell'))
|
||||
|
||||
$_.receiver(function(msg) {
|
||||
$receiver(function(msg) {
|
||||
if (msg.type == 'ping') {
|
||||
send(msg, {type:'pong'})
|
||||
}
|
||||
})
|
||||
|
||||
$_.delay(_ => $_.stop(), 0.1)
|
||||
$delay(_ => $stop(), 0.1)
|
||||
```
|
||||
|
||||
Run it:
|
||||
@@ -71,7 +71,7 @@ Run it:
|
||||
|
||||
Notes:
|
||||
- Modules are `*.cm` and must return a value. The engine deep‑freezes return values, so mutate via new objects or closures rather than in‑place.
|
||||
- Programs are `*.ce` and must not return a value. They run top‑to‑bottom when spawned and can register handlers via `$_.receiver()` and schedule work via `$_.delay()` or `$_.clock()`.
|
||||
- Programs are `*.ce` and must not return a value. They run top‑to‑bottom when spawned and can register handlers via `$receiver()` and schedule work via `$delay()` or `$clock()`.
|
||||
|
||||
## 5) Spawning Child Programs (Actors)
|
||||
|
||||
@@ -80,19 +80,19 @@ Programs can spawn other programs and receive lifecycle events.
|
||||
- File: `examples/spawner.ce`
|
||||
|
||||
```javascript
|
||||
$_.receiver(function(e) {
|
||||
$receiver(function(e) {
|
||||
if (e.type == 'greet' && e.actor) {
|
||||
log.console('Child greeted me')
|
||||
}
|
||||
})
|
||||
|
||||
$_.start(function(info) {
|
||||
$start(function(info) {
|
||||
if (info.type == 'greet') {
|
||||
log.console('Spawned child actor')
|
||||
}
|
||||
}, 'examples/hello.ce')
|
||||
|
||||
$_.delay(_ => $_.stop(), 0.5)
|
||||
$delay(_ => $stop(), 0.5)
|
||||
```
|
||||
|
||||
Run it:
|
||||
|
||||
Reference in New Issue
Block a user