Multiple Inheritance of Classes

superdan super at dan.org
Wed Aug 13 07:57:14 PDT 2008


Steven Schveighoffer Wrote:

> "superdan" wrote
> > Lars Ivar Igesund Wrote:
> >
> >> Chris R. Miller wrote:
> >>
> >> > Understand, I'm NOT demanding ANYTHING.
> >> >
> >> > What is the current state of thought about Multiple Inheritance for
> >> > classes in D?  I'd like to have that feature, since it'd make some 
> >> > stuff
> >> > I want to do a bit easier.  Is it not there because it's not worth the
> >> > effort to implement?  Because it's evil and needs to die (I don't know,
> >> > some people could possibly be adamantly anti-MI)?
> >>
> >> This is actually the reason, not the adamantly anti-MI part, just that MI 
> >> is
> >> evil and that is well acknowledged almost everywhere. You will find good
> >> argumentation against it if you look, too.
> >
> > appeal to authority. appeal to ridicule. appeal to the majority. all in 
> > one sentence. wow. at least could you space out your fallacies a bit more.
> >
> > the man has kindly asked a sensible question. he deserves a good answer. 
> > if u can't give one just don't reply. this is just ignorance.
> 
> This kind of bullying bullshit does nothing to further communication, or 
> help anyone in the least.  You've managed to call many of the brightest 
> developers for D idiots, usually based on useless crap like this (which has 
> no bearing on anything).  So shut the fuck up.

or what, u gonna kick my ass. relax. you can always block me. (but hold onto that a bit more. dee's plea is just too cool.) my post did further communication. it exposed the hackneyed "mi is evil" shit... i mean poop. (damn.) it may have helped someone. you know what i like about walter. when he doesn't know something he is open in admitting it. for that alone i'd wash his feet. i didn't call the poster any name. but that particular post was bull... i mean crap and i just said it. the fact that the post sucked bears nothing on the fact that he's good or anything. even worse, if he's good then why would he use his goodwill to get away with statements like that. they only reveal ignorance and attempt at continuing ignorance because it puts a stigma on anyone investigating mi. it's silly we need to still talk about it. now shall we just move on to something technical.

> > below's an attempt at an answer.
> 
> Good answer.
> 
> > interfaces could implement functions. that does make a lot of sense. 
> > example:
> >
> > interface Customer
> > {
> >    string ssn();
> >    string name();
> >    string uniqueName() { return name ~ "(ssn: " ~ ssn ~ ")"; }
> > }
> >
> > so uniqueName formats a specific way. a descendant can choose to change 
> > that or just use the default. no idea why walt chose to disallow that. 
> > walt?
> 
> What do you pass as the 'this' pointer?  When you call a function on an 
> interface, the compiler uses the offset of an interface to the 'this' 
> pointer to get to the object, but in this case, there is no object, so what 
> does the compiler do to call the ssn() and name() functions while 
> implementing this function?

i'm unclear about this so maybe it ain't as easy as i thought. but i'm thinking the same problem goes for the global

string uniqueName(Customer c) { return c.name ~ "(ssn: " ~ c.ssn ~ ")"; }

a pointer to this function should be put in the vtable if the object does not implement it. 

> If you pass the interface pointer as the 'this' pointer, then how do you 
> override it in an Object that implements the interface?  The function in the 
> concrete class can't be passed the interface pointer, so you can't really 
> override it.

that pretty much kills what i wrote above eh. but thunking will take care of it. if there's no impl in an object put a pointer to a thunk that adjusts the pointer (from obj to interface) and calls the default impl with the adjusted pointer. the latter is a direct call which makes it fast.

> One possible solution is to mark uniqueName as 'final', which means it 
> cannot be overridden.  Then you can safely pass the interface pointer to the 
> function (casting to the interface if necessary).  This might be a handy 
> thing when you always want to implement the same function in all concrete 
> classes in terms of the interface functions.

that would be cool too. i recall people suggested that here before.



More information about the Digitalmars-d mailing list