Re: Lazy interface objects?

One solution might be to implement the global using a proxy. There's a
lot of magic in the global (including its array-like behavior), so you
might want to do that for other reasons anyway.

/ Jonas

On Wed, Sep 21, 2011 at 9:51 AM, Travis Leithead
<Travis.Leithead@microsoft.com> wrote:
> 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 17:00:16 UTC