[Issue 3438] constructor with defaulted parameters ignored

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 10 22:39:13 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3438



--- Comment #2 from Eldar Insafutdinov <e.insafutdinov at 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: -------


More information about the Digitalmars-d-bugs mailing list