On Friday, 10 April 2015 at 10:02:01 UTC, Martin Nowak wrote:
On Wednesday, 8 April 2015 at 23:11:08 UTC, Walter Bright wrote:
http://wiki.dlang.org/DIP77

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.

Wouldn't it more straightforward to make pass-by-ref unsafe (@system) for RCOs?

Then the only thing missing to make this equally powerful, would be an optimization opportunity for the compiler to elide copies of pass-by-value RCOs, e.g. it could avoid calling the postblit when the function retains the refcount.

Only the first pass by ref create a copy. You can then pass the ref down all you want without copy.

That is an acceptable cost IMO.

Reply via email to