W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

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

From: Dirk Schulze <dschulze@adobe.com>
Date: Thu, 26 Sep 2013 03:08:20 -0700
To: Simon Pieters <simonp@opera.com>
CC: Cameron McCormack <cam@mcc.id.au>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <81C7FBEC-FFAC-45DE-93A6-DF20CCBCC53B@adobe.com>

On Sep 26, 2013, at 11:46 AM, Simon Pieters <simonp@opera.com> wrote:

> On Thu, 26 Sep 2013 11:33:58 +0200, Cameron McCormack <cam@mcc.id.au>  
> wrote:
> 
>> Simon Pieters wrote:
>>> Boris Zbarsky suggested it might be better to have two separate
>>> interfaces, with the mutable interface has settable attributes and the
>>> immutable interface has readonly attributes. [3]
>> 
>> Would it be too fancy to try to use inheritance to relate DOMRect and  
>> DOMRectReadOnly?  Web IDL already has this syntax:
>> 
>>   interface DOMRectReadOnly {
>>     readonly attribute double x;
>>     ...;
>>   };
>> 
>>   interface DOMRect : DOMRectReadOnly {
>>     inherit attribute double x;
>>     ...
>>   };
>> 
>> which basically means to have the same behaviour for  
>> DOMRect.prototype.x's getter as DOMRectReadOnly.prototype.x's.
> 

You would use DOMRectReadOnly as type for every rect object that you pass to a method instead of DOMRect. That is not a problem at all implementation or specification wise. I just hope that people understand this concept and don't try to "convert" one object to the other.

Greetings,
Dirk


> Works for me. Is there any reason URLUtils/URLUtilsReadOnly doesn't do  
> this?

> 
> -- 
> Simon Pieters
> Opera Software
> 
Received on Thursday, 26 September 2013 10:09:00 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC