Hacker News new | past | comments | ask | show | jobs | submit login

Isn't this the scenario that is going to be solved by ES6 'class' syntax sugar?



No, that will only allow to subclass "Object", not "Class". Also with ES6 you have to define the prototype all in once and you can't call `defineMethod` for each one, the ES6 sugar is more like just using `MyClass.prototype = Object.create(BaseClass.prototype, { /* properties */ });` today. Which the author apparently doesn't feel is even worth mentioning.


But as I understand, the extension of Class was mainly to introduce a self-binding variant. I assumed that a proper class implementation would take that into account.

And what is bad about defining the prototype at once? I don't see a great advantage to the defineMethod() style.


Sorry, I was being sarcastic about the `defineMethod`-style. IMHO the author overvalues the class/inheritance part of OOP and discards the considerable risks posed by using it. For example in the case of the self-binding he misuses inheritance to express "a Class with SelfBinding" which is a strategy/trait relationship and inheritance is the absolutely wrong hammer for that screw. A simple function would be less intrusive, have less indirection, and be more flexible.

EDIT: I'm not sure self-binding is part of ES6, to address your actual question. self-binding introduces a certain overhead to every function call, so I'm not even sure it would be a good thing if it would.


:) thanks for clarifying..

And assuming one wants to express the problem in terms of objects, then the slight overhead might be worth being able to pass bound functions around, "without thinking about it"




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

Search: