On 24 January 2012 20:24, Brendan Eich <[email protected]> wrote:
> I am skeptical we will banish var, ever. Consider the object detection
> pattern:
>
>  if (!this.foo) {
>    var foo = function () {
>      ...
>    };
>  }
>
> No way to make this work with let.

Actually, it is possible if this is a check for a primordial, and you
move them to the prototype of global this and allow shadowing them.
Then you'd be able to write:

let foo = Object.getPrototypeOf(this).foo || function() { ... }

(I think we had something like this on the board once.) Or, in the
browser, if window was actually bound to that prototype, this
simplifies to:

let foo = window.foo || function() { ... }

I don't think compatibility can afford binding window to something
different than global this, though. (One could still pre-bind the
prototype to a different name, however.)

Of course, I sincerely hope that the module system will provide a more
pleasant replacement for this pattern. :)

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

Reply via email to