The class operator: a bridge between object and function exemplers

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Nov 19 08:51:13 PST 2011


I updated the strawman with a declaration form of the class operator: http://wiki.ecmascript.org/doku.php?id=strawman:class_operator#a_binding_declaration_form 

the strawman is somewhat different from what I described below.

Allen

On Nov 17, 2011, at 5:51 PM, Allen Wirfs-Brock wrote:

> 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 gmail.com> 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 { }
> 
> and
> 
> 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 http://wiki.ecmascript.org/doku.php?id=strawman:class_operator 
> 
> 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
> 
> Allen
> 
> 
> 
> 
>> 
>> - Russ
>> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111119/0aac46a7/attachment.html>


More information about the es-discuss mailing list