John J Barton wrote:
On Thu, Mar 22, 2012 at 4:54 PM, Brendan Eich<bren...@mozilla.org>  wrote:
John J Barton wrote:
If I go back to my previous question, can we understand what should happen
here?

if (version === 1)
  import y from 'lib1.js';
else
  import y from 'lib2.js';
Again, no.

No, we can't understand this case? No, this is a compile error?

Compile error currently -- import is legal only at top level of a module or program.


1. We are not breaking run-to-completion by nesting (conditionally on
control flow) blocking event loops.

Where is the blocking event loop in the example above? I thought you
said the modules are pre-fetched.

You wrote that if-else, not me. If you think the author should face prefecthing *both* lib1.js and lib2.js even though only one (depending on runtime control flow) is needed, good luck selling that.


2. Also we are not losing static binding by having the names injected by
static syntactic forms depend on control flow dynamics.

Well the example has control flow dynamics and names, so what happens?

It's invalid syntax per the current proposals. If you want to prefetch both, tell me which bindings are in effect statically? Both modules' bindings? What if they conflict on a given name?


Seriously, you want something that is not tenable for developers or browser
implementors. Both 1 and 2 matter. You might argue 2 is not important but 1
remains. TC39 wants dynamic things to be dynamic (modules reflect when
passed to load callbacks as objects with properties), and static things to
bind statically.

I'm not arguing for anything other than clarification.  Hopefully
someone will just tell me that import statements can never appear in
if statements.

That's what the current grammar says:

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

/be


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to