Re: DIP1004: Inherited Constructors
On 11/29/2016 12:04 PM, Arafel wrote: > 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)? Have just answered a similar question in a PR thread: https://github.com/dlang/DIPs/pull/42#issuecomment-263562276 signature.asc Description: OpenPGP digital signature
Re: DIP1004: Inherited Constructors
On 11/28/2016 04:57 AM, rikki cattermole wrote: > On 28/11/2016 3:38 PM, 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. > > A few errors like this are in it: > > class ParseException : Exception { } > { Would you mind a PR? :) I am afraid my eyes are too sloppy after re-reading the text too many times. signature.asc Description: OpenPGP digital signature
Re: DIP1004: Inherited Constructors
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)?
Re: DIP1004: Inherited Constructors
On 28/11/2016 3:38 PM, 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. A few errors like this are in it: class ParseException : Exception { } {