class sugar

Kam Kasravi 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

http://www.mail-archive.com/es-discuss@mozilla.org/msg03904.html
http://www.mail-archive.com/es-discuss@mozilla.org/msg03906.html

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.

/be
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110604/59177aa4/attachment-0001.html>


More information about the es-discuss mailing list