DIP77 - Fix unsafe RC pass by 'ref'

Zach the Mystic via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 9 20:33:58 PDT 2015


On Wednesday, 8 April 2015 at 23:11:08 UTC, Walter Bright wrote:
> http://wiki.dlang.org/DIP77

 From the DIP:
T foo(ref Payload payload);
...
RC rc;
foo(rc.payload);

rewrite foo(rc) as:

auto tmp = rc;
foo(rc.payload);

The only question I had was whether there was an advantage to 
rewriting the statement in its own scope:
{
   auto tmp = rc;
   foo(rc.payload);
}

You can save some stack space that way, but I don't know how hard 
it is to implement.


More information about the Digitalmars-d mailing list