What is the order of resolution for super() calls?

2015-08-05 Thread cym13 via Digitalmars-d-learn

Hi,

I just read 
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ which describes how super works in python (tl;dr: it's completely different from C++, java or D's super but super cool to deal with multiple inheritance).


For example, for the following inheritance tree:

  Object
/\
AdamEve
|   \/   |
| X |
 \   /   \  /
   Abel   Cain
 \   /
   David

A call in David making use of super would in python go through 
classes in that order:   Abel, Cain, Adam, Eve, Object.  This is 
somewhat peculiar as we don't expect the call of super() in Abel 
to go to Cain just because the initiator was David but that's 
what happens and it is deterministic (I recommend the article to 
see why it is so).


What would be the order in D? Would it be something like:
 Abel
 Adam
 Object
 Eve
 Cain
 (Adam?)
 (Eve?)
 (Object?)



Re: What is the order of resolution for super() calls?

2015-08-05 Thread cym13 via Digitalmars-d-learn
Forget it, I just remembered that we only do single inheritance, 
and I don't think the same problem occurs with interfaces.


For reference, as the diagram was unreadable, I'll describe it 
here:


class Adam ;
class Eve ;
class Abel:Adam,Eve ;
class Cain:Adam,Eve ;
class David:Abel,Cain ;



Re: What is the order of resolution for super() calls?

2015-08-05 Thread anonymous via Digitalmars-d-learn

On Wednesday, 5 August 2015 at 12:32:48 UTC, cym13 wrote:
For reference, as the diagram was unreadable, I'll describe it 
here:


class Adam ;
class Eve ;
class Abel:Adam,Eve ;
class Cain:Adam,Eve ;
class David:Abel,Cain ;


This is illegal D. You must use interfaces to simulate multiple 
inheritance:


D classes support the single inheritance paradigm, extended by 
adding support for interfaces.


see more here: http://dlang.org/class.html