[whatwg] Passing more than JSON data to workers
Boris Zbarsky
bzbarsky at MIT.EDU
Thu Dec 17 01:03:49 PST 2009
On 12/17/09 12:48 AM, Boris Zbarsky wrote:
> It seems very difficult to me to come up with a "function cloning"
> solution that won't break in subtle ways when such functions are passed
> to it...
I should clarify this. It seems to me eminently possible to clone
functions that only reference local (declared with var) variables and
their arguments. And maybe explicit |this| access; not sure.
As soon as you're talking anything else, the situation gets very
complicated, it seems to me. That includes implicit property access on
the global object.
To make that clearer, consider these two functions, defined at global scope:
var x = 1;
function f() {
return x;
}
function g() {
return Math;
}
If I understand your proposal correctly, passing f to a worker would
pass across a function which always returns 1. Passing g to a worker
would do what? Pass across a function that always returns the Math
object from the web page scope? If not, then how is Math different from
x, exactly? If yes, then why are we baking anything at all in at pass time?
How is the f() example above affected if x is bound to an object, not to
a number?
-Boris
More information about the whatwg
mailing list