Re: Do I have to pass parameters with ref explicitly?

2022-04-17 Thread Elfstone via Digitalmars-d-learn
Thanks Ali. That's a lot of information. I'm learning D by rewriting my hobbyist project. I guess I can worry about optimization later. On Sunday, 17 April 2022 at 08:45:11 UTC, Ali Çehreli wrote: - Somewhat related, unlike C++, D does not allow binding rvalues to 'const ref'. (This point is

Re: Do I have to pass parameters with ref explicitly?

2022-04-17 Thread Ali Çehreli via Digitalmars-d-learn
On 4/17/22 01:45, Ali Çehreli wrote: > In D, if it > is an input to a function, then mark it as 'in' and the compiler will do > some magic: > >https://dlang.org/spec/function.html#in-params I should have remembered that there are some improvements coming for -preview=in as reported by

Re: Do I have to pass parameters with ref explicitly?

2022-04-17 Thread Ali Çehreli via Digitalmars-d-learn
On 4/16/22 21:56, Elfstone wrote: > On Sunday, 17 April 2022 at 04:00:19 UTC, max haughton wrote: >> On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote: >>> I'm reading some d-sources, and it looks like they pass big structs >>> by value. >>> Such as: >>> >>> Matrix4x4f opBinary(string

Re: Do I have to pass parameters with ref explicitly?

2022-04-16 Thread Elfstone via Digitalmars-d-learn
On Sunday, 17 April 2022 at 04:00:19 UTC, max haughton wrote: On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote: I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++

Re: Do I have to pass parameters with ref explicitly?

2022-04-16 Thread max haughton via Digitalmars-d-learn
On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote: I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++ background, and I would have written: Matrix4x4f opBinary(string

Do I have to pass parameters with ref explicitly?

2022-04-16 Thread Elfstone via Digitalmars-d-learn
I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++ background, and I would have written: Matrix4x4f opBinary(string op)(const ref Matrix4x4f rhs) { ... } I haven't found