On Sep 10, 2014, at 9:41 AM, John Barton wrote:

> 
> 
> 
> On Wed, Sep 10, 2014 at 9:35 AM, Allen Wirfs-Brock <[email protected]> 
> wrote:
> 
> On Sep 10, 2014, at 9:28 AM, Matthew Robb wrote:
> 
>> As soon as the language decided it would have a differentiation for modules 
>> vs scripts then it seems only natural that it should also specify at least 
>> some generic means of entry into one mode or another. Then it's up to 
>> browsers or who ever to determine what external signifiers would trigger 
>> module instead of script. Or the language parsing logic could say that in 
>> the presence of module syntax it will always be treated as module. I don't 
>> know if that's feasible or not *shrug* 
>> 
> 
> Modules and scripts can not always be identified by inspection.  Consider:
> 
> foo.js -------------------------------
> const answer = 42;
> ---------------------------------------
> 
> The semantics of this are quite different depending upon whether foo.js is 
> evaluated as a script or loaded as a module.
> 
> This case is clearly as script, as a module it has no effect right?  Isn't 
> the only ambiguous case would be explicit global manipulation, where we could 
> decide module is used and (most of the time ;-) win.

so make it:

foo.js -------------------------------
const answer = 42;
bar();
---------------------------------------

now whose mind are you going to read to decide if it is intended to be a module 
or script.

Plus, there is the dream that over the long term, modules (including script 
like modules) will completely displace scripts for new code which means we 
would have an always "strict" world for new code.

From that perspective, if we want to informally debate file extensions to 
distinguish such new usage from legacy usage, I suggest "js2" as the extensions 
for source files that are intended to be parsed using the ES grammar  Module 
goal symbol.  This but the focus on "new style" vs "old style" rather than the 
subtle distinction between Script and Module.

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to