Private symbols vs property attributes
Andreas Rossberg
rossberg at google.com
Tue Feb 12 07:06:29 PST 2013
On 10 February 2013 19:40, Mark Miller <erights at gmail.com> wrote:
> How does this interact with Proxies[1]? I know the answer probably starts
> with "whitelist", but let's spell it out in this context, and test it
> against the 8 membrane transparency cases previously discussed. If there are
> good answers for all of these, and if we can reuse enumerable: for this
> purpose as Brendan suggests, then I'm guardedly positive. I do not want to
> introduce a new attribute.
I must have missed the discussion of the "8 membrane transparency
cases". Do you have a pointer?
I'm fine with reusing 'enumerable'. Finally, a useful function for
that attribute. :)
/Andreas
> [1] For now, I agree that the proxies we should examine are direct proxies.
>
>
> On Sun, Feb 10, 2013 at 9:30 AM, David Bruant <bruant.d at gmail.com> wrote:
>>
>> Le 10/02/2013 17:16, Mark S. Miller a écrit :
>>
>>> I do not understand what is being proposed. When I try to imagine a
>>> proposal starting from what has been said, I have not been able to imagine
>>> something that works. But that's not a criticism. What is this alternate
>>> privacy idea?
>>
>> My understanding is:
>> * there is only one kind of symbol
>> * whether the symbol is reflected by Object.getOwnPropertyNames and the
>> likes is controlled by a 'private' attribute in property descriptors.
>>
>> // unique constructor, no boolean since there is only one kind of
>> symbol
>> var s = new Symbol();
>> var o = {}, o2 = {};
>>
>> Object.defineProperty(o, s, {value: 12, private: true});
>> assert(Object.getOwnPropertyNames(o).length === 0)
>> assert(o[s] === 12);
>> o[s] = 31;
>> assert(o[s] === 31);
>>
>> Object.defineProperty(o2, s, {value: 7, private: false});
>> assert(Object.getOwnPropertyNames(o)[0] === s);
>> assert(o2[s] === 7);
>> o2[s] = 13;
>> assert(o2[s] === 13);
>>
>> Pending question:
>> var o3 = {};
>> o3[s] = 62;
>> Object.getOwnPropertyDescriptor(o3, s).private // true or false?
>>
>> Since private:false implies symbol sharing through
>> Object.getOwnPropertyDescriptor, I think private:true should be favored to
>> force people to be explicit (see my reply to Brendan)
>>
>> The main difference with the current proposal is that privacy isn't an
>> inherent characteristic of the symbol, but related to how it's been
>> configured on the different objects it's been used on.
>>
>> Was the above one of the things you imagined? If yes, why doesn't it work?
>>
>> David
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
>
> --
> Text by me above is hereby placed in the public domain
>
> Cheers,
> --MarkM
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
More information about the es-discuss
mailing list