digitalmars.D.bugs - [Issue 3438] New: constructor with defaulted parameters ignored
- d-bugmail puremagic.com Oct 23 2009
- d-bugmail puremagic.com Nov 09 2009
- d-bugmail puremagic.com Nov 10 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3438 Summary: constructor with defaulted parameters ignored Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrei metalanguage.com --- Comment #0 from Andrei Alexandrescu <andrei metalanguage.com> 2009-10-23 07:44:31 PDT --- struct foo { this(int dummy = 0) { writeln("Default constructor");} } void main() { foo x = foo(); } does not print anything. The code should either not compile or print something. I think at some point we'll need to support default constructors that execute code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3438 Eldar Insafutdinov <e.insafutdinov gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |e.insafutdinov gmail.com --- Comment #1 from Eldar Insafutdinov <e.insafutdinov gmail.com> 2009-11-09 13:18:26 PST --- I would also like to have default struct constructors implemented. So I give a vote to this one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 09 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3438 --- Comment #2 from Eldar Insafutdinov <e.insafutdinov gmail.com> 2009-11-10 22:39:12 PST --- To add a point, by default constructor should be invoked if present. There may be some reasons to keep a way to create an uninitialized struct(yeah, D is a systems language), but it should be done explicitly. Now we have an opposite situation, where by default struct is not initialized, and if you want to, you can define static opCall like in D1(what an ugly hack!) and call it manually. I have the real word example for that as well. I am porting Qt container classes to D. They are value types with Copy on Write semantics and atomic reference counting. They need some initialization (reference increment) when constructed. So basically if I write something like this: QList!int a; It would not be a valid code. So I have to do auto a = QList!int(); That is annoying, unsafe(I would have write something in the docs: always initialize with static opCall!) and not consistent with other value types. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 10 2009









d-bugmail puremagic.com 