> Stupid question - is the following form of (Python-ish) import > possible (from the grammar it doesn't look like it): > > [snip] > > Or is it the case that with a module {...} declaration the module is > immediately accessible in the scope it was declared in - and no import > required if module.function syntax is used: > > <script type="harmony"> > // Math module declared above - no import needed > > alert("2π = " + Math.sum(pi, pi)); > </script>
The latter, yes. Since modules are bound in the scope chain, they're already available for use as values. This makes it very convenient to reflect them as first-class values: var x = Math; alert(x["sum"]); // function(x,y) { ... } alert(x["thisIsNotDefined"]); // undefined But since module instance objects are immutable, it's also easy for implementations to make static uses, such as your example above, as efficient as if they had been explicitly imported. Dave _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss