on master help sign in
Clamification
commit605bf7983a6b5278d0e17c1009befa2c70cc842b authorMatthew Levan <matt.s.levan@gmail.com> dateFri 13 Oct 2017, 16:49 (9 years ago) parent81c0605
1 file changed+8−9
docs/arvo/network.md+8−9
docs/arvo/network.md+8−9
@@ -207,15 +207,14 @@ urbit, this output:
207207Most of the code should be straightforward. In `++poke-atom`, the only new thing
208208is the expression `` `@t`tom ``, which is *casting* the argument `tom` to type
209209`@t`. As we already know, `@t` is the type of "cord" (text string). In Hoon,
210−when types are called using tick marks, they serve as a validator function--
211−that is, a function whose domain is all nouns, and range is the given type
212−(in this case, `@t`). When a type is called as a function (`(@t tom)`, for
213−example), it is called a "clam". A clam behaves the same as a cast.
214−
215−In simpler terms, if a clam is passed a value of its own type, it produces that
216−value. Otherwise, it produces the default value (aka the "bunt") of its type.
217−Here we call this `@t` function on the argument. This coerces the argument to
218−text, so that we can print it out prettily no matter what we're passed.
210+another way to perform a kind of casting is to use a type as a function, like
211+this: `(@t tom)`. When types are called like this, they are called "clams",
212+and they serve as validator functions-- that is, functions whose domain is all
213+nouns, and range is the given type (in this case, `@t`). Clams will "bunt" the
214+default value of the mold whereas casts (`@t`tom) may `nest-fail` if the
215+argument passed to it does not fit. An example of such a failure case is
216+passing a cell to an atom: `` `@`[1 2] ``. Using a clam here instead
217+(`(@ [1 2])`) will bunt the default value of `@`, which is `0`. Try it in dojo!
219218
220219The more interesting part is in `++poke-urbit`. The `urbit` mark is an urbit
221220identity, and the Hoon type associated with it is `ship` or `@p` (the "p"