Are array 'length' properties really configurable?

# Jim Blandy (15 years ago)

Given that 15.4.5.2 makes arrays' length properties non-configurable, it seems to me that all the care taken in step three of the custom [[DefineOwnProperty]] method in 15.4.5.1 is to no avail, as the default [[DefineOwnProperty]] will refuse to make any changes anyway.

I've filed a Trac ticket for this: bugs.ecmascript.org/ticket/473

# Allen Wirfs-Brock (15 years ago)

(this should probably have been posted to es5-discuss rather than es-discuss)

Most of the work in 15.4.5.1 step 3 is about maintaining array length invariants that are outside the scope of the default [[DefineOwnProperty]] specification. Specifically, the Uint32-ness of the length value and the possible removal of array elements when the length is reduced. Those would have to be specified regardless of whether the length property was configurable or not. The only additional attribute analysis that I see is related to the possibility of changing [[Writable]] for length from true to false. That change is permitted, even if [[Configurable]] is false. Some of the extra work is there to accommodate the possibility that that when deleting element for a length reduction we encounter a non-deletable array element and that causes the length to snap to that index (+1). We can't set [[Writable]] to false until we are sure what the final length value will be.

Are there some specific sub-steps of step 3 that you think are unnecessary?

# Jim Blandy (15 years ago)

On 08/25/2010 12:30 PM, Allen Wirfs-Brock wrote:

(this should probably have been posted to es5-discuss rather than es-discuss)

Most of the work in 15.4.5.1 step 3 is about maintaining array length invariants that are outside the scope of the default [[DefineOwnProperty]] specification. Specifically, the Uint32-ness of the length value and the possible removal of array elements when the length is reduced. Those would have to be specified regardless of whether the length property was configurable or not. The only additional attribute analysis that I see is related to the possibility of changing [[Writable]] for length from true to false. That change is permitted, even if [[Configurable]] is false. Some of the extra work is there to accommodate the possibility that that when deleting element for a length reduction we encounter a non-deletable array element and that causes the length to snap to that index (+1). We can't set [[Writable]] to false until we are sure what the final length value will be.

Are there some specific sub-steps of step 3 that you think are unnecessary?

I think this was my misunderstanding. If I'm reading the default [[DefineOwnProperty]] algorithm correctly, it permits [[Writable]] to go from true to false (but not from false to true) even when [[Configurable]] is false. That's not what I had expected. Now 15.4.5.1 step 3 makes more sense to me.

Thanks for the help.