Complete Minimal Classes

Herby Vojčík herby at
Sat Apr 7 13:17:43 PDT 2012

I have actually looked at the links (I confess I did not want to browse 
though another way to ruin (nearly a) consensus on max-min), and I must 
admit I like it.

Only things that bothers me a bit (except the inconsistent new keyword) 
is the potential ambiguity - I can add method to body, but (since I 
presume prototype and static block and fully-blown object initializers 
(if not, I take it back and I do not like it)) also to prototype / 
static block, as I see fit.

So I can write (comments snipped):

class Monster {

   new(name, health) { = name;
     this[pHealth] = health;

   prototype {
     attack(target) {
       log('The monster attacks ' + target);

     get isAlive() {
       return this[pHealth] > 0;

     set health(value) {
       if (value < 0) {
         throw new Error('Health must be non-negative.')

       this[pHealth] = value

     numAttacks: 0,
     attackMessage: 'The monster hits you!'

   static {
     numMonsters() {
       return this.allMonsters.length;

     allMonsters: []

if I see it as a layout I like more.

And so there can be two kinds of writing down the class and reader will 
need to switch PoV if reading one from the opposite "school".

Otherwise, nice (again, if prototype/static are full-blown object 


Kevin Smith wrote:
> Looking at Allen's collection classes, it's clear that our maximally
> minimal classes aren't sufficient for describing a large subset of the
> classes we might want to create.  As a general goal, I think that a
> complete class syntax should be able to express all of the external
> interface of the class, for all except a small set of edge cases.  I
> believe the following features are missing:
> 1) A way to add methods to the constructor.
> 2) A way to add arbitrary properties to the constructor.
> 3) A way to add arbitrary properties to the prototype.
> I'd also like to add a fourth feature:
> 4) The ability to separately define the [[Call]] and [[Construct]]
> behavior of the constructor.
> I've created a couple of gists with a variant of our minimal classes
> which is intended to provide these features:
> I've used "static" as a keyword.  I know it's a misnomer - but it's not
> too bad as misnomers go.  I've also left out private members and private
> names, as IMO they are an orthogonal concern.
> Let me know what you think - and thanks for your time everyone!
> kevin

More information about the es-discuss mailing list