Re: DIP 1016 and const ref parameters

2019-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: Aside from looking through the newsgroup/forum for discussions on DIPs, that's pretty much all you're going to find on that. Andrei's talk is the most up-to-date information that we have about this particular DIP. The prel

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Thursday, 20 June 2019 at 00:30:35 UTC, Jonathan M Davis wrote: Ultimately, if you want a function to accept both rvalues and lvalues as efficiently as posible, just templatize it and use auto ref. I'm aware of auto ref, and I've used it to solve this same problem when I had a template,

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 19, 2019 4:45:04 PM MDT XavierAP via Digitalmars-d-learn wrote: > On Wednesday, 19 June 2019 at 21:06:48 UTC, XavierAP wrote: > > Now with an rvalue returned from get, interesting, no copy. > > Still, I wonder what really happened. Again, moving between > > stacks would still be

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Les De Ridder via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 20:18:58 UTC, Max Haughton wrote: On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via Digitalmars-d-learn wrote: [...] The DIPs are here: https://github.com/dlang/DIPs [...] DIP1014 has n

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 21:06:48 UTC, XavierAP wrote: Now with an rvalue returned from get, interesting, no copy. Still, I wonder what really happened. Again, moving between stacks would still be work. And a different optimization can explain this non copy, for example inlining. My gu

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
Hmmm I know about move semantics, and C++11 etc. I just don't know how related all that is to my original question. :) On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: though if I understand correctly with RVO, it may just place the return value outside of the function in th

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via Digitalmars-d-learn wrote: [...] The DIPs are here: https://github.com/dlang/DIPs [...] DIP1014 has not been implemented in DMD or druntime yet, AFAIK

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via Digitalmars-d-learn wrote: > On Wednesday, 19 June 2019 at 12:55:09 UTC, Jonathan M Davis > > wrote: > > Even in C++, using const ref is not as good a practice as it > > once was, because they added move constructors, finally making > > obje

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 12:55:09 UTC, Jonathan M Davis wrote: Even in C++, using const ref is not as good a practice as it once was, because they added move constructors, finally making object moveable. The result is that in many cases, it's actually more efficient to just copy values i

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 19, 2019 6:33:44 AM MDT XavierAP via Digitalmars-d-learn wrote: > I often use a pattern of having const ref struct parameters (as > in C++) but this doesn't work in the case of rvalues. The > workaround of defining an overload that calls its own name is > terrible. I understand