Several implementations of mixins (e.g. Ruby mixin, Scala trait) include support for storing data (e.g. variables, properties) between method calls in instance variables. There was a bit of debate in this question about whether or not a Java virtual extension method qualified as a mixin because they cannot store data in this way; all variables are inputted and outputted within the scope of the method call and cannot be stored in an instance variable. Essentially, there was debate about what a "mixin" by definition is and whether or not implementations in Ruby and whatnot go beyond the commonly recognized definition of the programming concept.
Unfortunately, the definition of a mixin seem rather vague in this regard. For instance, Wikipedia says the following:
With mixins the class definition defines only the attributes and parameters associated with that class; methods are left to be defined elsewhere, as in Flavors and CLOS, and are organized in "generic functions". These generic functions are functions that are defined in multiple cases (methods) by type dispatch and method combinations.
The above says that a mixin defines attributes, but doesn't cite sources that might clarify this. However, every other definition simply fails to mention whether or not mixins allow storing data or if they are limited to methods. To further add confusion, Wikipedia earlier describes mixins as an interface with implemented methods
, but interfaces can't store instance variables. I tried to find out how it was defined in Flavors, which was the first programming language to use something called "mixins", but I couldn't find enough information online about it.
So can a mixin by definition allow storing data? Or is this something that is ambiguous and is left up to the programming language to decide?