Le 29/12/2011 03:04, Mark S. Miller a écrit :
> Darn. I completely missed that. No easy fix comes to mind. Suggestions?
I think '__proto__' in object literals should work like any property.
The ES.next proto operator [1] creates a standard alternative to using
__proto__ in object literal.
As the proposal says:
-----
Replace:
  var o = {
       __proto__ : myProto,
       a:0,
       b: function () {}
  }

With:
  var o = myProto <| {
       a:0,
       b: function () {}
  }
-----

__proto__ would then act like a regular property (shadowing the one on
the Object.prototype, very much like if it had been added with
Object.defineProperty). The ability to later change the prototype is not
lost as Lasse suggested.

I don't know to what extent my suggestion would break exisiting scripts.
Neither do I know whether breaking existing __proto__-using scripts is a
good or a bad thing.
If in some browsers it breaks something, browsers, when changing
__proto__ semantics could issue a warning in their console ("you're
using __proto__ in object literals and we have changed its semantics...").

David

[1] http://wiki.ecmascript.org/doku.php?id=harmony:proto_operator

>
>
> On Wed, Dec 28, 2011 at 6:01 PM, Allen Wirfs-Brock
> <[email protected] <mailto:[email protected]>> wrote:
>
>
>     On Dec 28, 2011, at 5:36 PM, Mark S. Miller wrote:
>
>     >
>     >
>     > Comments on this proposal appreciated.
>     >
>
>     Mark,
>
>     Your proposal doesn't address the occurrence of __proto__ as a
>     property name in an object literal
>
>     Allen
>
>
>
>
>
> -- 
>     Cheers,
>     --MarkM
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to