Two different use cases for privacy?

Axel Rauschmayer axel at rauschma.de
Mon Mar 25 00:53:39 PDT 2013


It seems to me that there are two different use cases for privacy:

Use case 1: Hide some properties from the outside (when listing properties or getting expansion help from an IDE). Many people use a naming convention here (e.g. a prefixed underscore). This hiding does not have to be completely safe. There could be methods that list all property keys, even hidden ones. Hiding is more like a hint (“you don’t normally need to look at this”) than actual protection.

Use case 2: Keep data completely safe inside an object.

#1 is very similar to the [[Enumerable]] attribute (if it was used slightly differently and more consistently). Symbols already almost serve this use case, because they are hidden from current ways of listing property keys. But you don’t want to hide some of the public symbols such as @@create. Hence, all that would be needed would be a flag, as a hint for IDEs and functions that list property keys.

#2 could be handled via WeakMap.

Do I see this correctly?

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130325/7181f5e8/attachment.html>


More information about the es-discuss mailing list