On 4/10/2015 2:20 PM, Martin Nowak wrote:
On 04/10/2015 12:29 PM, Walter Bright wrote:
So someone passes an RCO via ref to avoid the inc/dec, and because
that imposes
safety issues we turn it into some sort of pass by value under the hood,
defeating the purpose, and provide an opt-out via @system opAssign.
Or you could pass it by const ref (which is what Rust essentially does).
Maybe I'm missing something, but this proposal seems to make `ref RCO`
fairly useless, because it creates a copy anyhow.
Not if you read the copy elision section.
Assigning a RefCounted is marked @system,
That's kind of throwing in the towel, isn't it?
pass-by-ref is @safe.
What's missing, you want to be able to use RefCounted in @safe code? Why
not pass it by value then? That would pin the object and you could elide
the additional inc/dec just like you propose to elide the temporary copies.
It's more efficient to pass a smart pointer like RefCounted by-value anyhow.