Finding a "safety syntax" for classes

Brendan Eich brendan at mozilla.org
Sat Mar 24 22:54:31 PDT 2012


Allen Wirfs-Brock wrote:
> To actually add a computed function as the value of a prototype object 
> property within the class definition is pretty much the same thing as 
> defining an arbitrary valued  prototype data property.  Defining 
> non-method prototype properties is one of the features that we have 
> previous been unable to reach consensus on and for that reason was 
> intentionally excluded from the maximal-minimal proposal. As the 
> proposal says:
>
>   * "There is (intentionally) no direct declarative way to define
>     either prototype data properties (other than methods) class
>     properties, or instance property"
>   * "Class properties and prototype data properties need be created
>     outside the declaration."
>

Thanks, and I'm hip to this already and agree with the design. The 
consequence for Nadav's scenario is that the whole prototype must be 
computed, via extends as you note, or just manual desugaring.

It's the right trade-off, and not just to get appropriately minimal 
classes into ES6 -- the computed method case is often part of a 
generative framework anyway, so won't obviously fit  into any general, 
declarative syntax.

At least, this is my gut reaction -- but it would be helpful to see a 
concrete example in the wild (not contrived) and look deeper.

/be


More information about the es-discuss mailing list