On 13/04/22 8:29 am, Steven D'Aprano wrote:
When multiple parent provide candidate to a method resolution, raise an error.

Then you aren't doing full MI any more,

That sounds like a "true Scotsman" argument. Who defines what
"full MI" means?

I can think of at least two languages that do something very
similar to what malmalitia is proposing: C++ and (if I remember
rightly) Eiffel. I don't think I've heard anyone claim that
C++ doesn't do "full MI".

Here's a C++ example:

#include <stdio.h>

class A {
  public:
    void f() {
      printf("f in A\n");
  }
};

class B {
  public:
    void f() {
      printf("f in B\n");
  }
};

class AB: virtual A, virtual B {
};

int main() {
  AB ab;
  ab.f();
}

and compiling it gives this:

mi.cpp:22:6: error: member 'f' found in multiple base classes of different types
  ab.f();
     ^
mi.cpp:5:10: note: member found by ambiguous name lookup
    void f() {
         ^
mi.cpp:12:10: note: member found by ambiguous name lookup
    void f() {
         ^
1 error generated.

--
Greg



 just a limited, restricted
version known as traits.


The child class now has to redefine the method, and in the body of that method, 
can decide which parent method call, or in what order call them.
That's essentially the basic idea of my proposal.
What makes this impossible for you?

Its not impossible, I have been telling you about traits since my
earliest posts in this thread.

Maybe you need to stop thinking you have invented some brilliant idea
which has solved a problem nobody else has noticed, and read some of the
Artima links I have days ago.


I think i've adressed most if not all problems i had raised against it.

Except the most important one: why are you using multiple inheritence
when you clearly don't want multiple inheritence, instead you want
delegation?


Linearisation is litterally an operation that consist into converting
a multiple inheritance tree into a simple inheritance tree.

That is absolutely not what linearization does.

That's bound to lose some info,

No, the point of linearization is to avoid losing info.


and can't cover all cases.

Correct, there are inconsistent inheritence hierarchy which are
impossible to linearise because they are inconsistent. It is better to
get an error when you try to define the inconsistent hierarchy, rather
than pretend it is consistent and then wonder why inheritence is not
working and methods are called in inconsistent order.



_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7RPZNLARFS5B6WXSQ5XIHMR2MPNO5UL5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to