Overriding Map/etc with get/set hooks?

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed May 22 11:00:15 PDT 2013

I believe Tab is asking for something like:

`var MyNodeList = new ArrayType(EntryType, length);`

where `EntryType` is his own type and the result is an array like
collection or map.

At least, for what I understood, looks like he's asking for JS CTypes,
something rumored a while ago but never heard about again (while asm.js has
been introduced/implemented already)

If I am mistaking, apologies.

On Wed, May 22, 2013 at 10:35 AM, David Bruant <bruant.d at gmail.com> wrote:

> Le 22/05/2013 19:02, Tab Atkins Jr. a écrit :
>  On Wed, May 22, 2013 at 9:44 AM, Brendan Eich <brendan at mozilla.com>
>> wrote:
>>> NodeList extends Array now but is not literally Array plus hooks. Same
>>> for Map and the quite different thing you're specifying.
>> NodeList is an interesting case, actually.  It's an Array, but with a
>> type restriction.
> I'm a bit lost here. What exactly do you label as "Array"? What is a "type
> restriction"?
> For sure, Array.isArray(anyNodeList) === false
> So the ES spec seems to disagree with the statement "a NodeList is an
> Array"
>  Live NodeLists even have basically the same linkage
>> behavior I'm talking about.
>> What do I need to do to get a Map like that?
> Proxy is the answer to your question (FWIW I've made a proxy-based
> implementation of arrays a while back [1]). But both cases can't really be
> compared.
> From a dev perspective, the interface of an array is its own properties
> (numerical up to 2^32-1, connection with the .length property...) and the
> interface of a map is the methods/accessors on the prototype ([[MapData]]
> being "just" a spec tool that could be replaced by anything else as long as
> prototype methods were behaving observably the same)
> If your object can have *any* property name, that can shadow the
> get/set/has property you need to interact with your map. I'm not sure what
> the solution is, but a proxy doesn't sound like a good idea at least
> because of the shadowing issue.
> David
> [1] https://github.com/**DavidBruant/HarmonyProxyLab/**
> blob/master/ProxyArray/**ProxyArray.js<https://github.com/DavidBruant/HarmonyProxyLab/blob/master/ProxyArray/ProxyArray.js>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130522/6309fea1/attachment.html>

More information about the es-discuss mailing list