How to ensure that your script runs first in a webpage
Sam Tobin-Hochstadt
samth at ccs.neu.edu
Sat Feb 4 20:23:14 PST 2012
On Sat, Feb 4, 2012 at 1:02 PM, David Bruant <bruant.d at gmail.com> wrote:
> Le 04/02/2012 18:14, Mark S. Miller a écrit :
>> c) The ES6 module loader should make all these with-games unnecessary
>> anyhow, since it gives us a principled approach for controlling the
>> top level scope of untrusted code. Long term, this is the real answer.
> Ok, good to know.
> Can you show how "eval(string, lexEnv)" example would look like with
> module loaders? The proposal [1] (and the entire web?) lacks a bit of
> examples.
There's an examples page which includes some module loaders examples
(although not this one) [1].
I'm imagining that |lexEnv| is the entire environment that you want
available for this evaluation, ie, it shouldn't see any other
bindings. For this, we'd do the following:
let l = new Loader(system /* the parent loader */,
null /* make fresh intrinsics */,
lexEnv /* use lexEnv as the global scope */);
l.eval(string);
Note that this is slightly different than the API currently described
on the web page; Dave and I have updates that we need to make there.
[1] http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples
--
sam th
samth at ccs.neu.edu
More information about the es-discuss
mailing list