Approach of new Object methods in ES5
erik.arvidsson at gmail.com
Fri Apr 16 09:51:36 PDT 2010
On Fri, Apr 16, 2010 at 08:43, Brendan Eich <brendan at mozilla.com> wrote:
> ES4 since Waldemar's 1998-era JS2 work was concerned with the problem of
> versioning APIs implied by (1) greatly, and not just adding properties:
> deleting and redefining too. ES4 proposed namespaces (like Common Lisp
> packages, IIRC) as the solution. But namespaces are out for Harmony.
> My hope is that we can avoid versioning the object model and instead simply
> extend certain objects that we effectively "reserve to the implementation"
> (as ANSI and then ISO C does with certain global names, e.g. __foo and
> _BAR). Indeed Ajax library developers now generally avoid extending standard
> prototypes, and it's plausible this best-practice could be extended to the
> built-in constructor objects too.
These are considered best practices because it breaks in the presence of
other code outside your control. There is a reason why Prototype.js is
popular. It allows people to write code in a more sane way, using methods
that are bound to objects instead of global functions. If we had something
like ES4 namespaces without all the issues (one can always dream) I'm sure
that this best practice would be reversed.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss