Private Names and Methods

David Bruant bruant.d at gmail.com
Fri Apr 6 16:06:17 PDT 2012


Le 07/04/2012 00:57, Allen Wirfs-Brock a écrit :
>
> On Apr 6, 2012, at 2:57 PM, Axel Rauschmayer wrote:
>
>> I was thinking about Allen's
>>
>>     class Sub extends mixin(Jane, Jack, Super) {
>>     }
>>
>> Which could have the following prototype chain.
>>
>>     Sub -> Jane' -> Jack' -> Super.prototype
>>
>> A method in a module that works like Prototype's Object.extend(), but
>> copies private properties should suffice.
>>
>> Variations:
>> - Copy Jane and Jack into the same object.
>> - Use a class declaration to define the mixins Jane and Jack. Then
>> the prototype chain is
>>         Sub -> Jane.prototype' -> Jack.prototype' -> Super.prototype
>
> I think there is another approach that doesn't require copying.  Use a
> proxy to define a synthetic prototype object that delegates to one or
> more mixin providers:
>
>     Sub -> synthesized-mixin-delegator-> Super.prototype
>                            |                  |
>                           V                 V
>                       Jane            Jack
>
> This is off-the-cuff so I haven't worked out the details but I think
> it /almost/ works.  I think it /will/ work for string-keyed
> properties.  Unfortunately, as currently specified it won't work for
> private name properties because the proxy traps that would need to do
> the delegated sideways property lookups are not passed the actual
> private name object.  Instead they are passed a surrogate that can be
> matched against a known private name but which can't be used for a
> direct property access.  There might be ways to fix that which still
> don't expose the  actual private name to misuse.  For example, perhaps
> a private name surrogate could expose a method that does a property
> lookup using actual private name without exposing the actual name. The
> security focused guys would probably have to tell us whether they
> could live with that additional exposure.
Or maybe revive tha alternate private name proposal
https://mail.mozilla.org/pipermail/es-discuss/2011-December/018997.html
(which is nothing less than the visibility flag wit adapted proxy
semantics) ?

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120407/785fcd50/attachment.html>


More information about the es-discuss mailing list