On Oct 3, 2011, at 6:26 PM, Axel Rauschmayer wrote:

>> Channeling for MarkM, if you use regular objects for the enumeration element 
>> values you probably will want to freeze them all so they can't be used as a 
>> communications channel.
> 
> Immutability makes sense. I don’t understand the "communications channel" 
> argument.

A "bad guy" is passed a enumeration value.  The bad guy has been given local 
access to some secret but that is ok because he has no way to pass the secret 
on to anybody else.  The bad guy notices that he can add a new property to the 
enumeration value.  So he does so and assigns the secret as the value of the 
property.  The same enumeration value may subsequent be passed to a cohort of 
the bad guy who looks for the added property and retrieves the secret

> 
>> You may also want to define them with a null [[Prototype]].  I intended to 
>> do that for e in my original formulation for it got lost along the way from 
>> my mind to my finders.
> 
> What’s the benefit? Is comparison faster? It can’t be about memory 
> consumption (right?).

Nothing about perf.  I just wanted these objects to be as close to immutable 
values as possible, just like private names. I don't see any need for them to 
inherit from mutable Object.prototype.

However, if I was going to have the toString then I would probably create a 
shared (immutable) prototype to hold the toString method.  Each individual 
would have a immutable string valued property containing the name of the value. 
 You might also want to have a reference back to the Enum object that contains 
the value

> 
>> For debugging output you might want to capture the string of each numeration 
>> element value and provide a toString method.
> 
> 
> Good idea! With a null prototype, such a method would be needed to make the 
> objects printable.
> 
> We are approaching Bloch’s solution in "Effective Java".
> 
There are only a few ways to do these things.

Allen

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to