On 3/2/2015 12:42 PM, Walter Bright wrote:
On 3/2/2015 12:37 PM, Steven Schveighoffer wrote:
Not exactly. Note that we are taking by reference S, which is NOT reference
counted. So you are passing indirectly a reference to an RC object. You aren't
"borrowing" that reference.
It's seems that to solve the problem, it has to be borrowed, in that a static
check will be needed that what it points to cannot be modified/deleted through
other references to the same data.
I looked at how Rust does it. I was hoping it was something clever, but it
isn't. A copy is made of the object to which a borrowed reference is taken - in
other words, the reference count is incremented.
For D structs, that means, if there's a postblit, a copy must be made. For D ref
counted classes, a ref count increment must be done.
I was hoping to avoid that, but apparently there's no way.
There are cases where this can be avoided, like calling pure functions. Another
win for pure functions!