Yuescript icon indicating copy to clipboard operation
Yuescript copied to clipboard

Mixin Improvements: Override, super()

Open 11clock opened this issue 3 years ago • 2 comments

I would like added features for mixins to make them more inline with direct inheritance in terms if power and flexibility.

  1. The ability to override mixed in fields and functions. Currently mixin functions take precedence over what are defined in the class including them, meaning you cannot override them.

  2. The ability to call super() in an overridden mixed in function, to call the original implementation from the class it was from.

With these added features, mixins can be used more like proper interfaces with default implementations, and in some cases replace prototypical inheritance.

11clock avatar Apr 02 '22 00:04 11clock

Fixed overriding in mixing, but do you have any idea to implement the super() function?

pigpigyyy avatar Apr 02 '22 02:04 pigpigyyy

One idea is to keep a list of the class’ mixins. If super is called in a method, it can check the mixin list first before trying to call the parent.

11clock avatar Apr 03 '22 09:04 11clock