> How can I re-use the same built-ins each time?

There is no way. New context means new built-in objects. Also
reattaching global does not change anything because built-ins are not
on the global object itself.

If you want to reuse the same builtins you don't ultimately need a new
context. Just use the same all the time.

> Also what about strings or custom objects of our own?

If you execute this code multiple times you get multiple foos and of
course instances produced by one foo are not instanceof another foo...
Just like in pure JS:

function mkfoo() {
  function foo() {}
  return new foo();
}

var o1 = mkfoo();
var o2 = mkfoo();

o1 instanceof o2.constructor // => false

--
Vyacheslav Egorov


On Tue, Jun 26, 2012 at 5:34 PM, MikeM <[email protected]> wrote:
>> Array function in one context is different from Array function in
>> another context as each context is a separate world with it's own
>> built-in objects.
> Right.  That was the purpose of the ReattachGlobal() in the code.
> My idea (possibly mis-guided), was to re-use the same set of built-in
> objects (or prototypes) between different executions.
> So that instanceOf would work properly.  How can I re-use the same built-ins
> each time?
> I suppose I could keep using the same Context over and over, but I would
> need a way to wipe out any local var declarations between executions and
> only keep the built-ins.
>
>
>> You can use Array.isArray which should work cross-context.
> Also what about strings or custom objects of our own?
>
>   function foo() {}
>   var x = new foo();
>   x instanceof foo;
>
> Thanks!
>
>
>
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to