Private Slots

Russell Leggett russell.leggett at gmail.com
Wed Jan 16 12:57:51 PST 2013


On Wed, Jan 16, 2013 at 3:48 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Mark S. Miller wrote:
>
>> My position on private symbols.
>>
>> My position on classes is and has always been that classes are worth
>> introducing into the language*only*  if they give us, or can be used
>>
>> with, an affordable means for true object encapsulation. Assuming
>> Allen is right about what actual implementors will do (which I find
>> plausible) then WeakMaps are not that means. Given other discussions,
>> I am confident that the objects-as-closures pattern will not become
>> efficient either -- it is likely to continue to cost an allocation per
>> method per instance as its semantics naively suggests. So of the
>> options practically on the table, I think private symbols are the only
>> workable choice. If this is correct, then I consider private symbols
>> to be a requirement. Am I missing anything?
>>
>
> I agree, but David Bruant is arguing for weakmap-with-hint still, and
> Kevin is arguing (my summary) "YAGNI" to high-integrity privacy, not
> exclusively but for most developers -- and for the SES minority, weakmaps
> are enough.


I think Kevin's argument is pretty strong. SES is definitely not everyone,
and unique is pretty powerful, especially if you make the slot
non-enumerable. The when in doubt... argument has been made. ES6 is pretty
stuffed as it is. Thinking about ES7, though, I thought of a possibly
interesting place that might be more fitting for private style slots.

I've thought about the tradmark(
http://wiki.ecmascript.org/doku.php?id=strawman:trademarks) proposal a lot,
because I keep hearing the notion of a brand being used as a reason for a
private symbol. Perhaps branding could be implemented with private
symbols... *or* perhaps high-integrity privacy could be related with brand.
A brand could open the door to ADT/typeclass/protocol style abstractions,
and perhaps that is a better location for privacy.

- Russ


>
>
> /be
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130116/f0d5d523/attachment.html>


More information about the es-discuss mailing list