[whatwg] Web Workers and postMessage(): Questions
Ian Hickson
ian at hixie.ch
Sat Aug 1 13:59:58 PDT 2009
On Wed, 22 Jul 2009, Daniel Gredler wrote:
>
> First, why does the structured clone algorithm used by postMessage() [1]
> throw an exception if it encounters cycles? It seems to me that the
> memory-based logic which is used to catch cycles could easily be
> modified to resolve them instead. The only possible reason I can think
> of is to match JSON semantics, and the only reason I can think of to
> want to match JSON semantics is to make implementers lives easier
> (witness Firefox 3.5, which just JSONifies objects passed to
> postMessage()). However, this is a huge limitation, and I'm not sure
> that the correct trade-off is to make implementers lives easier at the
> expense of making web designers lives harder.
Your guess is correct. I imagine we'll lift the restriction eventually; if
you want to make that happen quicker, then I encourage you to speak
directly to the browser vendors implementing this, and convince them it'd
be worth it. :-)
> Second, why not walk the prototype chain? Similar rules regarding host
> objects and regular objects could apply to prototypes. You would want to
> make sure that multiple references to the same prototype instance result
> in references to a single prototype clone in the cloned object graph.
> Again, though, it doesn't sound too hard (though I might just be
> optimistic). Why not make web designers' lives easier?
We're definitely never going to copy function code over, so it's not clear
that the prototype chain would be that useful. Could you elaborate on your
use case?
> Overall, it just appears that the current web worker spec ignores the
> class of computational problems involving results which need to be
> modeled in a complex way.
That's probably a fair criticism, yes.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list