Putting `global` reference in specs

Domenic Denicola d at domenic.me
Fri Apr 17 17:11:30 UTC 2015


One thing I'm surprised nobody has brought up yet is that "global" would be an incorrect name in the case of browsers. The actual global object is not (and must never be) directly accessible. Instead you get a window proxy when you use `window`, `self`, `this`, etc.

As such I think our best bet is for server-side JS runtimes to use `self` or `window`.

The latter isn't as crazy as it sounds: just start adding phrases to the ES spec like "all JavaScript code runs within a certain context, called a _window_, which has a corresponding _window object_. In some runtimes the window object will be equivalent to the global object, but not always. Scripts run within _window scope_, whereas modules run in their own lexical context. The value of **this** in window scope is the window object."

It's not as if `window` actually means "window" anymore, given tabs and iframes and frames. We might as well move it into the set of terms like "realm" or "vat" or "environment" that are more abstract than real.

-----Original Message-----
From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Anne van Kesteren
Sent: Friday, April 17, 2015 11:19
To: Andrea Giammarchi
Cc: es-discuss at mozilla.org
Subject: Re: Putting `global` reference in specs

On Fri, Apr 17, 2015 at 5:12 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:
> So I'd say we should not have `self` (if stays on global and Worker I 
> don't actually care) and add a `global` that nobody needs explanation 
> to understand what it is in JavaScript

Indeed, three ways to reference the global object is not nearly enough.


--
https://annevankesteren.nl/
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list