inclusion, functors and functor types, class and class type inheritance, et cetera. Perl: Called roles, they are implemented in Perl libraries such as Moose, Role::Tiny and Role::Basic. Roles are part of the sister language Raku. With the acceptance of the Corinna OOP Proposal Perl will have roles native to the language as part of a modern OOP system. PHP: Since version 5.4, PHP allows users to specify templates that provide the ability to "inherit" from more than one (trait-)class, as a pseudo multiple inheritance. Python: Via a third-party library, or via higher-order mixin classes Racket: Supports traits as a library and uses macros, structures, and first-class classes to implement them. Ruby: Module mixins can be used to implement traits. Rust Scala trait is builtin supported with the key word trait. Smalltalk: Traits are implemented in two dialects of Smalltalk, Squeak and Pharo. Swift: Traits can be implemented with protocol extensions. Examples C# On C# 8.0, it is possible to define an implementation as a member of an interface.using System; namespace CSharp8NewFeatures; interface ILogger { // Traditional interface methods void Log(string message); void LogError(Exception exception); // Default interface method void LogWarning(string message) { Console.WriteLine(message); } } class Logger : ILogger { public void Log(string message) { Console.WriteLine(message); } public void LogError(Exception exception) { Console.WriteLine(exception.ToString()); } } class Program { static void Main(string[] args) { ILogger logger = new Logger(); logger.LogWarning("Some warning message"); } } PHP This example uses a trait to enhance other classes: // The template trait TSingleton { private static $_instance = null; private function __construct() {} // Must have private default constructor and be aware not to open it in the class public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } class FrontController { use TSingleton; } // Can also be used in already extended classes class WebSite extends SomeClass { use TSingleton; } This allows simulating aspects of multiple inheritance: trait TBounding { public $x, $y, $width, $height; } trait TMoveable { public function moveTo($x, $y) { // … } } trait TResizeable { public function resize($newWidth, $newHeight) { // … } } class Rectangle { use TBounding, TMoveable, TResizeable; public function fillColor($color) { // … } } Rust A trait in Rust declares a set of methods that a type must implement. Rust compilers require traits to be explicated, which ensures the safety of generics in