Classes: suggestions for improvement

Axel Rauschmayer axel at rauschma.de
Sun Jun 12 15:49:08 PDT 2011


>> and the "static" keyword for defining class properties are welcome additions.
> 
> Why "static" is the wrong word: there is nothing compile-time about the class properties. Classes are expressible (anonymous, even), as well as declarable in nested (generative) ways.
> 
> Using "class" does not work if one wants nested classes, although the default that binds prototype properties for ExportableDefinitions including Declarations seems like exactly the wrong default: how often do you want class Outer { class Nested {} ... } to make Nested a property of Outer.prototype, instead of a class property (Outer.Nested)?
> 
> Again, the grammatical retasking of certain Declarations to bind prototype properties (instead of lexical bindings in the class body, or perhaps class properties -- but perhaps not) seems like a mistake.


Terminology-wise, I have always avoided the word “class” in JavaScript and used the word “type”, instead (with, roughly, constructors implementing types). I call Properties such as Math.PI type variables. Then you can also talk about subtyping (instead of subclassing).

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com





More information about the es-discuss mailing list