On Friday, 3 June 2016 at 15:03:45 UTC, ag0aep6g wrote:
On 06/03/2016 04:34 PM, John Nixon wrote:
import std.stdio;
import std.container;
struct CS{
char[] t;
CS dup()const{
CS cs;
cs.t = this.t.dup;
return cs;}
};
Aside: No semicolon after struct declarations in D.
I recently came across another problem with my program in D,
found a minimal program showing it, and experimented a little
with it as follows:
import std.stdio;
import std.container;
struct CS{
char[] t;
CS dup()const{
CS cs;
cs.t = this.t.dup;
return cs;}
};
void main(){
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.
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 {
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.
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
On Friday, 24 April 2015 at 17:45:49 UTC, Steven Schveighoffer
wrote:
On 4/24/15 1:20 PM, John Nixon wrote:
I am using dmd v2.067.0 on Mac OSX with Terminal and I found
the lack of
line numbers surprising.
Is there something simple I am doing wrong? Do any of the
switches on
the command line
I am using dmd v2.067.0 on Mac OSX with Terminal and I found the
lack of line numbers surprising.
Is there something simple I am doing wrong? Do any of the
switches on the command line do this?
BTW I only found out about D a couple of weeks back. It seems to
be very impressive!
John Nixon