On Sunday, 21 April 2013 at 02:13:54 UTC, Manu wrote:
This DIP is actually likely to solve an important source of
problems,
consider:
void func(const ref matrix m);
func(x.getMatrix()); // compile error!
// fu*^&%$ing hell! you piece of &%^#≈¿$!
// ...
matrix temp = x.getMatrix();
func(temp); // no more compile error! (but equally
unsafe/dangerous)
It's hard to fully understand this example without getMatrix()
defined,
and why func() is unsafe (does it escape the reference?). Help!
definition:
matrix getMatrix(T x); // this is all you know
That's the point of the example. You _don't know_ if func() is
unsafe, does
it escape the reference? But you need to pass a temp anyway,
you have no
bearing on whether you should just hack it to work, or
reconsider the
problem.
And when 99 times out of 100, the correct answer is 'hack it to
work',
you're basically asking for a spectacular bug in that other 1%
of cases.
Yeah, that's kind of what I meant when I said it's a two-for-one
deal. You get to pass temps, and you get safety checking too.