June 09, 2015
On 9 June 2015 at 08:58, bitwise via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Mon, 08 Jun 2015 16:17:33 -0400, Namespace <rswhite4@gmail.com> wrote:
>
>> Yes, the same goes for Dgame.
>
>
> closed-source projects can also accept rvalue-refs now ;)

How?
June 09, 2015
On Mon, 08 Jun 2015 22:16:27 -0400, Manu via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

> On 9 June 2015 at 08:58, bitwise via Digitalmars-d
> <digitalmars-d@puremagic.com> wrote:
>> On Mon, 08 Jun 2015 16:17:33 -0400, Namespace <rswhite4@gmail.com> wrote:
>>
>>> Yes, the same goes for Dgame.
>>
>>
>> closed-source projects can also accept rvalue-refs now ;)
>
> How?

I mean that if this is implemented, your code doesn't have to be a template to use 'auto ref', so the code won't show up in a .di file.

  Bit
June 09, 2015
On Monday, 8 June 2015 at 22:58:15 UTC, bitwise wrote:
> On Mon, 08 Jun 2015 16:17:33 -0400, Namespace <rswhite4@gmail.com> wrote:
>
>> Yes, the same goes for Dgame.
>
> closed-source projects can also accept rvalue-refs now ;)
>
>   Bit

Dgame is not closed-source. ;)
June 09, 2015
Apologies if I've missed something - I haven't had much time to keep up with the discussions lately.

What is the use case for rvalue references in a garbage-collected language?

To me, it sounds like people want this feature for D purely because C++ has it.

Stewart.

-- 
My email address is valid but not my primary mailbox and not checked regularly.  Please keep replies on the 'group where everybody may benefit.
June 09, 2015
On Tuesday, 9 June 2015 at 11:04:43 UTC, Stewart Gordon wrote:
> Apologies if I've missed something - I haven't had much time to keep up with the discussions lately.
>
> What is the use case for rvalue references in a garbage-collected language?
>
> To me, it sounds like people want this feature for D purely because C++ has it.
>
> Stewart.

What does this have to do with "garbage-collected language"?
If I have a big struct, e.g.
----
struct Matrix {
    float[16] values = [...];
}
----
I always want to pass it by ref because a move or a copy would be too slow.
June 09, 2015
On Monday, 8 June 2015 at 20:16:13 UTC, bitwise wrote:
> static Mat4 transform()(const auto ref Vec3 pos, const auto ref Vec3 scale, const auto ref Quat rot);

Horrific.

static Mat4 transform(in Vec3 pos, in Vec3 scale, in Quat rot);

would be so much better...
June 09, 2015
On 6/9/15 8:14 AM, Namespace wrote:
> On Tuesday, 9 June 2015 at 11:04:43 UTC, Stewart Gordon wrote:
>> Apologies if I've missed something - I haven't had much time to keep
>> up with the discussions lately.
>>
>> What is the use case for rvalue references in a garbage-collected
>> language?
>>
>> To me, it sounds like people want this feature for D purely because
>> C++ has it.
>>
>> Stewart.
>
> What does this have to do with "garbage-collected language"?
> If I have a big struct, e.g.
> ----
> struct Matrix {
>      float[16] values = [...];
> }
> ----
> I always want to pass it by ref because a move or a copy would be too slow.

It's actually faster to pass an rvalue by value, because it's constructed on the stack anyway.

The real reason for this I think is to avoid building multiple functions that have identical implementation.

-Steve
June 09, 2015
On Tue, 09 Jun 2015 08:26:46 -0400, kink <noone@nowhere.com> wrote:

> On Monday, 8 June 2015 at 20:16:13 UTC, bitwise wrote:
>> static Mat4 transform()(const auto ref Vec3 pos, const auto ref Vec3 scale, const auto ref Quat rot);
>
> Horrific.
>
> static Mat4 transform(in Vec3 pos, in Vec3 scale, in Quat rot);
>
> would be so much better...

How do you figure?

  Bit
June 09, 2015
On Tue, 09 Jun 2015 07:04:36 -0400, Stewart Gordon <smjg_1998@yahoo.com> wrote:

> Apologies if I've missed something - I haven't had much time to keep up with the discussions lately.
>
> What is the use case for rvalue references in a garbage-collected language?
>
> To me, it sounds like people want this feature for D purely because C++ has it.
>
> Stewart.
>


If you have a function that takes a huge struct, like, as Namespace says, containing a float[16], you would want to pass by reference.

Currently, given the following code,

struct Mat4 {
    float elements[16];
}

void TakeMatrix(ref Mat4 m) { }

Then you must use it like this:

Mat4 tmp = Mat4();
TakeMatrix(tmp);

With r-value references(auto ref), you can do the following, and 'tmp' will be 'auto'matically created for you:

TakeMatrix(Mat4());

  Bit
June 09, 2015
On Tue, 09 Jun 2015 07:04:36 -0400, Stewart Gordon <smjg_1998@yahoo.com> wrote:
> To me, it sounds like people want this feature for D purely because C++ has it.
>
> Stewart.

That's actually not a bad reason ;)

Suppose we wanted to write bindings for some C++ code which made use of const-ref parameters:
http://help.autodesk.com/view/FBX/2015/ENU/?guid=__cpp_ref_class_fbx_a_matrix_html


  Bit