2 ms·
> A point I make occasionally is that there needs to be a good way to find the owning object when you do that. Is there a language where, when B is a field of A
by formerly_proven 6y ago
> A point I make occasionally is that there needs to be a good way to find the owning object when you do that. Is there a language where, when B is a field of A, you can find A from B?
I've built this multiple times in Python in a few different ways. Metaclasses work (for e.g. declarative stuff, like in ORMs and data description), the descriptor protocol works for the runtime kind (caveats ensue).
> Multiple inheritance is usually a mistake.
Allowing multiple inheritance seems to work better in some languages than others. For example, in C++ it almost always seems to be a bad idea. In Python it tends to work out more often (usually when the other classes are pure mix-ins).