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

RE: Lazy interface objects?

From: Travis Leithead <Travis.Leithead@microsoft.com>
Date: Wed, 21 Sep 2011 16:51:26 +0000
To: David Flanagan <dflanagan@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <9768D477C67135458BF978A45BCF9B3834CE0B63@TK5EX14MBXW604.wingroup.windeploy.ntdev.microsoft.com>
I'd rather not relax the spec on this point. Many of the ES built-ins (Array, Object, Number, etc.) have the same issue (although there are far fewer of these interface objects) and for compatibility the ES5 spec keeps these objects as [[writable]]: true.

The reason WebIDL is defined this way is to keep ES5 and the DOM interface objects consistent in this manner.

For an implementation that wants to optimize the way you describe, they would want to come up with mechanism that would be inclusive of built-in ES objects as well as DOM interface objects (as we did in IE9).

-Travis
 

-----Original Message-----
From: public-script-coord-request@w3.org [mailto:public-script-coord-request@w3.org] On Behalf Of David Flanagan
Sent: Tuesday, September 20, 2011 9:48 PM
To: public-script-coord@w3.org
Subject: Lazy interface objects?

When an specification, such as HTML, defines many IDL interfaces, implementors are naturally tempted to create the interface objects lazily so that they are only initialized when first used.

One way to do that is to define an interface object property (such as the HTMLHeadingElement property of the Window object) using a getter which when invoked, initializes the HTMLHeadingElement interface object, converts the property to a data property with that object as its value and returns the object.

Unfortunately, the first paragraph of WebIDL 4.5 requires an interface object property to be [[Writable]]: true.  Thus, it seems that using a getter for the property would not conform.  Can the spec be relaxed on this point?  It seems that the relevant detail is that the property can be set: that it should be a writable data property or a accessor property with a setter.

(Thanks to David Bruant for pointing this out.  See
https://bugzilla.mozilla.org/show_bug.cgi?id=687042 for context.)

     David Flanagan
Received on Wednesday, 21 September 2011 16:51:56 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC