Re: Weak set usage in streams

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.

/be

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