https://d.puremagic.com/issues/show_bug.cgi?id=3878
--- Comment #13 from [email protected] 2013-11-26 04:57:12 PST --- (In reply to comment #12) > In reply to the original report, I disagree that this is a significant issue, > in fact I'll often deliberately name a parameter the same as a member. > > struct S { > int m; > this(int m) { this.m = m; } > } Thank you for the answer. From my experience that code is very bug prone, I have found various bugs in code like that. I am not the only D programmer to hit such problem. Two alternative solutions: 1) To allow to refer to the instance fields in the constructor signature, so you don't need to repeat names (something like this is present in Scala and Typescript): class S { int m; this(in this.m) {} } 2) Require the usage of "this." in constructors, so you have to write this: struct S { int m; this(int m) { this.m = m; } } The problem is not just about constructors, but they are typically the ones where you initialise most instance members using arguments, so it's where I had my bugs. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
