On 13.04.2011 23:06, David Herman wrote:
It'll be the WindowProxy as usual, in top level code. Dave has addressed what
it will be in a module recently.
I have to look on Dave's explanation, seems I missed it. But this WindowProxy
won't be assessable then, right? Will it be possible to define a new global
property/variable at all at runtime depending on condition?
I think what Brendan means is that legacy script (that doesn't opt in to the
new version) will continue to be ES5 and will continue to use the window object
as the global scope frame. But the window won't be the global environment
record in Harmony.
In Harmony (as you know, Dmitry), the global scope is separate from the window
object. At Harmony top-level, |this| is bound to an object that reflects the
global scope, but it's not possible to do things like delete bindings from it,
and it's a separate object from the window object.
Yeah, thanks for reminding, Dave. I quote it from the spec-draft (for
others):
"The initial binding of |this| at program top-level is a prototype-less,
non-extensible, non-configurable reflection of the global environment
record. Programs can get and set the global bindings through this
object, but cannot add or remove bindings. "
So this means, no function expressions depending on the condition? I.e.:
this["foo"] = isDebug ? function () { ... } : function () { ... }
Or I guess, such cases will be replaced with function statements, right?
if (isDebug) {
function debug() { ... }
} else {
function debug() { ... }
}
However, no dynamic function creation anymore (and actually, any
binding). I just remember nice snippets such as:
['Object', 'Array', 'String', 'Function',
'RegExp'].forEach(function (constructorName) {
this['is' + constructorName] = function (object) {
return Object.prototype.toString.call(object) == '[object '
+ constructorName + ']';
};
});
which allowed me to create several test-function such as "isString",
"isArray", etc.
Nothing of this anymore in ES6, right?
And another quote from there:
"The initial binding of |this| at module top-level is the module
instance object for that module."
Just wanted to correspond this with the recent class-definition
discussion, when I also proposed that "this-value evaluated in the class
body -- is the class itself", which allows to define elegantly
class/static methods.
Dmitry.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss