DIP77 - Fix unsafe RC pass by 'ref'
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 10 03:02:00 PDT 2015
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.
More information about the Digitalmars-d
mailing list