Here is a link to a documentatin for the weak map based solution that Kris
mentioned:

https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/core/namespace.html

We find it invaluable and use for storing private field. Inheritance works,
but we did not found that feature all that useful in practice, probably
because we use that only for data fields

There is also another experiment that I found to be a lot more useful for
non data properties like methods
https://github.com/gozala/method

I also honestly wish private names would just be it

On Thursday, January 10, 2013, Kris Kowal wrote:

> As an aside, Irakli Gozashvili and I independently realized that you
> could use a WeakMap for parallel objects with inheritance. Very
> similar to Brendan’s createStorage, we put together a parallel
> universe constructor.
>
> function Parallel(root) {
>     var parallel = new WeakMap();
>     root = root || null;
>     function get(object) {
>         if (!parallel.has(object)) {
>             parallel.set(object,
> Object.create(get(Object.getPrototypeOf(object))));
>         }
>         return parallel.get(object);
>     }
>     return get;
> }
>
> Irakli’s was a Namespace constructor that appeared somewhere in the
> Mozilla Add-on toolkit, but the links have gone stale.
>
> Kris Kowal
> _______________________________________________
> es-discuss mailing list
> [email protected] <javascript:;>
> https://mail.mozilla.org/listinfo/es-discuss
>


-- 
Typed on tiny virtual keyboard
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to