3 ms·
Do Scala's traits change behavior depending on order of definition? That scares me tbh.
by Ygg2 12y ago
Do Scala's traits change behavior depending on order of definition?
That scares me tbh.
- seanmcdirmid 12y agoThere are ways to fix that, but I could never get Martin interested in my exclusive inheritance proposals. In particular, only one trait should be allowed to "implement" an abstract method in an object, although typical overriding is still unrestricted. It does require a new keyword (implement vs. override). As for overriding, traits could be ordered globally based on extension relationships and other fixed markers (e.g. Names).
- lmm 12y agoDepending on order of inheritance? Yes. And yes, it should scare you (though IME problems are rare and are obvious when they do occur). I love Scala but it's very much a language of awkward compromises.