Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote: Auto ref parameters seem to be just what I need. Thanks! I'd still be curious if anyone has additional information regarding the rationale at play (I'm spoiled, reading TDPL and having each decision explained in text). I had the

Re: const ref parameters and r-value references

2014-05-04 Thread Timon Gehr via Digitalmars-d-learn
On 05/04/2014 12:58 PM, Marc Schütz schue...@gmx.net wrote: This means that you will still get a (bit-wise) copy if you pass in an r-value. But semantically, this is a move, not a copy, so it is potentially cheaper than a copy (if your type has an expensive postblit). It can be constructed

Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Sunday, 4 May 2014 at 11:15:59 UTC, Timon Gehr wrote: On 05/04/2014 12:58 PM, Marc Schütz schue...@gmx.net wrote: This means that you will still get a (bit-wise) copy if you pass in an r-value. But semantically, this is a move, not a copy, so it is potentially cheaper than a copy (if your

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 02 May 2014 08:17:06 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) {

Re: const ref parameters and r-value references

2014-05-04 Thread bearophile via Digitalmars-d-learn
Jonathan M Davis: Andrei suggested auto ref to fix this problem, and Walter implemented it, but he misunderstood what Andrei had meant, I missed this detail of the story :-) Walter has suggested that we just redefine ref itself to do what I just described rather than using auto ref or

Re: const ref parameters and r-value references

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
Thanks for the insights! I suppose we'll get a chance to see where things stand at this year's dconf. It's quite interesting that D's concept of r-values seems less developed than C++. Here's hoping that that only results in a better thought out solution.

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 04 May 2014 19:08:27 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks for the insights! I suppose we'll get a chance to see where things stand at this year's dconf. It's quite interesting that D's concept of r-values seems less developed

const ref parameters and r-value references

2014-05-02 Thread Mark Isaacson via Digitalmars-d-learn
I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) { //Stuff } unittest { fun(5); //Error! Does not compile } I get the specified error in my unit test. I understand that

Re: const ref parameters and r-value references

2014-05-02 Thread via Digitalmars-d-learn
On Friday, 2 May 2014 at 08:17:09 UTC, Mark Isaacson wrote: I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) { //Stuff } unittest { fun(5); //Error! Does not compile } I

Re: const ref parameters and r-value references

2014-05-02 Thread Mark Isaacson via Digitalmars-d-learn
Auto ref parameters seem to be just what I need. Thanks! I'd still be curious if anyone has additional information regarding the rationale at play (I'm spoiled, reading TDPL and having each decision explained in text).

Re: const ref parameters and r-value references

2014-05-02 Thread Meta via Digitalmars-d-learn
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote: Auto ref parameters seem to be just what I need. Thanks! I'd still be curious if anyone has additional information regarding the rationale at play (I'm spoiled, reading TDPL and having each decision explained in text). The C++ way