From 1d3abf15f149036cfd0fa939f6393136ffcd1d7f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Sat, 18 Aug 2012 13:44:01 -0700 Subject: [PATCH] Tutorial: clarify 'other uses of safe references' --- doc/tutorial.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index 5a2fce3bc77..5da42e4e195 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -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