5 ms·
Unambiguous JavaScript Grammar
- wereHamster 10y agofunction foo(value) { value = value || ''; var args = [].slice.call(arguments); args.unshift(this); return args; } foo(null); export {}; If your module does nothing but side-effects during load time, screw you.
- jdd 10y agoThat's generally and edge case and totally supported under the proposal by being explicit about with respect to `export`. I think being explicit about the intent of your code is a good thing after all.
- gcb0 10y agoyeah, i just use it for scripting browsers, which don't support most of that shenanigans. for real work i use languages that are not a week old. I have no idea what exactly is being discussed there, other then it requires a syntax hack with `exports {}` to break the new standard.
- Wintamute 10y ago> I have no idea what exactly is being discussed there Criticizes it anyway .. something something JS is bad. Thanks for your high level input.
- nv-vn 10y agoWhy can't this be done as a module declaration? I.e. a file would be prefaced with `module Main;` to declare that it's a module and give it a name.
- aeosynth 10y agoThat requires modification to every file using ES modules, and new syntax. The proposed solution only requires modifying files which do not have an import or export statement, and does not need new syntax.
- olliej 10y agoAuthor seems to be mostly concerned by code loaded as a module being treated as strict 100% of the time. Literally every difference that they list is strict mode (and the usual misunderstanding of |this|)
- simplify 10y agoWhat usual misunderstanding of |this| are you referring to?
- dclowd9901 10y agoMight mean that in a module, `this` represents the environment the module was loaded in (rather than `undefined`), or `window|global` if not modularly loaded? I'm not sure either....
- olliej 10y agoPeople keep trying to apply lexical scope for |this| when it is always the left hand of the function refernece expression, e.g. Lhs.foo() Lhs[foo]() And Foo() // where lhs is implied to be the scope object defining Foo The last one seems to be what makes everyone super confused, but it is logically: GetScopeWith("foo").foo() Strict mode changes /one/ thing about|this|: whether the value of |this| undergoes object coercion
- deleted 10y ago[deleted]
- cwmma 10y agoYes that is the main difference along with top level return statements
- ryanlm 10y agoWhere is the BNF?
- coldtea 10y agoThere's no BNF, this is not a language spec or full grammar, it just describes an addition to the existing grammar to denote a module.
- citrusx 10y agoWho else thinks that this whole mess around trying to implement ES modules demonstrates that they were a bad idea to begin with?