Re: How to specify an object that can be mutable or immutable

Sent from my iPhone

> On Sep 26, 2013, at 2:39 PM, "Simon Pieters" <simonp@opera.com> wrote:
> 
> On Thu, 26 Sep 2013 14:15:47 +0200, Domenic Denicola  
> <domenic@domenicdenicola.com> wrote:
> 
>> Can somebody spell out how this proposed inheritance hierarchy works in  
>> actual ECMAScript, not WebIDL? I cannot see how it would work at all. A  
>> .js file containing some code that we can actually execute would make  
>> the most sense.
>> 
>> For example, if readonly is taken to mean non-writable non-configurable  
>> data properties, then you cannot reconfigure them to be writable in a  
>> subclass constructor. Or if it's meant to be getters only, touching an  
>> underlying backing store, then you should be able to bypass that  
>> protection by using the subclass setter applied to a superclass instance.
>> 
>> I am very concerned that the design thinking here is not taking place at  
>> the level of the language in which these constructs manifest.
> 
> AFAICT there would be two separate properties in JS.
> 
> http://dev.w3.org/2006/webapi/WebIDL/#es-attributes
> 
> However, roc pointed out that the inheritance idea is confusing since the  
> mutable object would inherit from an interface that claims immutability.  
> Having separate interfaces doesn't have that problem.

Hmm, then every method that can take both as argument, also must specify both every time. Beside that, you also need to implement each interface twice. One for the mutable case, on for the immutable. Means you have duplication all over the platform. That sound suboptimal.

Greetings
Dirk


> 
> -- 
> Simon Pieters
> Opera Software

Received on Thursday, 26 September 2013 13:12:39 UTC