Hi, new to v8 embedding here.

I'm having a hard time understanding the difference between v8::HandleScope 
and v8::Context::Scope. Where can I learn more?

As a practical application, what I'm trying to do is to run two classic 
scripts in "implicit" block scopes. (The way that modules are executed, I 
suppose.)

Let's suppose script1.js and script2.js both simply contain "let x = 0". If 
I just run those scripts in the same isolate + context, the second one will 
error with "Identifier 'x' has already been declared".

I'm trying to understand how to "push" a "block scope" around the execution 
of each script, so the moral equivalent of "{ let x = 0 }" is actually 
happening when each script is run.

I tried something like 

{ v8::HandleScope scope(isolate); script1->Run(context).ToLocalChecked(); }
{ v8::HandleScope scope(isolate); script2->Run(context).ToLocalChecked(); }

But it doesn't work, the let x is occurring at the top-level, not in a 
scope, and the second script errors about the duplicate declaration.

How can I solve this immediate problem, and how can I learn more on my own? 
The source code is not particularly illustrative, and no blog posts I can 
find go deep enough. Is there a deeper reference manual or book somewhere?

Thanks.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/ae973a53-0838-40a3-859d-c7afd7854d99n%40googlegroups.com.

Reply via email to