W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2014

Re: Weak set usage in streams

From: Brendan Eich <brendan@secure.meer.net>
Date: Wed, 26 Nov 2014 15:22:03 -0800
Message-ID: <5476609B.8090807@secure.meer.net>
To: Jonas Sicking <jonas@sicking.cc>, Domenic Denicola <d@domenic.me>
CC: Domenic Denicola <d@domenic.me>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Jonas Sicking wrote:
> I definitely see no problem in creating a pair of objects that are
> "friends" and can access each other's internal state.
> Using a WeakMap to specify that relationship seems ok, though I don't
> think that's how I'd implement for performance reasons. Instead I'd
> have the two objects share a closure and then put state that needs to
> be accessible to both on that closure.

I think WeakSet is a mistake. If you want a protocol among "friend" 
objects expressed in the base language, use a suite of methods -- a 
structural or "duck" type. Using a WeakSet both over- and 
under-specifies. Any object can be added to a WeakSet as a key (making 
for a DoS hazard). A WeakSet 'has' test does not prove anything about 
the structural subtype relationship (however defined). Etc.

Received on Wednesday, 26 November 2014 23:22:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:23 UTC