On Saturday, 26 July 2014 at 13:01:13 UTC, Kagamin wrote:
On Saturday, 26 July 2014 at 10:49:25 UTC, Marc Schütz wrote:
There are some corner cases here. For example when an r-value
is moved into a function as an argument. The callee will not
decrement the RC of its parameters, with the consequence that
the RC never goes to 0. There might be other problems, in
particular in the presence of optimizations.
How about this: an r-value is moved to caller's stack, then
passed to the callee? This way the callee still won't have to
maintain the counter. And this probably prohibits tail call
optimization.
Yes. And it needs stack unwinding on exceptions, but this is
needed anyway.
On the other hand, if `scope` works and is used wherever
possible, all of this probably doesn't matter too much. Most
utility functions would just take `scope`, and won't need to pay
the costs.