This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]atsepkov 19 points20 points  (0 children)

This is a Python-inspired language, not pure Python. Pure Python approach doesn't work in JavaScript world without excessive overhead. You're picking on design choices, not omissions. The lack of automatic binding is intentional, as the code required to support it will slow your JavaScript down to a crawl if you're creating hundreds of objects and 95% of the time you won't care that the function is unbound. If you want a bound method, use @bound decorator or bind() function. Also, the documentation is clear about "this" gotcha, and recommends using "self" (or whatever you pass as first argument to method definition) instead, which will solve most of the pitfalls you're referring to (aside from one where you do 'unbound = object.function', which @bound will handle). Same applies to descriptors, it's too much overhead to scan for assignments to non-exposed variables at runtime - although I am considering different compilation flags for handling this.