On Thu, Jun 19, 2014 at 10:53 AM, Matthew Robb <matthewwr...@gmail.com>
wrote:

> What if the `import "module/id";` form was an expression that evaluated to
> the module instance object.
>
> This means everything stays as it is now except we remove the ModuleImport
> form and if you want to use the module instance object you can do: `var foo
> = import "foo";`. You could also do `var { bar } = import "foo";`
>
>
This is essentially identical to System.get("foo"), other than the
restriction on the argument being a string.  It lends itself to imperative
code when what you're after is a declarative syntax.

Making it an expression also means it's not a toplevel form in the grammar,
and so you could do things like this:

function foo() {
  if (someCondition)
    return import "module1";
  else
    return import "module2";
}

or even similar to your examples:

var { bar } = someCondition ? import "foo" : import "bar";

which would make precise and static computation of the set of imports
impossible, and likely complicate module resolution as well.

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

Reply via email to