David Herman wrote:
I can mostly dig it -- I've been trying to encourage minimal classes for
quite some time now.
The part that I'm least happy about is that this doesn't allow for
declarative private methods, because if we had the computed syntax like
what we're adding to object literals, it would clash with hoisting:
{
let priv = new Name();
class C {
// oops, priv is still undefined!!
[priv](x, y, z) {
return x * y / z
}
}
}
Maybe too brittle, but since (I see that) classes are sugar for creating
a function with appropriate [[Prototype]] and .prototype _and_also_
populating the prototype, you can do hoisting the same way as you do for
other elements (have a dead zone, hoist declaration, do not hoist
prototype population), so that it would de-facto be:
{
let priv;
let /* function */ C; // sort-of
priv = new Name;
C = function (/*ctr_params*/) /*extends C_superclass*/ {/*ctr_body*/};
C.prototype.{
[priv](x, y, z) {
return x * y / z
}
}
}
which works.
I do think that class declarations should be hoisted, both in the sense
of being in scope for the whole containing block (as with let and
function) and in the sense of being initialized before the block begins
executing (as with function).
Dave
Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss