Re: Efficiently passing structs

2015-05-06 Thread Ali Çehreli via Digitalmars-d-learn
On 05/06/2015 11:24 AM, Charles Hixson via Digitalmars-d-learn wrote: On 05/05/2015 11:49 AM, Ali Çehreli via Digitalmars-d-learn wrote: On 05/05/2015 07:14 AM, bitwise wrote: > I don't see how someone could arrive at the above > solution without showing up here and asking first. It was the

Re: Efficiently passing structs

2015-05-06 Thread Charles Hixson via Digitalmars-d-learn
On 05/05/2015 11:49 AM, Ali Çehreli via Digitalmars-d-learn wrote: On 05/05/2015 07:14 AM, bitwise wrote: > I don't see how someone could arrive at the above > solution without showing up here and asking first. It was the same with me. :) Then I wrote a short section about it: http://ddili.

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 18:58:34 -0400, Namespace wrote: On Tuesday, 5 May 2015 at 21:58:57 UTC, bitwise wrote: On Tue, 05 May 2015 17:33:09 -0400, Namespace wrote: I've discussed that so many times... just search for auto / scope ref... ;) It will never happen. See: http://forum.dlang.org

Re: Efficiently passing structs

2015-05-05 Thread Namespace via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 21:58:57 UTC, bitwise wrote: On Tue, 05 May 2015 17:33:09 -0400, Namespace wrote: I've discussed that so many times... just search for auto / scope ref... ;) It will never happen. See: http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1 http:/

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 18:27:54 -0400, Gomen wrote: I am sorry for this post, I am just testing something. The retired "D" forum seems to have been re-purposed for testing ;) Bit

Re: Efficiently passing structs

2015-05-05 Thread Gomen via Digitalmars-d-learn
I am sorry for this post, I am just testing something.

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 17:33:09 -0400, Namespace wrote: I've discussed that so many times... just search for auto / scope ref... ;) It will never happen. See: http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1 http://forum.dlang.org/thread/ylebrhjnrrcajnvtt...@forum.dlang

Re: Efficiently passing structs

2015-05-05 Thread Namespace via Digitalmars-d-learn
I've discussed that so many times... just search for auto / scope ref... ;) It will never happen. See: http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1 http://forum.dlang.org/thread/ylebrhjnrrcajnvtt...@forum.dlang.org?page=1 http://forum.dlang.org/thread/mailman.2989.13

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 11:54:53 -0400, Jonathan M Davis wrote: On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being pa

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 14:49:07 -0400, Ali Çehreli wrote: http://ddili.org/ders/d.en/lvalue_rvalue.html#ix_lvalue_rvalue.auto%20ref,%20parameter I've actually stumbled upon this site a few times, and it has been very helpful, so thanks =D Unfortunately though, I had no idea that "auto ref" wa

Re: Efficiently passing structs

2015-05-05 Thread Ali Çehreli via Digitalmars-d-learn
On 05/05/2015 07:14 AM, bitwise wrote: > I don't see how someone could arrive at the above > solution without showing up here and asking first. It was the same with me. :) Then I wrote a short section about it: http://ddili.org/ders/d.en/lvalue_rvalue.html#ix_lvalue_rvalue.auto%20ref,%20parame

Re: Efficiently passing structs

2015-05-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need for worrying about copying like

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 10:44:13 -0400, rsw0x wrote: On Tuesday, 5 May 2015 at 14:14:51 UTC, bitwise wrote: Interesting.. Has this always worked? Theres a couple of forum conversations about trying to get "auto ref" to work for non-templates. The main problem seems to be that auto ref wont work

Re: Efficiently passing structs

2015-05-05 Thread rsw0x via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 14:14:51 UTC, bitwise wrote: On Tue, 05 May 2015 00:20:15 -0400, rsw0x wrote: it does, auto ref can bind to both lvalues and rvalues. Create the function with an empty template like so, import std.stdio; struct S{ } void Foo()(auto ref S s){ } void main(){

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 00:20:15 -0400, rsw0x wrote: it does, auto ref can bind to both lvalues and rvalues. Create the function with an empty template like so, import std.stdio; struct S{ } void Foo()(auto ref S s){ } void main(){ S s; Foo(s); Foo(S()); } There might

Re: Efficiently passing structs

2015-05-04 Thread rsw0x via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need for worrying about copying like

Re: Efficiently passing structs

2015-05-04 Thread bitwise via Digitalmars-d-learn
On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need for worrying about copying like you tend to have to do in C++98, and I think that a lot

Re: Efficiently passing structs

2015-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 03, 2015 21:58:12 bitwise via Digitalmars-d-learn wrote: > If I have a large struct that needs to be passed around, like a 4x4 matrix > for example, how do I do that efficiently in D? > > In std.datetime, "in" is used for most struct parameters, but I'm confused > by the docs for fun

Re: Efficiently passing structs

2015-05-03 Thread rsw0x via Digitalmars-d-learn
On Monday, 4 May 2015 at 03:57:04 UTC, bitwise wrote: I'll probably go with "in ref". I think "escape proof" is probably a good default. Not to mention, easier to type ;) FYI I'm unsure how well `scope` storage class is currently implemented because it's in a state of flux at the moment as far

Re: Efficiently passing structs

2015-05-03 Thread bitwise via Digitalmars-d-learn
On Sun, 03 May 2015 22:37:52 -0400, rsw0x wrote: Use the ref storage class. You can use more than one storage class i.e, foo(in ref int x) Thanks, this should work. On Sun, 03 May 2015 23:29:59 -0400, Baz wrote: it's specified in http://dlang.org/abi.html (at the bottom): "out and ref are

Re: Efficiently passing structs

2015-05-03 Thread Baz via Digitalmars-d-learn
On Monday, 4 May 2015 at 01:58:12 UTC, bitwise wrote: The documentation doesn't say anything about "in" being a reference, but it doesn't say that "out" parameters are references either, even though it's usage in the example clearly shows that it is. Thanks, Bit http://dlang.org/function.h

Re: Efficiently passing structs

2015-05-03 Thread rsw0x via Digitalmars-d-learn
On Monday, 4 May 2015 at 01:58:12 UTC, bitwise wrote: If I have a large struct that needs to be passed around, like a 4x4 matrix for example, how do I do that efficiently in D? In std.datetime, "in" is used for most struct parameters, but I'm confused by the docs for function parameter storage

Efficiently passing structs

2015-05-03 Thread bitwise via Digitalmars-d-learn
If I have a large struct that needs to be passed around, like a 4x4 matrix for example, how do I do that efficiently in D? In std.datetime, "in" is used for most struct parameters, but I'm confused by the docs for function parameter storage classes[1]. In C++, I would pass a large struct as