2 ms·
Depending on the use case the name clashing problem can be easily solved. For instance, in Lua the way I solve it is by simply letting multiple mixins define th
by hynieru 11y ago
Depending on the use case the name clashing problem can be easily solved. For instance, in Lua the way I solve it is by simply letting multiple mixins define the same function, and whenever that function is called anywhere it triggers all of them. For game development this is extremely useful since usually when you have something like object:takeHit(attacker), multiple mixins that do different things in relation to getting hit (damage calculations, effects, animation, physics for pushback, and so on) define the takeHit function, but each of those different concerns is well hidden into their own separate mixin/module.
Of course I agree with you that mixins need a lot of discipline and I specifically follow the 2-3 different target classes rule. It's really really easy to fall into the trap of making everything a mixin but this is really the wrong way to go about it.