@@ -6,7 +6,7 @@ template = "doc.html"
7In this lesson we'll look at sending and receiving one-off messages called
7In this lesson we'll look at sending and receiving one-off messages called
8`%poke`s. We'll look at the `on-poke` agent arm which handles incoming pokes.
8`%poke`s. We'll look at the `on-poke` agent arm which handles incoming pokes.
9−We'll also introduce the `on-agent` arm, and look at one kind of response it can
9+We'll also introduce the `on-agent` arm, and look at the one kind of response it can
10take - a `%poke-ack`.
10take - a `%poke-ack`.
12## Receiving a poke
12## Receiving a poke
@@ -106,8 +106,8 @@ produce the `(quip card _this)` like so:
107The [colcab](/docs/hoon/reference/rune/col#_-colcab) (`:_`) rune makes an
107The [colcab](/docs/hoon/reference/rune/col#_-colcab) (`:_`) rune makes an
108inverted cell, it's just `:-` but with the head and tail swapped. We use colcab
108inverted cell, it's just `:-` but with the head and tail swapped. We use colcab
109−to produce the `(quip card _this)` because the list of cards is typically
109+to produce the `(quip card _this)` because the list of cards is "heavier"
110−"heavier" than the new agent core expression (`this`), so it makes it more
110+here than the new agent core expression (`this`), so it makes it more
113### Receiving the `%poke-ack`
113### Receiving the `%poke-ack`
@@ -144,7 +144,9 @@ The simplest way to handle a `%poke-ack` by passing it to `default-agent`'s
144`on-agent` arm, which will just print an error message to the terminal if it's a
144`on-agent` arm, which will just print an error message to the terminal if it's a
145nack, and otherwise do nothing. Sometimes you'll want your agent to do something
145nack, and otherwise do nothing. Sometimes you'll want your agent to do something
146different depending on whether the poke failed or succeeded (and therefore
146different depending on whether the poke failed or succeeded (and therefore
147+whether it's a nack or an ack).
147−whether it's a nack or an ack). As stated in the [Precepts](/docs/development/precepts#specifics): "Route on wire before sign, never sign before wire.". Thus we first test the
149+As stated in the [Precepts](/docs/development/precepts#specifics): "Route on wire before sign, never sign before wire.". Thus we first test the
148`wire` so you can tell what the `%poke-ack` was for. You might do something
150`wire` so you can tell what the `%poke-ack` was for. You might do something
@@ -216,7 +218,8 @@ receiving pokes. Here's the first, an agent that receives pokes:
217 =/ action !<(?(%inc %dec) vase)
219 =/ action !<(?(%inc %dec) vase)
218 ?- action
220 ?- action
219− %inc `this(val +(val))
221+ %inc `this(val +(val))
221 ?: =(0 val)
224 ?: =(0 val)
222 ~| "Can't decrement - already zero!"
225 ~| "Can't decrement - already zero!"
@@ -324,7 +327,7 @@ dojo: app poke failed
324### `pokeit.hoon`
327### `pokeit.hoon`
326Here's a second agent. It takes a poke of `%inc` or `%dec` like before, but
329Here's a second agent. It takes a poke of `%inc` or `%dec` like before, but
327−rather that updating its own state, it sends two pokes to `%pokeme`, so
330+rather than updating its own state, it sends two pokes to `%pokeme`, so
328`%pokeme`'s state will be incremented or decremented by two.
331`%pokeme`'s state will be incremented or decremented by two.
@@ -368,6 +371,7 @@ rather that updating its own state, it sends two pokes to `%pokeme`, so
368 :~ [%pass /inc %agent [our.bowl %pokeme] %poke %noun !>(%inc)]
371 :~ [%pass /inc %agent [our.bowl %pokeme] %poke %noun !>(%inc)]
369 [%pass /inc %agent [our.bowl %pokeme] %poke %noun !>(%inc)]
372 [%pass /inc %agent [our.bowl %pokeme] %poke %noun !>(%inc)]
373 :~ [%pass /dec %agent [our.bowl %pokeme] %poke %noun !>(%dec)]
377 :~ [%pass /dec %agent [our.bowl %pokeme] %poke %noun !>(%dec)]
@@ -476,7 +480,7 @@ Let's try it out:
477`%pokeit` has received positive `%poke-ack`s, which means both pokes succeeded.
481`%pokeit` has received positive `%poke-ack`s, which means both pokes succeeded.
478It could tell they were increments because the `%poke-ack`s came back on the
482It could tell they were increments because the `%poke-ack`s came back on the
479−`/inc` path we specified. We can check the state of `%pokeme` to confirm:
483+`/inc` wire we specified. We can check the state of `%pokeme` to confirm: