Re: Importing global into modules.

2014-10-08 Thread A Matías Quezada
I like this idea mainly because it will allow us to create modules that explicitly define every used reference. This will help tooling detect exactly the source of every value we use. --- A. Matías Quezada Senior Javascript Developer amati...@gmail.com 2014-10-05 17:51 GMT+02:00 Brian Di Palma

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
That was one the intentions but I get the feeling that this change is either too late or far more complex then it seems. In future we might have a use strict or use macros for modules which would enforce this clean slate for modules. It's not a big deal but I would have preferred the use globals

Re: Importing global into modules.

2014-10-08 Thread Andreas Rossberg
On 5 October 2014 17:51, Brian Di Palma off...@gmail.com wrote: 1) I think you mean that a parser wants to fail quickly if it comes across an identifier that was not previously declared as an import but that could be declared as one deeper in the module file? The simple solution to that

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
Hi Andreas, Thanks for the response and explanations. I didn't realize how limited in power these fast parsers actually were, they are basically lexers. So yes this would require more bookkeeping on their part and that would impact performance. I'm doubtful that it would have a significant user

Re: Importing global into modules.

2014-10-08 Thread Andreas Rossberg
On 8 October 2014 14:11, Brian Di Palma off...@gmail.com wrote: I didn't realize how limited in power these fast parsers actually were, they are basically lexers. No, that's not correct. They have to perform a full syntax check. That does not imply binding analysis, though, which is usually

Re: Importing global into modules.

2014-10-08 Thread Kevin Smith
Yes, but unfortunately, you cannot distinguish between the two in JavaScript -- globals, monkey patching, and all that lovely stuff. And polyfilling - exactly. ___ es-discuss mailing list es-discuss@mozilla.org

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
On Wed, Oct 8, 2014 at 1:52 PM, Andreas Rossberg rossb...@google.com wrote: No, that's not correct. They have to perform a full syntax check. That does not imply binding analysis, though, which is usually regarded part of the static semantics of a language, not its (context-free) syntax.

Re: Importing global into modules.

2014-10-08 Thread caridy
last time we discussed this, the conclusion was that `Reflect.global` is the way to go. more details here: https://gist.github.com/ericf/a7b40bf8324cd1f5dc73#how-do-we-access-the-global-object-within-a-module once realms landed, it will reflect `realm.global`. ./caridy On Oct 8, 2014, at 8:52

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
A compiler can convert references like these import {myGlobalFunction, MyPolyfilledConstructor} from @global; myGlobalFunction(42); into global.myGlobalFunction(42); And the global scope can be window for a browser. This code has the exact same semantics as if the global scope was allowed

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
On Wed, Oct 8, 2014 at 2:51 PM, caridy car...@gmail.com wrote: last time we discussed this, the conclusion was that `Reflect.global` is the way to go. more details here: https://gist.github.com/ericf/a7b40bf8324cd1f5dc73#how-do-we-access-the-global-object-within-a-module once realms landed,

Re: Importing global into modules.

2014-10-08 Thread caridy
var myGlobalFunction = Reflect.global.myGlobalFunction; note: you can't use import for global due to the nature of the binding process when importing members or namespaces. On Oct 8, 2014, at 9:57 AM, Brian Di Palma off...@gmail.com wrote: On Wed, Oct 8, 2014 at 2:51 PM, caridy

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
On Wed, Oct 8, 2014 at 3:21 PM, caridy car...@gmail.com wrote: var myGlobalFunction = Reflect.global.myGlobalFunction; note: you can't use import for global due to the nature of the binding process when importing members or namespaces. I find import global from @global;

Re: Importing global into modules.

2014-10-08 Thread Guy Bedford
The global could potentially be available via the this module meta syntax: import { global } from this module; On 8 October 2014 16:34, Brian Di Palma off...@gmail.com wrote: On Wed, Oct 8, 2014 at 3:21 PM, caridy car...@gmail.com wrote: var myGlobalFunction =

Re: Importing global into modules.

2014-10-08 Thread caridy
Guys, anything that you import is going to be subject to the binding process, they are immutable values. In the other hand, Reflect.global is just the new global for scripts and modules, plain and simple. Today, many libraries are relying on `new Function()` to artificially access global, and

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
Does that mean that anything that is imported is frozen? You can't add properties to any binding you import? I've never heard of this restriction before. If that restriction doesn't exist then I'm not sure I see what issue this causes import { global } from this module; global in this case is

Re: Importing global into modules.

2014-10-08 Thread caridy
Brian, my point is that using import to get access to `global` (as you suggested) is confusing due to the nature of the import, remember the contract: to import something, someone else has to export it first :) Aside from that, we don't want to have a exclusive way of accessing globals for

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
On Wed, Oct 8, 2014 at 4:38 PM, caridy car...@gmail.com wrote: Brian, my point is that using import to get access to `global` (as you suggested) is confusing due to the nature of the import, remember the contract: to import something, someone else has to export it first :) The JS

Re: Importing global into modules.

2014-10-08 Thread caridy
what do you mean by: If the desire was there importing the global would also allow static errors on free variables. If we ever decide to allow importing a reference to global from a module, it has to be a named import, and therefore, no static analysis can be applied to its members (since

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
Sorry, I meant free variables inside the module. The reason why I originally started this thread was to ask if importing global references or the global would be a way of adding static checks of free variables in modules. You are right that you can't check properties of the global. Hence the

RE: Importing global into modules.

2014-10-08 Thread Domenic Denicola
Just use JSHint. -Original Message- From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Brian Di Palma Sent: Wednesday, October 8, 2014 12:29 To: caridy Cc: es-discuss@mozilla.org Subject: Re: Importing global into modules. Sorry, I meant free variables inside

Re: Importing global into modules.

2014-10-08 Thread Brian Di Palma
- From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Brian Di Palma Sent: Wednesday, October 8, 2014 12:29 To: caridy Cc: es-discuss@mozilla.org Subject: Re: Importing global into modules. Sorry, I meant free variables inside the module. The reason why I originally started

Re: Importing global into modules.

2014-10-05 Thread Brian Di Palma
I'm probably not understanding all the issues here but I'm also not explaining my suggestion well either. The way I see the two issues you raised is like this. 1) I think you mean that a parser wants to fail quickly if it comes across an identifier that was not previously declared as an import

Importing global into modules.

2014-10-03 Thread Brian Di Palma
The recent thread on throwing errors on mutating immutable bindings touched upon the fact that there is no static unresolvable reference rejection in modules. I was wondering if that was down to needing to allow access to properties set on the global object? If that's the case why could you not

Re: Importing global into modules.

2014-10-03 Thread Brendan Eich
Brian Di Palma wrote: The recent thread on throwing errors on mutating immutable bindings touched upon the fact that there is no static unresolvable reference rejection in modules. I was wondering if that was down to needing to allow access to properties set on the global object? If that's the