I have concerns about constructors in mixins. Allowing declaring constructor in mixins means allowing access to super since it's a must to call super in constructor, which would lead to origin class reference leakage.
As I understand mixins, they adds own properties and methods and encapsulate logic acting like a plain JS object. But allowing a constructor somewhat equals them to classes, which is not that simple.
For initiating logic I would expect to have a dedicated keyword like init
In case of mixin extension, the extensions would just add up to this as they are a part of origin mixin since there could be multiple mixin extensions.
mixin Events {
listeners = new Set
dispatch() {...}
on() {...}
}
mixin Socket extends Network {
init {
this.dispatch(...) // no access to `super` in mixins.
}
}
I have concerns about
constructor
s in mixins. Allowing declaring constructor in mixins means allowing access to super since it's a must to callsuper
in constructor, which would lead to origin class reference leakage.As I understand mixins, they adds own properties and methods and encapsulate logic acting like a plain JS object. But allowing a
constructor
somewhat equals them to classes, which is not that simple.For initiating logic I would expect to have a dedicated keyword like
init
In case of mixin extension, the extensions would just add up to
this
as they are a part of origin mixin since there could be multiple mixin extensions.