kamkasravi at yahoo.com
Sat Jun 4 17:03:35 PDT 2011
Although this ship has sailed, its unfortunate the keyword privileged was never considered as part of the closure pattern
and valid syntax within the classes strawman, where public operated on the prototype chain and privileged operated on the closure.
Now its less clear what type of pattern is being employed since public methods within the constructor are not on the prototype and cannot be extended.
From: Brendan Eich <brendan at mozilla.com>
To: Peter Michaux <petermichaux at gmail.com>
Cc: Mark S. Miller <erights at google.com>; es-discuss <es-discuss at mozilla.org>
Sent: Saturday, June 4, 2011 3:23 PM
Subject: Re: class sugar
On Jun 4, 2011, at 3:00 PM, Peter Michaux wrote:
> On Sat, Jun 4, 2011 at 9:52 AM, Juan Ignacio Dopazo
> <dopazo.juan at gmail.com> wrote:
>> Both styles are equally useful. Prototype based code has its own advantages
>> such as being able to easily modify the behavior of multiple objects on the
>> fly (very useful when working with 3rd party code for instance).
> Yes but this is a limitation of our tools. If Firebug let you into a
> closure and edit the code inside the closure, for example, you could
> have this ability with the closure based system.
This is hard, though. It's related to the optimization challenges in joining function objects to their one expression form. See
All solvable, but hard enough that even the latest JS engines (last I checked) show slowdowns when you scale up objects as closures vs. the prototypal equivalent.
I know, it's a vicious cycle. We can't get engine implementors to optimize harder without somehow making closure costs hurt, but since closure costs hurt developers first and engine implementors second or third, while prototypes hurt less, many developers choose prototypes. JS has prototypes as well as closures, and prototypes allow explicit sharing of "methods". This ship sailed long ago.
Good to see class syntax supporting both styles, in any event.
es-discuss mailing list
es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss