On 21 April 2013 06:51, Timon Gehr <timon.gehr@gmx.ch> wrote:
On 04/20/2013 05:56 PM, Dicebot wrote:
You miss quite an important point - DIP36 does not add new feature. It
partially defines existing feature (scope) to replace an existing but
broken solution (auto ref). Nothing new is really added to the language,
only existing stuff better defined.

_New meaning_ is assigned to existing grammar whose original purpose is at most loosely related to the _new_ features.

I do not think that making 'scope' indicate an rvalue reference is particularly future proof.

That's not what scope does. Scope promises that the variables will not escape the scope. And as such, just happens to make passing a temporary by ref safe.
It does not implement r-value ref's. It simply allows refs to temporaries to be considered a safe operation.

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)


In this example, the 'solution', which is what everybody does right now, is exactly as unsafe as the attempted call with the r-value.
ref, as in the language right now, is a fundamentally unsafe operation... and not only is it technically unsafe, a programmer can't even know if it is practically unsafe or not.
Since they have a habit of using this hack, they may unknowingly use it in a call site where it's not *practically* safe to do it. They can't know, and by habit (and frustration) they're trained to use this hack everywhere.

With 'scope ref' (or 'in ref'), the programmer now has a guide to say whether it's safe to pass a temporary or not. In the future, if the function does not receive scope ref, perhaps the programmer will start to presume that it is NOT safe to pass a temporary, and stop doing so via the current local-variable hack.

scope was always intended to implement this promise as far as I'm lead to believe(?).

<Side rant>
In my experience showing D to new people, this is the #1 complaint. It's the first one that comes up, every time (which really doesn't help with first impressions), and I'm fairly sure every single person I've introduced to D has complained about this.
It's kind of embarrassing when I'm saying that D is really cool, and then I have to start making excuses and apologising for this, and assure them that it's a known issue, and it'll be fixed one day.