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

Re: Non-constructible constructors and Arrays

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Thu, 28 Jul 2011 19:12:07 -0700
Cc: Alex Russell <slightlyoff@google.com>, public-script-coord@w3.org, Brendan Eich <brendan@mozilla.com>, Cameron McCormack <cam@mcc.id.au>
Message-Id: <50BAED85-48F0-49B3-9802-2F1293B8119D@wirfs-brock.com>
To: Jonas Sicking <jonas@sicking.cc>

On Jul 28, 2011, at 5:04 PM, Jonas Sicking wrote:

> As I asked above, what would the mutating functions do to "live"
> NodeList? And IMHO only APIs that want to return "live" objects should
> return NodeLists. Others should simply return arrays.

In ES5 all of the Array.prototype functions are defined to operate upon generic objects with "array indexed" (ie, integer string values) properties. The objects they operate upon do not need to be Array instances. The functions are specified in terms of the basic ES5 internal operations such as [[Get]], [[Put]],  etc.  Such generic objects (or even Array instances for that matter) may, in ES5, have non-writable and non-deletable properties and the objects may be non-extensible.  For that reason, the array algorithms all explicitly define how to deal with such situations.  Generally, they throw when they try to modify a property in a manner that is forbidden for that object.

If a DOM implementation provides reasonable implementations of [[Get]], [[Put]] and friends then the Array functions should just work on its DOM objects. Trying to reverse a read-only DOM object may not do anything useful, but its unuseful behavior would still be fully specified.

Received on Friday, 29 July 2011 02:12:41 UTC

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