on master help sign in
Added reminders to cast often in hoon (#704)
257d54fDavid Kerschner
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
473
473
474Here 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.
474Here 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.
475
475
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.
476
479
477## Summary
480## Summary
478
481
tutorials/hoon/lists.md+4
@@ -33,6 +33,10 @@ To make a list, let's cast nouns to the `(list @)` ("list of atoms") type.
33
33
34Notice 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 ~]`.
34Notice 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 ~]`.
35
35
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+
36Let's make a list whose items are of the `@t` string type:
40Let's make a list whose items are of the `@t` string type:
37
41
38```
42```