5 ms·
Because trait is a much better word for it: https://en.wikipedia.org/wiki/Trait_(computer_programming) https://en.wikipedia.org/wiki/Trait_(computer_programming
by masklinn 12y ago
Because trait is a much better word for it: https://en.wikipedia.org/wiki/Trait_(computer_programming) https://en.wikipedia.org/wiki/Trait_(computer_programming)
- EugeneOZ 12y agoSo in Rust traits can include full methods bodies, not only signatures?
- evanpw 12y agoYes: http://rustbyexample.com/trait.html http://rustbyexample.com/trait.html
- pcwalton 12y agoYes. The feature has been proposed for Java too: "defender methods". Originally I resisted them on the grounds of not being necessary, but they're used all over now. Being able to supply a default implementation is extremely useful.
- oldmanjay 12y agoQuick correction: Java 8 does have defender methods.
- EugeneOZ 12y agoThanks to all for explanations! :) And now I think Traits are traits, but can be used as interfaces too :)
- kzrdude 12y agodefault method implementations makes traits behave like mixins, it's very useful (and it is a form of code reuse).
- pcwalton 12y agoTotally agreed. I was wrong to resist them :)
- deleted 12y ago[deleted]
- Manishearth 12y agoThey can also contain associated constants.