Suggestion: Allow Multiple Inheritance and still preserver super() functionality

Simen Kjaeraas simen.kjaras at gmail.com
Sat Mar 8 09:07:56 PST 2008


On Fri, 07 Mar 2008 04:40:54 +0100, Mike Parker <aldacron71 at yahoo.com>  
wrote:

> Jim Gadrow wrote:
>
>>  I will first state that I don't like the super() function because I  
>> don't believe the keyword 'super' very clearly identifies what is going  
>> on. wouldn't parent() have been more suitable?
>
> The term 'superclass' is more common in the OOP vernacular than 'parent  
> class', so super() is spot on, IMO. You'll find the same used in Java  
> and probably some other languages.
>
> Using 'parent()' would almost certainly cause some consternation among  
> some D users, since the terms 'parent' and 'child' are often used to  
> describe relationships in data structures. It's not uncommon to see  
> methods like parent() (or getParent()) to fetch a parent node in a tree.


In Object Pascal, the keyword for calling methods from the parent (super)  
class is 'inherited'.


//-------

   Foo = class
     procedure doStuff();
   end;

   Bar = class(Foo)
     procedure doStuff(); overload;
   end;

...

procedure Foo.doStuff();
begin
   // code here
end;

procedure Bar.doStuff();
begin
   inherited();
   inherited doStuff(); // equivalent to above line, calls parent.doStuff();
   // code here
end;

//-------

I'm not saying I'm for including 'inherited' in D - 'super' fits me  
perfectly. It may be clearer what it does than 'super' or 'parent', though.

-- Simen



More information about the Digitalmars-d mailing list