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.