W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2009

[whatwg] Passing more than JSON data to workers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 17 Dec 2009 01:03:49 -0800
Message-ID: <4B29F3F5.6000808@mit.edu>
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
Received on Thursday, 17 December 2009 01:03:49 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:54 UTC