RE: Lazy interface objects?

>From: David Flanagan [mailto:dflanagan@mozilla.com]
>I wonder if the ES3 requirement of [[Writable]] properties was
>reconsidered during the development of ES5 and the addition of
>Object.defineProperty and Object.getOwnPropertyDescriptor()?  In ES3
>implementations that supported getters and setters, the choice between a
>data property and an accessor property was an implementation detail.
>When ES5 added getOwnPropertyDescriptor(), that implementation detail
>became observable, and the meaning of a [[Writable]]:true requirement
>changed from a behavior to be tested (can I set the property?) to an
>attribute to be queried (what does getOwnPropertyDescriptor() return?).
>Was there an explicit intent there to restrict the choices available to
>implementors?  If not, then maybe the ES spec should be relaxed in the
>same way that I'm proposing that WebIDL should be relaxed.  (Though I
>don't think the case for relaxing ES is as strong).

If I recall my conversations with Allen correctly, it was indeed something that was considered. I believe compatibility was favored at the time over change to lock them down.


>In general, it seems to me that defineProperty and
>getOwnPropertyDescriptor are reflection and metaprogramming tools that
>intentionally enable unsafe observation of implementation details.  It
>is a mistake, I think, to use them as a specification mechanism.  (The
>same thing goes for getPrototypeOf)

Yes, defineProperty and getOwnPropertyDescriptor are "reflection" based tools; but I disagree with your sentiment of them being "unsafe". I believe they add a deeper level of implementation specificity that web developers should be able to rely on--indeed we've already started to see some convergence among different browsers in this area.

Received on Wednesday, 21 September 2011 22:34:51 UTC