Enumerability

Axel Rauschmayer axel at rauschma.de
Fri Jan 10 14:40:31 PST 2014


> The ES6 class specification originally made  prototype methods (we didn't have static methods at the time) non-enumerable.
> 
> That was changed at the Sept 19, 2012 TC39 meeting https://mail.mozilla.org/pipermail/es-discuss/2012-September/025231.html

It may make sense if enumerability was repurposed as a runtime flag for privacy (in the sense of “you don’t need to know about this property/method”). That would nicely complement TypeScript’s static-only (= non-runtime) `private` keyword. It’s one of the two – largely orthogonal – use cases I see for privacy:

1. Completely protecting data from “external” access. In ES6, one can use WeakMaps and closures for this.
2. Encapsulation: Hide internal properties from sight, document internal-ness. If it’s advisory only then you can still write “friend” functions etc, without too much of a fuss.

### I’m looking for a simple explanation of what enumerability will be, going forward. If there isn’t one then I’d argue that no new feature should be influenced by it.

-- 
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/20140110/bb2cdf85/attachment.html>


More information about the es-discuss mailing list