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: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 26 Sep 2013 11:26:56 -0400
Message-ID: <52445240.8040006@mit.edu>
To: public-script-coord@w3.org
On 9/26/13 5:33 AM, Cameron McCormack wrote:
> 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.

The big drawback from my pov is that this setup means you can't 
interpose your own getter on DOMRectReadOnly and have DOMRect pick it 
up....  I really wish ES allowed defining the inheritance directly in 
the language.  As it is, maybe "inherit" should end up forwarding to the 
canonical parent proto's getter, instead of calling the same internal impl?

It's hard to say which is more "idiomatic"; both are viable 
implementation strategies.

Received on Thursday, 26 September 2013 15:27:24 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:18 UTC