DIP 1016--ref T accepts r-values--Formal Assessment

Don don at gmail.com
Wed Jan 30 00:25:17 UTC 2019


I'm on the reviewers side here.

To be honest I never liked this DIP and maybe I'll sound dumb but 
I think this is a case where this could bring more problem than 
anything.

The way I see this would be more like a syntax sugar to create 
temporary variable for ref parameters and that's it.

But what I fail to see is why can't the programmer solve this 
themselves instead of relying on a new feature that would cause 
more harm?

With overload some could do:

void f(int i){
     f(i);
}

void f(ref int i){
     ++i;
     writeln(i);
}

void main(){
     int i = 0;
     f(10);
     f(i);
}

prints:
11
1

The "f" function will work with ref or literal (rvalues).

But this will be controlled by the programmer the way they want 
it.

Donald.


More information about the Digitalmars-d-announce mailing list