Ducks, Rabbits, and Privacy

Benoit Marchant marchant at mac.com
Tue Jan 22 19:54:12 PST 2013


My initial reaction:

- Hosting getPrivate/setPrivate on Object seems quite strange to me.
- it seems unrealistic to me to ask developers to write so much code every time they want to use their own private instance variable. The notion of Private should be specified once for an instance variable, not every time it's used internally
- I haven't followed the whole thread and I'm not a language developer. I never felt that I needed a private data structure to hold  internal "stuff". One can already do that with a closure and a WeakMap manually if one really wants it
- I do want private instance variables that allow me to truly have encapsulation.

Thanks,

Benoit 

On Jan 22, 2013, at 19:28, Kevin Smith <khs4473 at gmail.com> wrote:

> A Duck/Rabbit Proposal:
> 
> 1) There is only one kind of Symbol
> 2) Private data can be accessed via Object.getPrivate and Object.setPrivate
> 
> The goal is to provide a base-level API from which higher-level abstractions can be built.
> 
>     // === Basic example ===
>     var symbol = new Symbol(), obj = {};
> 
>     // Setting private data:
>     Object.setPrivate(obj, symbol, {});
> 
>     // Getting private data:
>     var data = Object.getPrivate(obj, symbol);
> 
> Note that this does not preclude the possibility of full private symbols in ES7.
> 
> More at:
> 
> https://gist.github.com/4601469
> 
> { Kevin }
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130122/fdc575f6/attachment.html>


More information about the es-discuss mailing list