Claude Pache wrote:
A simple solution is to make:
class Foo { /* ... */ }
equivalent to:
const Foo = class Foo { /* ... */ }
instead of the equivalent desugaring with `let`.
The ES6 design has "classes as sugar", which is an imprecise slogan, but
useful. For some reason we settled on a mutable outer binding in block
scope: let not const. That "some reason" may have been the expectation
that classes desugar to prototypal
function-as-constructor-with-prototype-properties lowerings, but still:
no reason given ES6 const and let to prefer let.
I suspect it'll be hard to change anything for ES6 at this stage,
especially to make class bind a const instead of a let binding -- but
your point still stands:
That way, anyone who want to play with a same-named external binding must be
explicit about their intention:
let Foo = class { /* ... */ } // one binding
let Foo = class Foo { /* .... */ } // two bindings
Anyone who wants to support replacement-for-wrapping will have to use
the first form.
Let's see if this becomes the norm, on that basis. I hope it doesn't,
because if so, we picked the wrong (two-binding-not-one) desugaring.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss