On Fri, Feb 14, 2020 at 07:24:48PM -0300, Soni L. wrote: > In Rust, you can have:
That's great for people who understand both Rust styntax and Rust semantics, but this is a Python discussion group, not Rust. We aren't all Rust experts. > with strait, you can't have both Foo and Bar on Baz - it just raises by > default. if you don't want it to raise, you have to specify an x, That's how traits are (usually) defined: if there is an ambiguity due to conflicting methods, you have to explicitly resolve the ambiguity, or else it's an error. If the compiler just picks one for you, you don't have traits, you have multiple inheritence. (Above, I say "usually", because there are many subtle or not-so-subtle differences between the way traits are defined in different languages.) > at which point it behaves like mixins, Well, yes. Mixins with no conflicting methods is just the same as traits. The difference is that traits make you resolve conflicts explicitly, rather than just using some default rule. > not giving you the niceties of Rust traits. > > for proper traits, you need to be able to select, implicitly or > explicitly, which trait impl you want to call. Right. And that's what the strait module allows too. See the example: https://pypi.org/project/strait/ I think that if this discussion is going to become productive, you need to start by defining what "traits" mean to you, in detail. What do they do? What are their semantics? Focus on how they differ from multiple inheritence and mixins in Python, and what problems you would solve by using them. Entities and features going by the name "trait" occur in many languages, but have different meanings. Unless we agree on a meaning, we are just talking past each other. You should give *short*, *simple* but *concrete* examples, in pseudocode that demonstrates the principle, not the mechanical details of some specific interface. Interfaces can be changed. The semantics of the feature is what is important for understanding. Using abstract metasyntactic variables like spam, eggs, foo, bar, x, y that do nothing and mean nothing is not going to be helpful. Use a concrete, actual example, but simplifed. Thank you. -- Steven _______________________________________________ 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/VVSCG4UBGHN67V2T4FAROO6SKGETUINR/ Code of Conduct: http://python.org/psf/codeofconduct/