Re: [streams] can streams be transferred via postMessage()? (#276)

I think it helps reduce the surface area a little bit. In particular one strategy would be that you only have to check if `dest.getWriter` is the same as the original `getWriter`, and as long as that can be done unobservably, you're then good to go. (I think it can, too: you insert the equality check in between the "get" and the "call" steps of the invoke-a-method algorithm.)

Except... what if someone overwrites `WritableStreamWriter.prototype.write` or similar -_-.

---

Another strategy would be that the first thing the algorithm does is grab all the methods off the writer, and then use them forever more after. E.g.

```js
const [write, close] = [writer.write, writer.close];

// we can unobservably insert a check here that write and close are the expected ones...

// later:
write.call(writer) // instead of writer.write()
```

Except ... this doesn't work for our `ready` getter, without hacks. And, seems pretty JS-unnatural anyway...

---

I'm starting to feel that we need to program what we want more directly into the spec, instead of trying to make it an unobservable optimization. That implies one of the other two strategies. (Or perhaps less-extensible versions of them, at least in the short term...)

I hope to think on this more productively next Monday, when my brain has had a chance to un-fry itself after a TC39 week. I feel like I need to take a step back, and say what the high-level goals and constraints are here. (I've left a lot implicit, I think.) But the above is kind of where I'm at right now; hope it helps people understand that we're taking this seriously at least :)

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/276#issuecomment-86641918

Received on Thursday, 26 March 2015 17:46:59 UTC