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

Re: JSIDL ideas for read only (Was: RE: Figuring out easier readonly interfaces)

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 03 Oct 2013 12:10:47 -0400
Message-ID: <524D9707.9080308@mit.edu>
To: Domenic Denicola <domenic@domenicdenicola.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
On 10/3/13 9:34 AM, Domenic Denicola wrote:
> Oh! It's just like ES5 object literals. A getter without a setter means no setter. The answer is `undefined`.

Note that I was asking about the other way around: a setter with no 
getter.  I assume that's what you were talking about too.

That doesn't work, then.  Consider this testcase, which sets up this 

   var objWithGetter = {
     get x() { return this._x; }
   var objWithSetter = Object.create(
       "x": { set: function(arg) { this._x = arg; } }
   function MyConstructor() {
     this._x = 0;
   MyConstructor.prototype = objWithSetter;
   var testObj = new MyConstructor();
   testObj.x = 17;

This prints "undefined" twice (as exspected, because the undefined 
getter on objWithSetter shadows the getter we really want), whereas the 
obvious desired behavior is to print 0 and then 17.

The point being, this is not a useful way to have a common superclass 
that's immutable and has the getters and a subclass with the setters, 
because due to how accessor descriptors work in ES those setters end up 
shadowing the getters.  :(

Received on Thursday, 3 October 2013 16:11:23 UTC

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