Hi all,<br><br>I've been writing some code that uses web workers. It's a very nice addition to the HTML toolbox (kudos!), but I have some questions:<br><br>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.<br>
<br>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?<br>
<br>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. What do others think?<br><br>Looking forward to feedback!<br>
<br>Daniel<br><br><br>[1] <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#structured-clone" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#structured-clone</a><br clear="all">
<br><br>-- <br>Daniel Gredler<br><a href="http://daniel.gredler.net/" target="_blank">http://daniel.gredler.net/</a><br>