on master help sign in
Added reminders to cast often in hoon (#704)

* Added reminders to cast often in hoon * typo * Accidentally a word

commit257d54f681da062e482f69cb2b1ab765b8062796 authorDavid Kerschner <david@tlon.io> dateTue 5 Nov 2019, 15:54 (7 years ago) parent4305216
2 files changed+7
tutorials/hoon/arms-and-cores.md+3 tutorials/hoon/lists.md+4
tutorials/hoon/arms-and-cores.md+3
@@ -473,6 +473,9 @@ Let's take a quick look at how cores can be combined to build up larger structur
473473
474474Here you can see the style of wrapping one core in another. This technique is used frequently in Hoon, particularly in the standard library. `dec` is used in the subsequent core. This can be a useful code organization technique. Gates and Traps are both special kinds of cores, as you will see in later lessons.
475475
476+## Casts
477+
478+Once again we remind you it's a good idea when writing your code to cast your data structures often. The Hoon type inferencer is quite naive and while it will often correctly understand what you mean, manually casting can be beneficial both for someone reading the code and for helping you debug problems.
476479
477480## Summary
478481
tutorials/hoon/lists.md+4
@@ -33,6 +33,10 @@ To make a list, let's cast nouns to the `(list @)` ("list of atoms") type.
3333
3434Notice how the last Dojo command has a different construction, with the `~` in front of the bracketed items. This is just another way of writing the same thing; `~[1 2]` is semantically identical to `[1 2 ~]`.
3535
36+## An aside about Casting
37+
38+The use of casts in this example is helpful to explain to the Hoon compiler exactly what it is we mean with these data structures. In this case, we are telling it they are all lists of atoms. Get in the habit of casting your data structures, as it will not only help anyone reading your code, but it will help you in hunting down bugs in your code.
39+
3640Let's make a list whose items are of the `@t` string type:
3741
3842```