Overriding Map/etc with get/set hooks?

Brendan Eich brendan at mozilla.com
Wed May 22 03:44:06 PDT 2013


Tab Atkins Jr. wrote:
> If TC39 isn't going to allow us to ever use*any*  of the built-in
> collection classes just because we have type restrictions we need to
> enforce, that'll be a pretty raw deal for authors.

Whining about TC39 like this is bad for business. Should I whine about 
W3C to even up the bad karma?

You can do whatever you want with a subclass or a wrapper. Your o.p. had 
a parenthetical aside about subclass hardships:

(One way to do thistoday  is to subclass Map and provide my own
get/set/etc. functions, but I need to override a potentially-open set
(anything that doesn't directly lean on my overridden functions), and
it doesn't prevent people from directly twiddling my [[MapData]] by
calling Map.prototype.set.call() on my object.)

----- end cite -----

But there's no free lunch. Either Map needs hooks lumbering its spec and 
implementations for all users, or you need to do the hooking. Without 
evidence that others need the hooking, as Allen argues, the burden's on 
you. Buy your own lunch.

/be


More information about the es-discuss mailing list