A trait is a characteristic, a capacity, an ability. It is much more refined and narrowed, less abstract, close to what is has-a instead of naive and crude is-a hierarchy.

So called Type Classes in Haskell are actually Type Traits, because they define capabilities instead of "classes or kinds of things". This is exactly what the word trait mean.

This is very important. Traits are compostable (mixable), while classes are not. This is a fundamental and principal difference.

In the very first version of the OO DSL for Zeta Lisp (a precursor of Common Lisp) has flavours which were just another name for traits and suggests that they could be mixed (composed).

See also Structures which is a very related concept.

Last modified 14 months ago Last modified on Dec 18, 2018, 1:21:05 PM
Note: See TracWiki for help on using the wiki.