[whatwg] Web Workers and postMessage(): Questions

Hi all,

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:

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.

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?

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?

Looking forward to feedback!

Daniel


[1]
http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#structured-clone


-- 
Daniel Gredler
http://daniel.gredler.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090722/ed63745b/attachment.htm>

Received on Wednesday, 22 July 2009 17:59:12 UTC