On __proto__ as a magical data property

Andreas Rossberg rossberg at google.com
Wed Jul 18 04:42:52 PDT 2012


On 18 July 2012 12:35, David Bruant <bruant.d at gmail.com> wrote:

>  I also don't think that array length counts as proper precedence. Array
> length is a magic property _on the instance_, whose magic is limited to
> that specific instance, whereas __proto__ would be a magic property _on the
> prototype_, thereby introducing _cross-object_ magic. I'd argue that's
> quite a different quality. Do we have any precedence for that?
>
>  It simply seems entirely incoherent to me that a single _data_ property
> should exhibit different values when accessed through different receivers.
> From my perspective, that's a significantly more fundamental violation of
> the JS object model than the magic that comes with array length.
>
> Proxies are an even more fundamental violation of the JS object model.
>

Agreed (and one of the reservations I actually have about adding proxies).
However, proxies are proxies. True, we cannot efficiently _enforce_ many
behavioural invariants for (user-defined) proxies. But that does not imply
that we should feel free to actively _break_ more invariants for
(language-defined) non-proxies.

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120718/b46fa4e9/attachment-0001.html>


More information about the es-discuss mailing list