Attribute defaults for Object.defineProperty

Garrett Smith dhtmlkitchen at gmail.com
Sat Aug 23 20:07:12 PDT 2008


> On Aug 21, 2008, at 9:55 AM, Allen Wirfs-Brock wrote:
>
>> Or arguably "reconfigurable".
>>
On Thu, Aug 21, 2008 at 8:34 AM, Neil Mix <nmix at pandora.com> wrote:
> At the risk of beating a dead horse too much, based on the info you
> provided it sounds like the "flexible" attribute isn't really an
> attribute of the property, but an attribute of the attributes.

(posting order restored)

I'm not sure if that's what it is or not. It seems that the
documentation is very unclear and that is the source of the confusion.

The 3.1 draft defines [[Flexible]] as a property attribute:-

| [[Flexible]]	boolean	If true, attempts to delete the
| property or change its attributes will succeed. Otherwise,
| the property is said to be sealed. See the description of the
| delete operator in section 11.4.1, and the reflective Object
| methods .

That definition of [[Flexible]] seems to imply:

1) true - property can be deleted using - delete - operator.
2) false - property is sealed. What is sealed?

The closest I can come to defining "sealed" is Object.isSealed:-.

| 15.2.3.12	Object.isSealed ( O )
| When the isSealed function is called with argument O,
| the following steps are taken:
| 1. If Type(O) is not Object throw a TypeError exception.
| 2. For each named own data property P of O,
| a. Call the [[GetOwnProperty]] method of O with P.
| b. If the [[Flexible]] field of Result(2a) is true, then return false.
| 3. If the internal [[Extensible]] property of O is false, then return
| true.
| 4. Otherwise, return false.
| The length property of the Object.isSealed function is 1.


Back to the definition of [[Flexible]]
1) true - property can be deleted using - delete - operator.
2) false - property is sealed. What is sealed?

So if the property is [[Flexible]], then the properties [[value]] must
be an object which cannot be modified. What? I'm confused. :-(

What is [[Flexible]]? Is it an object modifier/attribute or a property
attribute? If it's an object modifier, then [[Mutable]] is a better
name. Otherwise, [[Deletable]] is a better name. It is unclear.

[[Mutable]]
A mutable object can be modified with new properties and new values of
existing non-final properties, after it is created.

An immutable object could be described as having no members whose
values are changeable (const/final), with the additional rule that no
properties could be added or deleted. An enum would be an example of
an immutable object.

[[Deletable]] - the opposite of [[DontDelete]].


Allen, Pratap, can you clarify what this is?

Thanks,

Garrett

> Sort
> that out appropriately in the APIs and the terminology may flow more
> easily.
>> We've had several discussions of most of these alternatives and so
>> the consensus has been to stick with "flexible". We'll talk about it
>> again today, but I wouldn't be surprised if the outcome is the same.
>>
>> Allen
>>
[snip]


More information about the Es-discuss mailing list