@@ -4,6 +4,8 @@ weight = 10
4template = "doc.html"
4template = "doc.html"
7+In this lesson we'll look at the basic type and structure of a Gall agent.
7A Gall agent is a `door` with exactly ten arms. Each arm is responsible for
9A Gall agent is a `door` with exactly ten arms. Each arm is responsible for
8handling certain kinds of events that Gall feeds in to the agent. A `door` is
10handling certain kinds of events that Gall feeds in to the agent. A `door` is
9just a `core` with a sample - it's made with the
11just a `core` with a sample - it's made with the
@@ -67,13 +69,13 @@ documentation](/docs/arvo/gall/data-types#bowl).
68If you've worked through [Hoon School](/docs/hoon/hoon-school/intro), you may
70If you've worked through [Hoon School](/docs/hoon/hoon-school/intro), you may
69recall that a core is a cell of `[battery payload]`. The battery is the core
71recall that a core is a cell of `[battery payload]`. The battery is the core
70−itself compiled into nock, and the payload is the subject which it operates on.
72+itself compiled to nock, and the payload is the subject which it operates on.
72For an agent, the payload will at least contain the bowl, the usual standard
74For an agent, the payload will at least contain the bowl, the usual standard
73−library functions, and the **state** of the agent. If your agent were for an
75+library functions, and the **state** of the agent. For example, if your agent
74−address book app, it might keep a `map` of ships to address book entries. It
76+were for an address book app, it might keep a `map` of ships to address book
75−might add entries, delete entries, and modify entries. This address book `map`
77+entries. It might add entries, delete entries, and modify entries. This address
76−would be part of the state stored in the payload.
78+book `map` would be part of the state stored in the payload.
78## Transition function
80## Transition function
@@ -81,8 +83,8 @@ If you recall from the prologue, the whole Arvo operating system works on the
81basis of a simple transition function `(event, oldState) -> (effects, newState)`. Gall agents also function the same way. Eight of an agent's ten arms
83basis of a simple transition function `(event, oldState) -> (effects, newState)`. Gall agents also function the same way. Eight of an agent's ten arms
82produce the same thing, a cell of:
84produce the same thing, a cell of:
84−- Head: A list of effects called `card`s (which we'll discuss later).
86+- **Head**: A list of effects called `card`s (which we'll discuss later).
85−- Tail: A new agent core, possibly with a modified payload.
87+- **Tail**: A new agent core, possibly with a modified payload.
87It goes something like this:
89It goes something like this:
@@ -107,7 +109,7 @@ rejected.
107What this means is that you can intentionally design your agent to crash in
109What this means is that you can intentionally design your agent to crash in
108cases it can't handle. For example, if a poke comes in with an unexpected
110cases it can't handle. For example, if a poke comes in with an unexpected
109`mark`, it crashes. If a permission check fails, it crashes. This is quite
111`mark`, it crashes. If a permission check fails, it crashes. This is quite
110−different to many programs written in procedural languages, which must handle
112+different to most programs written in procedural languages, which must handle
111all exceptions to avoid crashing.
113all exceptions to avoid crashing.
113## Example
115## Example
@@ -143,7 +145,7 @@ Secondly, you'll notice some of the arms return:
145A backtick at the beginning is an irregular syntax meaning "prepend with null",
147A backtick at the beginning is an irregular syntax meaning "prepend with null",
146−so for example in the dojo:
148+so for example, in the dojo:
@@ -277,8 +279,6 @@ If we again examine our agent core's payload by looking at the tail of
278## Summary
280## Summary
280−The key takeways are:
282- A Gall agent is a `door` with ten arms and a sample of `bowl:gall`.
282- A Gall agent is a `door` with ten arms and a sample of `bowl:gall`.
283- Each of the ten arms handle different kinds of events - Gall calls the
283- Each of the ten arms handle different kinds of events - Gall calls the
284 appropriate arm for the kind event it receives.
284 appropriate arm for the kind event it receives.