Rvalue references - The resolution
deadalnix
deadalnix at gmail.com
Sat May 4 14:57:12 PDT 2013
On Saturday, 4 May 2013 at 21:48:25 UTC, Walter Bright wrote:
> 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.
Where you miss the point, is that these annotations may be
omitted (and they are most of the time). When nothing is
specified, the lifetime of the returned reference is considered
to be the union of the lifetime of parameters lifetime, which is
what you want in 99% of cases.
More information about the Digitalmars-d
mailing list