Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Looks interesting, but to be honest there is nothing new here. If you take a look at D, it also has both runtime and compile time polymorphism for a long time. The former is implemented with Java-style interfaces, while the latter is done through templates. Traits are also possible via template mixins: you define a template like so: template ExtraStuff { int someData; void someMethod() { someDate = 5; } }

and then you mix it into the class in question: class SomeClass { mixin ExtraStuff; }

It also gives you a lot more flexibility: you can mix it not only in classes but in structs(in D those are different types), to the global scope and even inside the functions(in that case someData becomes a local variable and someMethod() an inner function).



The part that's new (as far as we know anyway) is the unification of typeclasses with OO (bounded polymorphism; e.g. fn foo<T:MyInterface>(x : T)). Mixins and traits are definitely not new.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: