Trait (computer programming): Difference between revisions

Content deleted Content added
Characteristics: copyedit and cleanup; rm comment about scala mixins (mixins are not traits)
Limitations: copyedit and cleanup. remove most of the 'excluding methods' section, because I'm pretty sure those are compiler bugs and not traits of traits. I
Line 49:
=== Required Methods ===
 
If a trait requires the consuming class to provide certain methods, the trait cannot know if those methods are [[Semantic_equivalence|semantically equivalent]] to the trait's needs. Worse, forFor some dynamic languages, such as Perl, the required method can only be identified by a method name, not a full [[Type signature|method signature]], making it harder to guarantee that the required method is appropriate.
 
=== Excluding Methods ===
 
If a method is excluded from a trait, that method becomes a 'required' method for the trait because the trait's other methods might call it.
If you exclude a method from a trait, that method becomes a 'required' method for the trait because the trait's other methods might call it. If the programming language uses [[Static dispatch|static dispatch]] ("early binding"), method names are bound at [[Compile time|compile time]] and the trait methods might call the trait's implementation of the method and not the corresponding method provided by the class. Conversely, if the programming language uses [[Dynamic dispatch|dynamic dispatch]] ("late binding"), method names are determined at run time and the trait methods might call the class's implementation of the method and not the method provided by the trait. If a method is excluded, the programmer must take this into account.
 
==Supported languages==