Minor questions on new module BNF

Jeff Morrison lbljeffmo at gmail.com
Mon Jun 3 14:11:27 PDT 2013


Big +1 on being able to defer execution until explicit import. It 
definitely seems useful to allow for control over dependency 
specifications separately from [potential] dependency execution. More 
concretely, I don't think you could do something like the following with 
the current module spec (correct if wrong):

exports.foo = function() {
   var bar = require('bar');
   bar.baz();
}

What about specifying some form of hoisting for ImportDeclarations so 
that dependencies for a module can be declared separately from their 
execution? This would still allow for compile-time resolution and 
linking while also addressing concerns about runtime-conditional 
dependencies...

-Jeff

On 6/3/13 9:33 AM, Yehuda Katz wrote:
> On Mon, Jun 3, 2013 at 12:24 AM, Domenic Denicola 
> <domenic at domenicdenicola.com <mailto:domenic at domenicdenicola.com>> wrote:
>
>     From: samth0 at gmail.com <mailto:samth0 at gmail.com>
>     [mailto:samth0 at gmail.com <mailto:samth0 at gmail.com>] On Behalf Of
>     Sam Tobin-Hochstadt
>
>     > The idea here is that modules will typically be written in files
>     like "compiler/Lexer.js", where the starting grammar production
>     *is* `ModuleBody`.
>
>     Ah, that makes sense! It's a nice way of prohibiting
>     `<script>export function foo() { }</script>` as well, assuming
>     inline `<script>` corresponds to `Script`. It would be helpful to
>     update the wiki with this, or more generally to show how this
>     grammar will integrate with the rest of the grammar.
>
>     > I would just write `import {} from "someModule";`
>
>     That appears to be disallowed; I believe
>
>         "{" ImportSpecifier ("," ImportSpecifier)* ","? "}"
>
>     requires at least one `ImportSpecifier`. (It's also sad and ugly;
>     any reason not to allow `import "someModule";`?)
>
>
> I've advocated for this in the past. I believe it should be allowed.
>
> Separately, I would like this form to be specified as deferring 
> execution until bindings are explicitly imported (from another 
> module), or a synchronous `System.get` call is made.
>
> This would make it possible to guarantee that a synchronous 
> `System.get` will succeed, without being forced to execute the module 
> first.
>
>     _______________________________________________
>     es-discuss mailing list
>     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>     https://mail.mozilla.org/listinfo/es-discuss
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130603/604e585c/attachment.html>


More information about the es-discuss mailing list