on master help sign in
Minor technical corrections to egg-timer walkthrough
f3be624David Kerschner
learn/hoon/hoon-tutorial/egg-timer.md+7−7
@@ -1,5 +1,5 @@
1+++
1+++
2−title = "2.7.1 Walkthrough: Egg Timer"
2+title = "2.7.1 Gall Walkthrough: Egg Timer"
3weight = 36
3weight = 36
4template = "doc.html"
4template = "doc.html"
5+++
5+++
@@ -17,7 +17,7 @@ The Arvo operating system is divided up into modules called vanes. Gall is the v
17 |= t=@dr
17 |= t=@dr
18 ^+ [*(list effect) +>.$]
18 ^+ [*(list effect) +>.$]
19 :_ +>.$ :_ ~
19 :_ +>.$ :_ ~
20− [ost %wait /(scot %da now) (add now t)]
20+ [ost %wait /egg-timer (add now t)]
21++ wake
21++ wake
22 |= [=wire error=(unit tang)]
22 |= [=wire error=(unit tang)]
23 ^+ [*(list effect) +>.$]
23 ^+ [*(list effect) +>.$]
@@ -60,7 +60,7 @@ The `door` we've made has two arms `poke-noun` and `wake`. Gall is capable of di
60 |= t=@dr
60 |= t=@dr
61 ^+ [*(list effect) +>.$]
61 ^+ [*(list effect) +>.$]
62 :_ +>.$ :_ ~
62 :_ +>.$ :_ ~
63− [ost %wait /(scot %da now) (add now t)]
63+ [ost %wait /egg-timer (add now t)]
64```
64```
65
65
66In the above code, we create a gate that takes a single `@dr` argument. `@dr` is an aura for a 128-bit relative date. Here are a few examples.
66In the above code, we create a gate that takes a single `@dr` argument. `@dr` is an aura for a 128-bit relative date. Here are a few examples.
@@ -74,7 +74,7 @@ As a matter of good type hygiene, we explicitly cast the output of this gate wit
74Next we're going to use the `:_` rune which is just the inverted form a `:-` the cell construction rune. We use it twice so the actual data will end up looking something like:
74Next we're going to use the `:_` rune which is just the inverted form a `:-` the cell construction rune. We use it twice so the actual data will end up looking something like:
75
75
76```
76```
77−[[[ost %wait /(scot %da now) (add now t)] ~] +>.$]
77+[[[ost %wait /egg-timer (add now t)] ~] +>.$]
78```
78```
79
79
80`ost` is the `bone`, the opaque reference to a chain of events, that comes from `bowl`, so we're going to continue to use it here. `%wait` is the name of the `syscall`, in this case a request to the Behn vain to start a timer for us.
80`ost` is the `bone`, the opaque reference to a chain of events, that comes from `bowl`, so we're going to continue to use it here. `%wait` is the name of the `syscall`, in this case a request to the Behn vain to start a timer for us.
@@ -82,10 +82,10 @@ Next we're going to use the `:_` rune which is just the inverted form a `:-` the
82After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique identifier for this `syscall`:
82After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique identifier for this `syscall`:
83
83
84```
84```
85−/(scot %da now)
85+/egg-timer
86```
86```
87
87
88−The `/` here is an irregular syntax to make a `path`, and `scot` is going to transform `now`, the current time as given to us by `bowl`, from a `@da` to a `cord`.
88+The `/` here is an irregular syntax to make a `path`.
89
89
90The final part of this `syscall` is:
90The final part of this `syscall` is:
91
91
@@ -95,7 +95,7 @@ The final part of this `syscall` is:
95
95
96`now` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` these two to get an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
96`now` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` these two to get an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
97
97
98−That's all for our `poke-noun` arm. But what about when the timer goes off? Behn will create a `move` similar to how we created one with `effect`, only this time it will end up being dispatched back to us in the `++wake` arm. Behn always looks for an arm named `++wake` when a timer goes off; it is defined this way in the vane's code. So any app that wants to use a timer trigger needs to have an arm called `++wake`.
98+That's all for our `poke-noun` arm. But what about when the timer goes off? Behn will create a `gift` a similar construct to how we created an `effect`, only this time it will end up being dispatched back to us via Gall in the `++wake` arm. Any app that wants to use a timer trigger needs to have an arm called `++wake`.
99
99
100```
100```
101++ wake
101++ wake