Tutorial: clarify 'other uses of safe references'

This commit is contained in:
Tim Chevalier 2012-08-18 13:44:01 -07:00
parent 3e52a0acde
commit 1d3abf15f1
1 changed files with 7 additions and 0 deletions

View File

@ -1859,6 +1859,13 @@ match my_rec {
}
~~~~
It's unsafe to dereference `b` in the second `log` expression, because `b` is
a _pointer_ to the inside of `my_rec`, and the assignment statement has
allocated a new record and assigned `my_rec` to point to it. Thus, the old
contents of `my_rec` are no longer live, and `b` is dangling at this point.
The borrow-checking analysis inside the compiler recognizes this situation
and rejects the program.
## Argument passing styles
The fact that arguments are conceptually passed by safe reference does