diff options
Diffstat (limited to 'chapter13/README.md')
| -rw-r--r-- | chapter13/README.md | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/chapter13/README.md b/chapter13/README.md index e381f1dc..49737663 100644 --- a/chapter13/README.md +++ b/chapter13/README.md @@ -1,9 +1,9 @@ -# Chapter 12: Floats, Arrays, Refs - -## Floats +# Chapter 12: Floats, References and Arrays In this chapter we add a series of new types and some modest syntax. +## Floats + Floating point values start with the `flt` type and compute IEEE754 64-bit arithmetic. Integer expressions auto-widen to floats when involved in a float expression. @@ -45,3 +45,22 @@ Within the Type Lattice, we now add the following domain: with a TOP, BOT and constants +## References + +Structs can reference other structs; references can be mutually recursive. +Any reference field can allow null or not, same as a normal variable. + +```java +struct Person { + String name; // No string type, yet + int age; + FamilyTree tree?; // A family tree, or not +} +struct FamilyTree { + Person father?; + Person mother?; + Person []kids?; +} +``` + +Normal field syntax works: `person.tree.father = new Person;` or `person.tree.father.name = "Dad";`. |
