inheriting ctors?

2010-08-05 Thread dcoder
Suppose I have a base class with many ctors(). I want to inherit from the base class and make one slight alteration to it, but I don't want to write X times the following: this(args) { super(args); } Does D have an easy way for the derived class to 'inherit' all or some of the base class ctors

Re: inheriting ctors?

2010-08-05 Thread Steven Schveighoffer
On Thu, 05 Aug 2010 13:53:20 -0400, dcoder wrote: Suppose I have a base class with many ctors(). I want to inherit from the base class and make one slight alteration to it, but I don't want to write X times the following: this(args) { super(args); } Does D have an easy way for the deriv

Re: inheriting ctors?

2010-08-05 Thread Simen kjaeraas
dcoder wrote: Suppose I have a base class with many ctors(). I want to inherit from the base class and make one slight alteration to it, but I don't want to write X times the following: this(args) { super(args); } Does D have an easy way for the derived class to 'inherit' all or some

Re: inheriting ctors?

2010-08-05 Thread Sean Kelly
Steven Schveighoffer Wrote: > On Thu, 05 Aug 2010 13:53:20 -0400, dcoder wrote: > > > Suppose I have a base class with many ctors(). > > > > I want to inherit from the base class and make one slight alteration to > > it, > > but I don't want to write X times the following: > > > > this(args) {

Re: inheriting ctors?

2010-08-06 Thread Rory Mcguire
Sean Kelly wrote: > Steven Schveighoffer Wrote: > >> On Thu, 05 Aug 2010 13:53:20 -0400, dcoder wrote: >> >> > Suppose I have a base class with many ctors(). >> > >> > I want to inherit from the base class and make one slight alteration to >> > it, >> > but I don't want to write X times the fol

Re: inheriting ctors?

2010-08-06 Thread Philippe Sigaud
On Fri, Aug 6, 2010 at 11:43, Rory Mcguire wrote: > I've been trying to make a template for this but it seems that dmd still > won't allow me to get the parameters of the constructors. dmd Seems to > think > that I'm trying to use it as a property. > > > void main() { >foreach (m; __traits(

Re: inheriting ctors?

2010-08-06 Thread bearophile
Philippe Sigaud: > This is my new once-a-day bug :( Add them all to Bugzilla :-) Bye, bearophile

Re: inheriting ctors?

2010-08-06 Thread Philippe Sigaud
On Fri, Aug 6, 2010 at 19:09, bearophile wrote: > Philippe Sigaud: > > This is my new once-a-day bug :( > > Add them all to Bugzilla :-) > I do, from time to time. But I'm never sure if it's a bug or not. It's related to The Great And Neverending Property Debate (tm). So I don't what to believe

Re: inheriting ctors?

2010-08-06 Thread Rory Mcguire
Philippe Sigaud wrote: > On Fri, Aug 6, 2010 at 11:43, Rory Mcguire > wrote: > > >> I've been trying to make a template for this but it seems that dmd still >> won't allow me to get the parameters of the constructors. dmd Seems to >> think >> that I'm trying to use it as a property. >> >> > >>

Re: inheriting ctors?

2010-08-06 Thread Rory Mcguire
Rory Mcguire wrote: > Philippe Sigaud wrote: > >> On Fri, Aug 6, 2010 at 11:43, Rory Mcguire >> wrote: >> >> >>> I've been trying to make a template for this but it seems that dmd still >>> won't allow me to get the parameters of the constructors. dmd Seems to >>> think >>> that I'm trying to

Re: inheriting ctors?

2010-08-06 Thread Rory Mcguire
dcoder wrote: > Suppose I have a base class with many ctors(). > > I want to inherit from the base class and make one slight alteration to > it, but I don't want to write X times the following: > > this(args) { > super(args); > } > > Does D have an easy way for the derived class to 'inherit'

Re: inheriting ctors?

2010-08-06 Thread Philippe Sigaud
On Fri, Aug 6, 2010 at 21:59, Rory Mcguire wrote: > > Here is a possible solution to your problem: > > -Rory I believe you can get the type of A. Isn't it typeof(super) or std.traits.BaseClassesTuple!B[0] ? B in the latter case being typeof(this) That way, there is no need for the user to provi

Re: inheriting ctors?

2010-08-06 Thread Andrej Mitrovic
There is an AutoImplement class template in http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#AutoImplement , which I've just been trying out. Apparently you can pass it 1: a Base class, 2: a templated function to filter out which functions you want to inherit/overwrite from the Base cl

Re: inheriting ctors?

2010-08-06 Thread Andrej Mitrovic
Here's an example: import std.stdio; import std.traits; import std.conv; import std.typecons; class C { int m_value; int testMe() { return 1; } this(int x) { m_value = x; } this(int x, int z) { m_value = x + z; } }

Re: inheriting ctors?

2010-08-07 Thread div0
On 06/08/2010 22:57, Andrej Mitrovic wrote: // Offtopic Template errors are so hard to grasp, most of the time it's best to just ignore them and take some logical steps to fix the errors. At least that's in my case true.. lol, that's true. I've been basing out c++ & d template code for years

Re: inheriting ctors?

2010-08-09 Thread Rory Mcguire
Philippe Sigaud wrote: > On Fri, Aug 6, 2010 at 21:59, Rory Mcguire > wrote: > >> >> Here is a possible solution to your problem: >> >> -Rory > > > I believe you can get the type of A. Isn't it typeof(super) or > std.traits.BaseClassesTuple!B[0] ? B in the latter case being typeof(this) > That

Re: inheriting ctors?

2010-08-09 Thread Rory Mcguire
I had been trying to use AutoImplement to make something before but it gave me weird errors. I'm going to try using it for implementing "this" when I get some time. Andrej Mitrovic wrote: > Here's an example: [snip]

Re: inheriting ctors?

2010-08-09 Thread Rory Mcguire
Thanks for suggestion Andrej Mitrovic wrote: > Here's an example: [snip]