Sep 27 meeting notes

Russell Leggett russell.leggett at gmail.com
Thu Sep 29 07:20:59 PDT 2011


On Wed, Sep 28, 2011 at 10:40 PM, Oliver Hunt <oliver at apple.com> wrote:

>
> Given our apparent desire to have a declarative syntax i don't see why
> something akin to:
>
> class Foo {
>    var bar; // default value -> undefined
>    var wibble = 5; // initialised fields desugar to statements at the head
> of the constructor
>    const wiffle; // read barrier on uninitialised
>
>    function someMethod(..) {
>         this.bar = foo; // could have a short hand for this.property
>    }
>
>    constructor (bar, wibble) {
>        // extra typing due to the removal of horrible punning
>        // but "public bar = bar" or whatever that syntax was is longer
>        // than this.bar
>        this.bar = bar;
>        this.wibble = wibble;
>    }
> }
>
> function's get shoved on to the prototype chain, and fields go on the
> instance, inheritance follows reasonably sensibly from that.  Remove the
> declarative field definitions and you have essentially got python's class
> model, which seems to be well accepted by a wide array of people, otherwise
> the question becomes one of how much you want to lock down the resultant
> object shape.
>
> --Oliver
>
>
Hi, just a voice from the peanut gallery - of the proposals going on right
now, I really like this proposal a lot. Perhaps it is just my experience
with Java, but this feels like an intuitive class syntax that also stays
feeling like JavaScript. I like that it doesn't introduce a new keyword
"public" which I especially didn't like because there was no "private"
keyword.

In regards to private fields/methods in classes, I did also have a thought
that perhaps you could use proxies to provide a peephole view of a class
instance. Basically, the thought being when you say "new Foo()" it creates a
new instance, then wraps it in a proxy exposing only the public
fields/methods and returns that. Internally, the methods can still access
the private (unexposed) members, but from the outside, with access only to
the proxy, they would be hidden. I think this would avoid the need for the
private key feature that has also been proposed.

Thanks,
Russell Leggett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110929/da7d5c51/attachment.html>


More information about the es-discuss mailing list