Re: A simplification of the RvalueRef idiom

2016-11-27 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 25 November 2016 at 17:21:52 UTC, Nick Treleaven wrote: I've started documenting it now, will post a PR soon. https://github.com/dlang/dlang.org/pull/1519

Re: A simplification of the RvalueRef idiom

2016-11-25 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:35:39 UTC, TheGag96 wrote: The thing that gets me more is "return" as a function attribute. I see it under "MemberFunctionAttribute" in the grammar but I can't find an explanation for its use anywhere... I've started documenting it now, will post a PR soon.

Re: A simplification of the RvalueRef idiom

2016-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 24, 2016 00:35:39 TheGag96 via Digitalmars-d-learn wrote: > On Tuesday, 22 November 2016 at 13:06:27 UTC, Nordlöw wrote: > > On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: > >> mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER > >> ANY MORE > >>

Re: A simplification of the RvalueRef idiom

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:35:39 UTC, TheGag96 wrote: The thing that gets me more is "return" as a function attribute. I see it under "MemberFunctionAttribute" in the grammar but I can't find an explanation for its use anywhere... YOU ARE NOT SUPPOSED TO KNOW THIS. DON'T LIVE YOUR PLA

Re: A simplification of the RvalueRef idiom

2016-11-23 Thread TheGag96 via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 13:06:27 UTC, Nordlöw wrote: On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER ANY MORE { alias T = typeof(this); static assert (is(T == struct)); @nogc @safe ref const(

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 22:03:14 UTC, Satoshi wrote: or I have simple class class View { this(Rectangle frame) {...} this(float, float, float, float) { ... } this(Point, Size) { ... } } then struct Point, Size and Rectangle (Point, Size) now I need to write 2 overloads for View class t

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 16:05:35 UTC, Satoshi wrote: Sorry, but D seems to be worse and worse day by day. This should be resolved by language and not doing it by template function. Same thing should be applied for maybe monad and tuples. I'm reminded of trying to follow the rules and

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 16:57:28 UTC, kink wrote: I hate this 'idiom' too (just a clumsy workaround for something that should work out of the box), but the non-bindability of rvalues to ref params and the associated dispute is veeery old, nothing new, so I don't agree that the languag

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
or I have simple class class View { this(Rectangle frame) {...} this(float, float, float, float) { ... } this(Point, Size) { ... } } then struct Point, Size and Rectangle (Point, Size) now I need to write 2 overloads for View class taking 4 floats or (Point, Size) and this must do in every des

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 19:16:56 UTC, Ali Çehreli wrote: On 11/22/2016 08:05 AM, Satoshi wrote: I don't have extensive experience with other languages. In fact, the only other languages that I can claim proficiency are C and C++. (I also know Python just enough to find it incredible

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Ali Çehreli via Digitalmars-d-learn
On 11/22/2016 08:05 AM, Satoshi wrote: > Sorry, but D seems to be worse and worse day by day. I don't have extensive experience with other languages. In fact, the only other languages that I can claim proficiency are C and C++. (I also know Python just enough to find it incredible how it's use

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread kink via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 16:05:35 UTC, Satoshi wrote: Sorry, but D seems to be worse and worse day by day. This should be resolved by language and not doing it by template function. I hate this 'idiom' too (just a clumsy workaround for something that should work out of the box), but th

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: First, a reminder that we have this great resource of D idioms: https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it The link above has an idiom of mixing in a byRef() member function

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: Let me know if it's not the equivalent of the original. Ali I've changed the idiom, thanks. The place to discuss this is the d-idioms bugtracker, else I would have skipped this message.

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Namespace via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 13:06:27 UTC, Nordlöw wrote: On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER ANY MORE { alias T = typeof(this); static assert (is(T == struct)); @nogc @safe ref const(

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Nordlöw via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: ref const(T) byRef() const pure nothrow return Add when DIP-1000 has been implemented into compiler this should be `scope`-qualified aswell, right?

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Ali Çehreli via Digitalmars-d-learn
On 11/22/2016 05:06 AM, Nordlöw wrote: On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER ANY MORE { alias T = typeof(this); static assert (is(T == struct)); @nogc @safe ref const(T) byRef() const pure n

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Nordlöw via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER ANY MORE { alias T = typeof(this); static assert (is(T == struct)); @nogc @safe ref const(T) byRef() const pure nothrow return Why do you need to qual

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Nordlöw via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: Let me know if it's not the equivalent of the original. Ali Nice. What about putting this in a druntime or phobos PR, making it standardized?

A simplification of the RvalueRef idiom

2016-11-21 Thread Ali Çehreli via Digitalmars-d-learn
First, a reminder that we have this great resource of D idioms: https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it The link above has an idiom of mixing in a byRef() member function to a struct. I think I've simplified the template by moving typeo