-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: Add missing has operation to property operations #1438
base: main
Are you sure you want to change the base?
Conversation
This adds direct language about "does not have an own property with key". This was brought up due to legacy WebIDL usage of this language from host behavior when implementing their own exotic objects. This has been in use for years and cannot be removed and should not be changed, this is just explicitly adding it to the list of operations. The spec already requires this operation be done by implementations due to language like "... does not have an own property with key ..."
cc @Ms2ger |
Thanks @bmeck! I've removed the Bug and Normative labels, as I think this is an editorial change: currently the meaning of "has" is implied by the description of objects as "logically a collection of properties". I'm undecided on the particular change here, but will provide feedback early next week. |
The purpose of the replaced text is not to define all of the MOP level operations that involve properties. That would be a much longer list than just get, set, and has. The sentence
(subject to various tweaks) traces all the way back to ES1 but has moved around a bit. There were substantial refactoring of this section in both ES5 and ES6 but the sentence lived on. The current purpose of that paragraph is more about defining the terms own and inherited and the nature of property keys. I'd suggest replacing the above sentence with something like:
Then the following sentence:
could be updated something like:
|
@allenwb so you don't think property inspection and manipulation needs to be defined in detail? Or, in other words, a host environment defining an exotic object should simply aim to mimic the language used in ECMAScript to define exotic objects and not use some kind of prose-based-API? |
@annevk It's the job of 6.1.7.3 and 6.1.7.4 to define the generic operation that manipulate objects properties. 9.1 defines the behavior of those operations for ordinary objects. The operations for exotic objects are typically minor variation of the ordinary object operations. But in the extreme they can do any thing that is consistent with the invariants in 6.1.7.4.
I don't really understand what you are saying. Exotic objects need to be defined in terms of the operations in 6.1.7.3. You might use propose in an end user description but probably not in a specification. The subsections of 9.4 are all examples of specifying exotic objects. |
@allenwb I think that was the original intent of the PR linked from WebIDL but it encountered a recursion problem:
|
I'll try to restate it; we have an object for which one of its overridden internal methods has a step similar to
This confused folks as "have" wasn't really defined or linked and they thought it should use some kind of abstract operation instead since it wasn't the ECMAScript specification. However, using a pre-existing abstract operation would end up doing more steps, some potentially not desired. Perhaps we should have told this person that their question was incorrect, but it wasn't quite clear to me at least that it was. |
Yes, part of the problem is that "own property" is not formally defined anywhere and is really a concept of ordinary objects. A more formal definition of "own property" as used in 6.1.7.3 and 6.1.7.4 would essentially be "An own property of an object is a property whose property descriptor is accessible using [[GetOwnObject]]." The whole paragraph in 6.7.1 that @bmeck was trying to tweak should probably move into 9.1 as it is describing the semantics of own and inherited objects of ordinary objects. But that is probably not enough to deal with the WebIDL issue. Instead, it is probably the case that the meaning of own object for ordinary objects should be more concretely specified in 9.1. This is something I had toyed with several times in the past, but decided at the time that the added spec. complexity was unnecessary. What I considered doing was adding an additional internal slot called [[OwnProperties]] to each ordinary object. The value of [[OwnProperties]] would be an ordered list of key/value pairs where the key would the property key and the value was a fully complete property descriptor. The ordinary object MOP operations that add, retrieve, or otherwise manipulate "own properties" would be restated to operate upon the [[OwnProperties]] list. It would probably make sense to do so via OrdinaryXXX internal operations that could be referenced from the definitions of exotic objects. |
See also issue #1067. |
Thanks @allenwb, I think that matches the intuition I and others have about this not being as precisely defined as we'd like. I think for now IDL should keep using similar language to ECMAScript, but if this were more formally defined at some point IDL (and HTML) would definitely follow. |
3d0c24c
to
7a79833
Compare
This adds direct language about "does not have an own property with key".
This was brought up due to legacy WebIDL usage of this language from
host behavior when implementing their own exotic objects. This has been
in use for years and cannot be removed and should not be changed, this
is just explicitly adding it to the list of operations.
The spec already requires this operation be done by implementations due
to language like "... does not have an own property with key ..."
We might also want to note that hosts should not be using these operations in ways that break the meta object protocol. The whatwg/webidl#601 PR might better explain and show how it is being used in the MOP for WebIDL that brought this up.