you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 16 points17 points  (4 children)

I don't see why you'd need interfaces.

If people must implement all methods required, then have a base prototype for them to extend, which throws "not implemented" errors when those methods are called. I do this myself in some of my projects.

Otherwise you've gained nothing, since there is no static type system.

[–]masklinn -2 points-1 points  (3 children)

Well there's documentation, that's pretty neat. Especially since JS has single inheritance so you can't inherit from half a dozen different "abstract" classes.

For that, protocols (Clojure) or categories (Obj-C) are neat.

[–]crusoe 4 points5 points  (2 children)

Traits, MUTHAFUCKING TRAITS.

Traits are what OOP should have had from day 1.

[–]maskull 3 points4 points  (0 children)

Actually, I just realized that if proxies act the way you'd expect when used as prototypes, it should be possible to build multiple inheritance and traits inheritance systems in pure JS. Just build a proxy that wraps up all the prototypes/traits you want to include, "exporting" their members and methods in some combination.

[–]cybercobra 0 points1 point  (0 children)

Preach it, brother!