Class literals: does "public" still make sense?

Kam Kasravi kamkasravi at
Sun Sep 25 20:31:05 PDT 2011

I see, so private declarations may go back to being defined at the class level - at least semantically - in order for the private name to be in scope 
across the class eg this[heath] referenced in Monster prototype methods: get isAlive(), Monster.set health(). 

From: Brendan Eich <brendan at>
To: Kam Kasravi <kamkasravi at>
Cc: Mark S. Miller <erights at>; Axel Rauschmayer <axel at>; es-discuss <es-discuss at>
Sent: Sunday, September 25, 2011 8:10 PM
Subject: Re: Class literals: does "public" still make sense?

On Sep 25, 2011, at 3:12 PM, Kam Kasravi wrote:

class Monster {
>  // The contextual keyword "constructor" followed by an argument
>  // list and a body defines the body of the class’s constructor
>  // function. public and private declarations in the constructor
>  // declare and initialize per-instance properties. Assignments
>  // such as " = bar;" also set public properties.
>  constructor(name, healthvalue) {
>    public name = name;
>    module name from "@name";
>    private health = name.create();
No, that's silly. If there is to be private declaration syntax, it should generate the private name, class-private (shared among instances). What you just spelled out wants 'const' not 'private', but hoisted to an outer closure. The way you wrote it, each constructor call would make a new and unique private name, so you'd get instance-private instance variables, not class-private.

    this[health] = healthvalue;
This part is what we agreed to in July.

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

More information about the es-discuss mailing list