Harmony:classes static and private

Juan Ignacio Dopazo dopazo.juan at gmail.com
Wed Jun 8 12:41:39 PDT 2011


On Wed, Jun 8, 2011 at 3:13 PM, Bob Nystrom <rnystrom at google.com> wrote:
>
> That's better, but "public" and "private" are still less than ideal
> keywords here since Javascript's use of them is distinctly different from
> other languages. Alas, they were the best we could come up with.
>

"public" confuses me because its name is related to access control. And
because the following doesn't make any sense and I expected to be able to
declare a private instance property:

*class *Monster {
    *private public* health = 10;
}

So, taking a page from CoffeeScript's for own ... in extension, what do you
think about this?

*class *Monster {

    *private own* health = 10;

    *private static *allMonsters = [];

    *own *id;

    constructor() {
        *this*.id = Monster.allMonsters.length;
        Monster.allMonsters[this.id] = this;
    }

}

Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110608/d5a869ca/attachment.html>


More information about the es-discuss mailing list