Modules and eval

Erik Arvidsson erik.arvidsson at gmail.com
Mon May 2 12:50:18 PDT 2011


http://wiki.ecmascript.org/doku.php?id=harmony:modules
http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders

The loader says that eval and evalLoad uses Program which allows
export and import. What does it mean to import and export something
within eval code?

Take this small program. Does this fail or not?

module m {
  export function addExport(name) {
    eval('export var ' + name + ' = ' name)
  }
  var x = 42
}

m.addExport('x')
assert(m.x === 42)


-- 
erik


More information about the es-discuss mailing list