ES Modules: suggestions for improvement
Brendan Eich
brendan at mozilla.org
Wed Jun 27 09:27:25 PDT 2012
Kevin Smith wrote:
>
> The other point people seem to miss about import as a special
> binding form is not just that it can be restricted grammatically
> to be control-insensitive by construction: it's that static export
> vs. import checking can be done to catch typos.
>
>
> As long as the exported names are static, it's possible to catch typos
> using Isaac's form as well though, right?
Not as I understood Isaac's proposal:
|---|
// x.js
export { real: 'x' }
|---
// y.js
var x = import './x.js'
obscured_call(x)
assert.same(x.real, 'x')
x.typo // undefined, not an early error
---
|
obscured_call could have deleted the 'real' property, and added (or not)
'typo'. There is no way in general to statically check property
references in JS. Static analysis is by definition approximate and while
we have some hot analyses in SpiderMonkey and (to be brought back up
soon) DoctorJS, they are way too much to mandate in the standard.
/be
More information about the es-discuss
mailing list