www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Time to remove ugly auto ref ?

reply "Temtaime" <temtaime gmail.com> writes:
Hi all !
It's too ugly that we cannot write simply « ref in » on functions 
argument.
Many of functions expects a const argument and don't want to know 
is it a temp object or not.

In C++ we can write

struct Number {
Number operator+(const Number &num);
...
};

And then use it as « auto c = a + Number(123);

But in D we cannot. Why ? Because ref doesn't accept temp objects.
We need to use auto ref. OK, but auto ref cannot be used on 
non-templated function.
We need even more make that function templated. It leads to a 
code bloat.

I don't see a reason why « auto ref » even exists.
I think we need to accept temp objects on functions arguments 
marked « const ref » : no auto required and functions is not a 
template.
That change will not break any exiting code : it only allows a 
const ref to accept a temporal object.
In future we can simple deprecate « auto ref » so users will 
adjust their code.
Jun 19 2015
parent reply "Namespace" <rswhite4 gmail.com> writes:
I've made a PR:
https://github.com/D-Programming-Language/dmd/pull/4717
Jun 19 2015
next sibling parent reply "Temtaime" <temtaime gmail.com> writes:
Hi !
I think that's great but isn't it better to use « ref in » 
instead ?
Jun 19 2015
parent "Namespace" <rswhite4 gmail.com> writes:
On Friday, 19 June 2015 at 12:34:49 UTC, Temtaime wrote:
 Hi !
 I think that's great but isn't it better to use « ref in » 
 instead ?
Search for DIP 36 and look what the decision was.
Jun 19 2015
prev sibling parent reply bitwise <bitwise.pvt gmail.com> writes:
On Fri, 19 Jun 2015 08:28:17 -0400, Namespace <rswhite4 gmail.com> wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
Jun 19 2015
next sibling parent reply "rsw0x" <anonymous anonymous.com> writes:
On Friday, 19 June 2015 at 14:49:59 UTC, bitwise wrote:
 On Fri, 19 Jun 2015 08:28:17 -0400, Namespace 
 <rswhite4 gmail.com> wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
having a way to track important PRs would be nice.
Jun 19 2015
parent bitwise <bitwise.pvt gmail.com> writes:
On Fri, 19 Jun 2015 11:34:23 -0400, rsw0x <anonymous anonymous.com> wrote:

 having a way to track important PRs would be nice.
I agree. With conversations often spanning between the NG, pull-comments, maybe private emails, it's especially hard for new-comers to figure out what's going on. Bit
Jun 19 2015
prev sibling parent reply "Namespace" <rswhite4 gmail.com> writes:
On Friday, 19 June 2015 at 14:49:59 UTC, bitwise wrote:
 On Fri, 19 Jun 2015 08:28:17 -0400, Namespace 
 <rswhite4 gmail.com> wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
I've pinged him already two times, but no reaction so far. Therefore I guess Andrei has a lot to do and will see about it later.
Jun 19 2015
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/19/15 9:14 AM, Namespace wrote:
 On Friday, 19 June 2015 at 14:49:59 UTC, bitwise wrote:
 On Fri, 19 Jun 2015 08:28:17 -0400, Namespace <rswhite4 gmail.com> wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
I've pinged him already two times, but no reaction so far. Therefore I guess Andrei has a lot to do and will see about it later.
It's one of my 21 opened browser tabs... I should discuss this with Walter today. -- Andrei
Jun 19 2015
next sibling parent "Namespace" <rswhite4 gmail.com> writes:
On Friday, 19 June 2015 at 16:53:26 UTC, Andrei Alexandrescu 
wrote:
 On 6/19/15 9:14 AM, Namespace wrote:
 On Friday, 19 June 2015 at 14:49:59 UTC, bitwise wrote:
 On Fri, 19 Jun 2015 08:28:17 -0400, Namespace 
 <rswhite4 gmail.com> wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
I've pinged him already two times, but no reaction so far. Therefore I guess Andrei has a lot to do and will see about it later.
It's one of my 21 opened browser tabs... I should discuss this with Walter today. -- Andrei
Great to hear that! :)
Jun 19 2015
prev sibling parent bitwise <bitwise.pvt gmail.com> writes:
On Fri, 19 Jun 2015 12:53:25 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail erdani.org> wrote:

 On 6/19/15 9:14 AM, Namespace wrote:
 On Friday, 19 June 2015 at 14:49:59 UTC, bitwise wrote:
 On Fri, 19 Jun 2015 08:28:17 -0400, Namespace <rswhite4 gmail.com>  
 wrote:

 I've made a PR:
 https://github.com/D-Programming-Language/dmd/pull/4717
What's the holdup on this anyways? Bit
I've pinged him already two times, but no reaction so far. Therefore I guess Andrei has a lot to do and will see about it later.
It's one of my 21 opened browser tabs... I should discuss this with Walter today. -- Andrei
Awesome, thanks for the heads up =D Bit
Jun 19 2015