(first post to Stack Overflow so maybe I didn't post where/how I should, sorry)
TL;DR : How do I make this specific inheritance scheme in R6 :
MOTHER (MOTHER is a virtual class)
/ | \
/ | \
/ | \
/ | \
Daughter1 Son Daughter2 (Son is a virtual class)
\ / \ /
\ / \ /
\ / \ /
\ / \ /
Incest1 Incest2 (Incestuous but no diamond issues)
The same scheme is available is S4, I did it and I'm actually trying to convert my S4 classes to references R6 ones. But the documentations on R6 classes is not that big, and I can't find how to do it.
If that's not possible, I'm going to have to duplicate a lot of code, i.e. all methods from "Son", and I don't want to do that.
I've called the last 2 classes Incest to joke, but I'm serious : I got no diamond issue here, the methods provided by the Daughter's and the Son are not the same at all.
If you think about an other scheme that could work to replace this one, I'd love to hear it : The MOTHER and Son Classes are VIRTUAL ( which is not really doable in R6 right? but I don't care), so maybe I'm not thinking the inheritance issue as it should be.
Thx for the help.
** EDIT : **
Ok I've found a solution. Since Incest's are fully functional Son's and Daughter's (since they ARE sons and daughters), when not just re-build the multiple inheritance mechanism in them ? That is :
1° For every function that Son's don't have and need to inherit, build a wrapper method with the same name in son where you call a generic coercice() method.
2° The coercise method just does what R6 should do : it initialize a "Son" element and a "Daughter" element, and check for both of them is the method that we passed as argument exist. If it does for only one, let's go they call it with this coercised Incest that's now a Son or a daughter. If both implement it, it yells at me (but it could do something else !)
It's very ugly, but it work and does what I wanted to do.
Actually, it's not that ugly, it's just implementing something that should be. Do you think this could have been done a better way?