Class Syntax Proposal, Complete With Arguments For and Examples.

Mike Shaver mike.shaver at gmail.com
Sun Sep 18 09:14:10 PDT 2011


On Sun, Sep 18, 2011 at 1:36 AM, Jonathan Dumaine
<jonathan.dumaine at dumstruck.com> wrote:
> You could go
> all the way and make classes a very strict subset of the language: throw an
> error if the user tries to set a property of a class instance that has
> already been declared private
[...]
> I would personally prefer the prior route: sacrifice some of javascript's
> dynamic attributes in favor of better abstraction and encapsulation
> capabilities.

But one problem here is exactly related to abstraction and
encapsulation: the class's implementation can't add a new private
property without risking breaking of existing clients: if they were
using the newly-claimed name as an "expando" property's name, then the
changes to the "encapsulated and abstracted" internal representation
will cause them to error out.

Mike


More information about the es-discuss mailing list