On Monday, 28 November 2016 at 02:38:00 UTC, Dicebot wrote:
DIP 1004 is merged to the queue and open for public informal
feedback.
PR: https://github.com/dlang/DIPs/pull/42
Initial merged document:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1004.md
If you want the change to be approved and have ideas how to
improve it to better match on
https://github.com/dlang/DIPs/blob/master/GUIDELINES.md and
existing published reviews - please submit new PR with
editorial and ping original author.
I think I might be a bit late to the party, and I'm still quite
new in D... but wouldn't a variadic template constructor work?
The usual rules of templates would still let you override a
constructor if needed.
---
class A {
this() { }
this(int a) { }
}
class B : A {
// Here we inherit all of A's constructors.
this(Args...)(Args args) {
super(args);
}
this(string s) { }
}
void main() {
B b1 = new B(42);
B b2 = new B("foo");
}
---
I've been playing with it, and the only problems I can see are
with specialization and casting (i.e. B defines this(float), but
you want to call A's this(int), the int will be promoted to float
and B's version will be used). A way of disabling them would be
needed, though... perhaps assert(0)?