Removal of WeakMap/WeakSet clear

Andreas Rossberg rossberg at google.com
Thu Dec 4 00:55:42 PST 2014


On 4 December 2014 at 00:54, David Bruant <bruant.d at gmail.com> wrote:
> The way I see it, data structures are a tool to efficiently query data. They
> don't *have* to be arbitrarily mutable anytime for this purpose.
> It's a point of view problem, but in my opinion, mutability is the problem,
> not sharing the same object. Being able to create and share structured data
> should not have to mean it can be modified by anyone anytime. Hence
> Object.freeze, hence the recent popularity of React.js.

I agree, but that is all irrelevant regarding the question of weak
maps, because you cannot freeze their content.

So my question stands: What would be a plausible scenario where
handing a weak map to an untrusted third party is not utterly crazy to
start with? In particular, when can giving them the ability to clear
be harmful, while the ability to add random entries, or attempt to
remove entries at guess, is not?

/Andreas


More information about the es-discuss mailing list