Private Slots

Kevin Smith khs4473 at gmail.com
Mon Jan 14 19:19:48 PST 2013


> In order to satisfy security guarantees, properties which are keys on
> > private symbols are not returned by getOwnPropertyNames.
>
> That's why the methods are bound to the original object.
>

Regardless of the "this" binding, the privately keyed method will not be
copied over from the source object and hence will be undefined when called.


> You'd probably make the point that having private symbols around
> introduces these kinds of confusions.


Well, yes, there is certainly that.  It's best not to have features which
are superficially very similar but are quite different in actuality (e.g.
unique vs. private names).  But that's not my main point.


> My opinion is I don't think it's that hard to learn how private symbols
> work and develop a consistent approach to mixins if you want to use them.
>

OK - but that consistent approach will be to not use private methods at all
in if you want your classes to be mixable.  That's a big asterisk next to
the private symbol feature.

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130114/feed31bd/attachment.html>


More information about the es-discuss mailing list