On 5/4/2013 2:22 PM, deadalnix wrote:
I still think this is inferior to Rust's solution and like to see ref as a
equivalent of the Rust burrowed pointer. It achieve the same safety at compile
time instead at runtime, and incurs no extra complexity except in some very rare
cases (when you have a function taking several arguments by ref and returning
also by ref and the lifetime of the returned ref isn't the union of the lifetime
of the ref parameters - a very specific case).
As you say, D ref's are analogous to Rust's borrowed pointers, and for the
escaping ref problem, Rust requires additional annotations (much like the 'scope
ref' proposal).
http://static.rust-lang.org/doc/tutorial-borrowed-ptr.html#returning-borrowed-pointers
The runtime check is because Andrei & I really didn't like requiring additional
annotations.