Re: full copies on assignment

2016-05-29 Thread John Nixon via Digitalmars-d-learn
On Friday, 27 May 2016 at 08:59:43 UTC, Marc Schütz wrote: Yes indeed it does. Thanks. Something in my version must have been different.

Re: full copies on assignment

2016-05-27 Thread Marc Schütz via Digitalmars-d-learn
On Thursday, 26 May 2016 at 10:51:30 UTC, John Nixon wrote: On Wednesday, 25 May 2016 at 15:44:34 UTC, Marc Schütz wrote: On Tuesday, 24 May 2016 at 20:58:11 UTC, John Nixon wrote: On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John

Re: full copies on assignment

2016-05-26 Thread John Nixon via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 15:44:34 UTC, Marc Schütz wrote: On Tuesday, 24 May 2016 at 20:58:11 UTC, John Nixon wrote: On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: Or add an explicit constructor: struct CS {

Re: full copies on assignment

2016-05-25 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 20:58:11 UTC, John Nixon wrote: On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the

Re: full copies on assignment

2016-05-24 Thread John Nixon via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the char[] being shallow copied still leads to mutable stuff.

Re: full copies on assignment

2016-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the char[] being shallow copied still leads to mutable stuff. What I typically do here is just add a method `dup` to the

full copies on assignment

2016-05-24 Thread John Nixon via Digitalmars-d-learn
1 import std.stdio; 2 3 struct CS{ 4 char[] t; 5 CS opAssign(const CS rhs){ 6 writeln("CS.opAssign called"); 7 this.t = rhs.t.dup; 8 return this;} 9 }; 10 void test_fun(const ref CS rhs){ 11 CS cs = rhs;//error cannot implicitly convert expression (rhs) of