mirror of
https://github.com/urbit/developers.urbit.org.git
synced 2024-09-11 13:55:59 +03:00
commit
357b18aaeb
@ -121,7 +121,7 @@ Save the above code as a file in `ted/mythread.hoon` and `|commit` it. Run it wi
|
||||
[~ 'foo']
|
||||
```
|
||||
|
||||
**NOTE:** The dojo wraps arguments in a unit so that's why it's `[~ 'foo']` rather than just `foo`.
|
||||
**NOTE:** The dojo wraps arguments in a unit so that's why it's `[~ 'foo']` rather than just `'foo'`.
|
||||
|
||||
## Analysis
|
||||
|
||||
|
@ -141,7 +141,7 @@ dojo. We'll get to what each of the arms do later. For now, we'll just consider
|
||||
a few particular points.
|
||||
|
||||
Firstly, note its structure - it's a door (created with `|_`) with a sample of
|
||||
`bowl:gall` and the ten arms described earlier.
|
||||
`bowl:gall` and the ten arms described earlier. The `=bowl:gall` syntax simply means `bowl=bowl:gall` ([`$=` irregular syntax](/reference/hoon/irregular#-buctis)).
|
||||
|
||||
Secondly, you'll notice some of the arms return:
|
||||
|
||||
|
@ -960,7 +960,7 @@ You can also create a trap for later use with the [`|.` bardot](/reference/hoon/
|
||||
|
||||
What is a gate? It is a door with only one arm `$` buc, and whenever you invoke it then that default arm's expression is referred to and evaluated.
|
||||
|
||||
A _gate_ and a _trap_ are actually very similar: a [gate](/reference/hoon/rune/bar#-bartis) simply has a sample (and can actively change when evaluated or via a `%=` cenhep), whereas a trap does not (and can _only_ be passively changed via something like `%=` cenhep).
|
||||
A _gate_ and a _trap_ are actually very similar: a [gate](/reference/hoon/rune/bar#-bartis) simply has a sample (and can actively change when evaluated or via a `%=` centis), whereas a trap does not (and can _only_ be passively changed via something like `%=` centis).
|
||||
|
||||
#### Example: Hoon Workbook
|
||||
|
||||
|
@ -255,7 +255,7 @@ To act in a stateful manner, a core must mutate itself and then pin the mutated
|
||||
|
||||
We will use `%say` generators as a bridge concept. We will produce some short applications that maintain state while carrying out a calculation; they still result in a single return value, but gesture at the big-picture approach to maintaining state in persistent agents.
|
||||
|
||||
Here are a couple of new runes for modifying the subject and chaining computations together, aside from `%=` cenhep which you've already seen:
|
||||
Here are a couple of new runes for modifying the subject and chaining computations together, aside from `%=` centis which you've already seen:
|
||||
|
||||
- [`=.` tisdot](/reference/hoon/rune/tis#-tisdot) is used to change a leg in the subject.
|
||||
- [`=~` tissig](/reference/hoon/rune/tis#-tissig) composes many expressions together serially.
|
||||
@ -348,7 +348,7 @@ For instance, a network service call may take a while or may fail. How should t
|
||||
|
||||
We have some more tools available for managing deferred or chained computations, in addition to `=~` tissig and `=*` tistar:
|
||||
|
||||
- [`=^` tisket](/reference/hoon/rune/tis#-tisket) is used to change a leg in the tail of the subject then evaluate against it. This is commonly used for events that need to be ordered in their resolution e.g. with a `%=` cenhep. (Used in Gall agents frequently.)
|
||||
- [`=^` tisket](/reference/hoon/rune/tis#-tisket) is used to change a leg in the tail of the subject then evaluate against it. This is commonly used for events that need to be ordered in their resolution e.g. with a `%=` centis. (Used in Gall agents frequently.)
|
||||
- [`=*` tistar](/reference/hoon/rune/tis#-tistar) defers an expression (rather like a macro).
|
||||
- [`;<` micgal](/reference/hoon/rune/mic#-micgal) sequences two computations, particularly for an asynchronous event like a remote system call. (Used in [threads](/reference/arvo/threads/overview).)
|
||||
- [`;~` micsig](/reference/hoon/rune/mic#-micsig) produces a pipeline, a way of piping the output of one gate into another in a chain. (This is particularly helpful when parsing text.)
|
||||
|
@ -680,7 +680,7 @@ If `i` and `n` are equal, the trap will produce `~`. If not, `s` is called and
|
||||
==
|
||||
```
|
||||
|
||||
The final arm in our core is `++fib`, which is a `++stream` of `@ud` and therefore is a `%lead` core. Its subject contains `p` and `q`, which will not be accessible outside of this trap, but because of the `%=` cenhep will be retained in their modified form in the product trap. The product of the trap is a pair (`:-` colhep) of an `@ud` and the trap that will produce the next `@ud` in the Fibonacci series.
|
||||
The final arm in our core is `++fib`, which is a `++stream` of `@ud` and therefore is a `%lead` core. Its subject contains `p` and `q`, which will not be accessible outside of this trap, but because of the `%=` centis will be retained in their modified form in the product trap. The product of the trap is a pair (`:-` colhep) of an `@ud` and the trap that will produce the next `@ud` in the Fibonacci series.
|
||||
|
||||
```hoon
|
||||
=< (to-list (take fib 10))
|
||||
|
Loading…
Reference in New Issue
Block a user