Think of it this way: dynamic binding no, dynamic assignment yes.

> So this means, no function expressions depending on the condition? I.e.:
> 
> this["foo"] = isDebug ? function () { ... } : function () { ... }

var foo = isDebug ? function() { ... } : function() { ... }

> Or I guess, such cases will be replaced with function statements, right?
> 
> if (isDebug) {
>     function debug() { ... }
> } else {
>     function debug() { ... }
> }

Sure, that would be fine too.

> However, no dynamic function creation anymore (and actually, any binding).

Of course you can still do dynamic function creation. You just can't do dynamic 
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?

For the most part, this will not be possible. You can do it in a phased way, by 
creating the globals dynamically via the module loader *before* evaluating the 
script that wants to use them. E.g.:

    ['Object', 'Array', 'String', 'Function', 
'RegExp'].forEach(function(constructorName) {
        ModuleLoader.defineGlobal('is' + constructorName, function(object) {
            return Object.prototype.toString.call(object) == '[object ' + 
constructorName + ']';
        });
    });

But these globals won't be accessible to scripts that have already been 
compiled; only to scripts that are subsequently compiled and evaluated, e.g. 
via ModuleLoader.eval.

Dave

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

Reply via email to