Re: [heycam/webidl] Can we use ObjectCreate in object creation? + other editorial tweaks (#655)

The intent was that new exotic objects or exotic objects defined in other specifications should follow the pattern established within [9.4](https://tc39.github.io/ecma262/#sec-built-in-exotic-object-internal-methods-and-slots).  This includes specify a xxxCreate abstraction operation for each new kind of exotic object.

> it'd make more sense if exotic object was defined from first principles so you don't get that ambiguity.

I'm not sure what ambiguity you mean. ObjectCreate, by definition,  creates ordinary objects.  Exotic objects are created some other way and in a manner that explicitly identifies the created object as exotic. That is what ArrayCreate does for Array exotic objects. 

> first principles

Which first principles do you have in mind.  The only first principles that apply to exotic object are the concept of object identify and that they must expose (to the rest of the specification) the behavior of the essential internal methods that conform to the essential invariants.  It is the job of exotic object creation abstract operations such as ArrayCreate to provide such a definition and that is what it does:

4. Let A be a newly created Array exotic object.
5. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
6. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
7. Set A.[[Prototype]] to proto.
8. Set A.[[Extensible]] to true.

In particular, step 4 both creates a distinct object (ie with identity)  and  explicitly "brands" (for use in the spec) the new object as an Array exotic object.  ObjectCreate creates and brands ordinary objects.

One thing that is missing (its implicit)  from step 5 is the inclusion of the ordinary object internal slots in the newly created array exotic object. It would probably be better if it's step 5 (and other similar xxxCreate abstract operations) was restated something like:

5. Incorporate into A the internal slots and set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.

Also object creation should be considered an atomic action so the ordering of steps 6-8 is not significance.  You could imagine all of steps 5-8 being listed as bullet points under step 4.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/655#issuecomment-467559106

Received on Tuesday, 26 February 2019 18:37:32 UTC