> Just to contribute to this... er... fun-thread...
> 
> My team uses the closure pattern for our "classes" (i.e. no prototype methods 
> at all), since we value encapsulation. I can't imagine we're alone.

Do you see privacy via closures and prototypes as mutually exclusive? In my 
experience, they work well in combination. Do you add all of your methods to 
the instance? That would have the advantage of making it easier to access 
private data from public methods, but would consume more memory.

> So any class solution that doesn't fully incorporate private names (e.g. by 
> making them awkward via manual Name.create(), etc.) will leave that audience 
> behind, still using closures and ignoring any new class sugar.


True. Something along the lines of:

    class C {
        private {
            age, strength
        }
        /* syntactic sugar for
        module name from "@name";
        var age = name.create();
        var strength = name.create();
        */

        // private method
        @incAge() {
            this.@age++;
        }
    }


-- 
Dr. Axel Rauschmayer
a...@rauschma.de

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

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to