Overriding Map/etc with get/set hooks?

Brendan Eich brendan at mozilla.com
Tue May 21 04:19:06 PDT 2013


David Bruant wrote:
> This description ("arbitrary string keys", "bidirectional link with 
> style rule") suggests that you want a proxy (canonical values are in 
> the style rule, the proxy is just a façade with a bit of 
> validation/coercion logic). That's the sort of use case they've been 
> introduced for.

I don't see why a proxy is required if the API is get/set/has (like 
Map's). We're not making properties appear without knowing their names, 
so this is not a proxy use-case on its face.

Of course, coercing key type makes the API not Map. So if the 
bi-directionality is important, this would be a custom Map-like class.

So Tab: why do you want to abuse Map instead of make a custom class?

/be


More information about the es-discuss mailing list