What's the reasoning behind the extra restrictions in [[CanPut]]?

Mark S. Miller erights at google.com
Thu Dec 29 15:11:22 PST 2011


[+google-caja-discuss]

Hi John,

First, thanks for commenting on repairES5.js. Please keep the comments
coming. Anything not appropriate for the es-discuss like should instead be
posted to google-caja-discuss, cc'ed. But please look instead at <
http://code.google.com/p/es-lab/source/browse/trunk/src/ses/repairES5.js>,
which is the version in review at <http://codereview.appspot.com/5489103/>.

Regarding this issue, thanks for raising it here. I was planning to do so
myself, once I flesh out <
http://wiki.ecmascript.org/doku.php?id=strawman:fixing_override_mistake>.
But what's already there is coherent enough to look at.

The Irony of this "feature" of the language is that SES pays a significant
performance penalty only on platforms that pass the test you link to. On
platforms that fail this test, our "repair" in review at <
http://code.google.com/p/es-lab/source/browse/trunk/src/ses/repairES5.js#2252>
makes them much faster.


On Thu, Dec 29, 2011 at 2:56 PM, John-David Dalton <
john.david.dalton at gmail.com> wrote:

> So I was digging through repairES5.js
>
> http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/repairES5.js#1427
>
> and noticed that:
>
>  var a = Object.freeze({ 'x': 1 });
>  var b = Object.create(a);
>  b.x = 2;
>  b.x; // should still be 1
>
> Then I dug into spec and noticed:
> http://es5.github.com/#x8.12.4
>
> so `b.x` remains 1 because the property 'x' of its [[Prototype]] is
> writable: false.
>
> Ok, so why all of that when you could simply do:
>
>  var b = Object.create(a, {
>    'x': {
>      'configurable': true,
>      'enumerable': true,
>      'writable': true,
>      'value': 2
>    }
>  });
>
> or
>
>  Object.defineProperty(b, 'x', {
>    'configurable': true,
>    'enumerable': true,
>    'writable': true,
>    'value': 2
>  });
>
>  b.x; // 2
>
> - JDD
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111229/b57ed56c/attachment-0001.html>


More information about the es-discuss mailing list