Minimalist Classes

Axel Rauschmayer axel at rauschma.de
Tue Nov 1 20:58:17 PDT 2011


I really hope that “let is the new var” will hold and won’t be replaced with “let is the new var, except for class declarations and global variables”.

One more possibility (in addition to not writing anything at all and using let instead of var):
class C {
    public x = 0, y = 0; // the analog to private
    const foo = "abc";
}

Two more thoughts:
- We are becoming more verbose than object literals (with either var or public). I had hoped that we could preserve their lightweight spirit.
- How often will one define non-function prototype properties? It could even be considered an anti-pattern. That might make it easier to decide on verbose syntax.

> I also prefer var since it fits better with const.
> 
> class C {
>  var x = 1;
>  const y = 2;
>  ...
> }
> 
> is better than
> 
> class C {
>  x = 1;
>  const y = 2;
>  ...
> }
> 
> Another problem with skipping var (which we saw in Traceur) was that
> without both var and initializer it looks really strange.
> 
> class D {
>  z;
>  ...
> }

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111102/71173b84/attachment.html>


More information about the es-discuss mailing list