This behavior is consistent with other OO languages like C++ and C# that do
not have virtual methods by default.
This solution isn't ideal, but I don't have time for a larger refactoring
right now. I sat on this change for a good few weeks before committing it
unchanged.
* lib/MemberBuilderValidator.js (validateMethod): Allow override of
supertype overrides.
* test/*: Stripped `virtual' keyword where appropriate.
* doc/classes.texi (Inheritance): Update to state that `override' implies
`virtual'.
The concept of stacked traits already existed in previous commits, but until
now, mixins could not be stacked without some ugly errors. This also allows
mixins to be stacked atop of themselves, duplicating their effect. This
would naturally have limited use, but it's there.
This differs slightly from Scala. For example, consider this ease.js mixin:
C.use( T ).use( T )()
This is perfectly valid---it has the effect of stacking T twice. In reality,
ease.js is doing this:
- C' = C.use( T );
- new C'.use( T );
That is, it each call to `use' creates another class with T mixed in.
Scala, on the other hand, complains in this situation:
new C with T with T
will produce an error stating that "trait T is inherited twice". You can
work around this, however, by doing this:
class Ca extends T
new Ca with T
In fact, this is precisely what ease.js is doing, as mentioned above; the
"use.use" syntax is merely shorthand for this:
new C.use( T ).extend( {} ).use( T )
Just keep that in mind.
More information on this implementation and the rationale behind it will
appear in the manual. See future commits.
(Note the TODOs; return values aren't quite right here, but that will be
handled in the next commit.)