Making inheritance less tedious

Kristian Kilpi kjkilpi at gmail.com
Fri Mar 9 07:40:37 PST 2007


On Mon, 26 Feb 2007 15:31:29 +0200, Kristian Kilpi <kjkilpi at gmail.com>  
wrote:
>
> I think class inheritance is a bit(?) tedious sometimes (that is,  
> unnecessarily tedious).
> (I leave interfaces out of this discussion.) 'Problems', IMHO, with it  
> are:
>
> 1) You cannot inherit constructors.
>
> 2) A function will hide inherited functions having the same name.
>
> 3) The syntax for calling a super function of the base class is  
> redundant and (could be) tedious.
>
[snip]
> What about the case 3? Well, lets have the following member function:
>
>    foo(int value, int x, int y, bool is_clipped, bool is_inverted,  
> string label = null) {
>      ...
>
>      super.foo(value, x, y, is_clipped, is_inverted, label);
>    }
>
> It would be nice to have the following possible:
>
>    foo(int value, int x, int y, bool is_clipped, bool is_inverted,  
> string label = null) {
>      ...
>
>      superfunc(..);  //equals to 'super.foo(value, x, y, is_clipped,  
> is_inverted, label);'
>    }
>
> 'superfunc(..)' (or 'superfunc($)' or something) is non-redundant, easy  
> to read, and
> trivial to maintain (because no maintenance is needed! :) ).
>
> You can of course define the arguments by yourself if needed:
>
>    superfunc(value + 1, x, y, false, is_inverted);


What, nobody voted for the case 3? I'm stunned. ;)

To me having 'superfunc' would be about as nice as having 'this' for  
ctors/dtors...
Lets put it this way: how many C++ person would switch back to use the  
class name in
the construtors and destructors instead of 'this'?



More information about the Digitalmars-d mailing list