Allow the omission of the superclass
See original GitHub issueCurrently the syntax is:
class MyClass extends mix(MySuperClass).with(MyMixin1, MyMixin2) {
}
How about the following?
class MyClass extends mixins(MyMixin1, MyMixin2, MySuperClass) {
}
Details:
- This better reflects the order of the inheritance chain
- The last parameter should be optional (you may want to create classes that only assemble mixins and have no superclass)
- The function could do a simple typecheck by enforcing that the mixins must not have a property
prototype
, while the superclass (the optional last parameter) must have this property.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Always allow code before super call when it does not use "this"
The first statement in the body of a constructor must be a super call if both of the following are true: The containing...
Read more >PHP superclass calling subclass methods without knowing ...
PHP is very dynamic language and it allows you to use polymorphism without inheritance. In this case, it simply looks ...
Read more >Abstract Classes
We can treat an abstract class as a superclass and extend it; its subclasses can override some or all of its inherited abstract...
Read more >Design and document for inheritance—or else prohibit it ...
There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or ...
Read more >database T/F Flashcards - Quizlet
Superclass may not contain overlapping subclasses ... during the conceptual design is the omission of certain attributes, entities, or relationships.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If this syntax is acceptable:
…then you could throw this check in for mix constructor:
That would default to having Object as a superclass…which everything is, so that’s technically true.
I was just thinking about this, as I thought “what if I don’t have a super class, and just want to extend from some mixins?”.
Object
can be replaced at runtime, whereasclass {}
always extends from the internal[[Object]]
, so possibly it’s better to use an empty class anyway.