The class operator: a bridge between object and function exemplers

Allen Wirfs-Brock allen at
Thu Nov 17 17:51:21 PST 2011

On Nov 17, 2011, at 11:21 AM, Russell Leggett wrote:

> sorry that last one didn't go to the group - ignore. This new gmail interface screwed me up ;)
> On Thu, Nov 17, 2011 at 2:20 PM, Russell Leggett <russell.leggett at> wrote:
> At this point, if Allen's proposal included a declaration form 'class Point {...}' I would be ready to get behind it. I still have a fondness for mine, which is used purely for defining classes, but for most cases, his would work equally well in the ways I would want to use it.

Here a first (for me for this form) cut:

class AbstractPoint { }


class Point AbstractPoiont <| { }

where the syntax of the second is:

classPoint Identifier MemberExpression <| LiteralObject

This means exactly:
let Identifier = class MemberExpression <|  LiteralObject

(may need some grammar engineering because MemberExpression can contain a <|)

The expression form remains exactly as I've already defined in it 

Strictly speaking the <| is unnecessary and could be implicit.  I like requiring it because  it maintains symmetry with the expression form. 

For the relatively rare situations where "class-side" methods are needed they could be provided as part of the ObjectLiteral, as:

class Point AbstractPoiont <| { constructor() {}. {origin() {return new  this(0,0)}} 
   //class methods are just properties on the constructor function


> - Russ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list