-
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: Eliminate "present" and "absent" fields #2624
Conversation
spec.html
Outdated
@@ -12640,13 +12643,13 @@ <h1> | |||
1. If ! IsDataDescriptor(_current_) is *true* and ! IsAccessorDescriptor(_Desc_) is *true*, then | |||
1. If _Desc_ has a [[Configurable]] field, let _configurable_ be _Desc_.[[Configurable]]; else let _configurable_ be _current_.[[Configurable]]. | |||
1. If _Desc_ has a [[Enumerable]] field, let _enumerable_ be _Desc_.[[Enumerable]]; else let _enumerable_ be _current_.[[Enumerable]]. | |||
1. Replace the property named _P_ of object _O_ with an accessor property having [[Configurable]] and [[Enumerable]] attributes set to _configurable_ and _enumerable_, respectively, and each other attribute set to its corresponding value in _Desc_ if present, otherwise to its <emu-xref href="#table-object-property-attributes">default value</emu-xref>. | |||
1. Replace the property named _P_ of object _O_ with an accessor property whose [[Configurable]] and [[Enumerable]] attributes are set to _configurable_ and _enumerable_, respectively, and whose [[Get]] and [[Set]] attributes are set by _Desc_ or default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure this is clear enough. Why not s/is present/if it has the field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure this is clear enough.
Do you mean:
set by _Desc_ or default
doesn't clearly suggest its meaning (in which case we can look for a different phrase), or- it doesn't strongly signal that it's a use of a defined phrase (in which case we could consider a more distinctive syntax), or
- the definition itself isn't clear enough, or
- something else?
Why not s/if present/if it has the field/?
You could, but:
- These steps are already fairly complicated syntactically; adding a subordinate clause will make them a bit more so.
- Although it should be fairly clear that "it" refers to
_Desc_
, it's between two "its" that refer to the attribute, so that might be confusing. - Strictly speaking, "the field" wouldn't have an antecedent, although you could give it one by changing "the corresponding value" to "the value of the corresponding field".
- I thought that factoring out the concept was useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of those - "or default" isn't clear enough, doesn't have a definition, and thus doesn't clearly suggest its meaning.
Maybe it would be clearer to make a small AO that takes two records and the field name, and performs the logic? This prose has always been a bit unwieldy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of those - "or default" [...] doesn't have a definition,
You didn't see the definition in the AO's description?
Maybe it would be clearer to make a small AO that takes two records and the field name, and performs the logic? This prose has always been a bit unwieldy.
That would involve an alias/parameter whose value is a field name, and using it to:
- check whether a given record (
_Desc_
) has a field of that name, and - if so, extract its value.
...which are things that the spec currently doesn't do. We could add such a thing, but an early version of PR #2468 tried something similar ("dynamic record field lookup", "record field name indirection"), and it met with some reluctance/opposition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec passes around internal slot names as reified values, and has field names in tables as reified values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but totally fair about the dynamic lookup part)
spec.html
Outdated
@@ -12612,20 +12615,20 @@ <h1> | |||
</h1> | |||
<dl class="header"> | |||
<dt>description</dt> | |||
<dd>It returns a Boolean value which is *true* if and only if _Desc_ can be applied as the property of an object with specified _extensibility_ and current property _current_ while upholding <emu-xref href="#sec-invariants-of-the-essential-internal-methods">invariants</emu-xref>. When such application is possible and _O_ is not *undefined*, it is performed for the property named _P_ (which is created if necessary).</dd> | |||
<dd>It returns a Boolean value which is *true* if and only if _Desc_ can be applied as the property of an object with specified _extensibility_ and current property _current_ while upholding <emu-xref href="#sec-invariants-of-the-essential-internal-methods">invariants</emu-xref>. When such application is possible and _O_ is not *undefined*, it is performed for the property named _P_ (which is created if necessary). For the purposes of this abstract operation, when we say an attribute is "set by _Desc_ or default", it means that if _Desc_ has a field of the same name as the attribute, the attribute is set to the value of that field; otherwise the attribute is set to its <emu-xref href="#table-object-property-attributes">default value</emu-xref>.</dd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the editor call today, we discussed this phrasing, and we do not think it adds clarity. Can you revert this and its usages? We think the original phrasing was clear enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec.html
Outdated
@@ -12620,12 +12623,12 @@ <h1> | |||
1. If _extensible_ is *false*, return *false*. | |||
1. If _O_ is *undefined*, return *true*. | |||
1. If ! IsAccessorDescriptor(_Desc_) is *true*, then | |||
1. Create an own accessor property named _P_ of object _O_ whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attribute values are described by _Desc_. If the value of an attribute field of _Desc_ is absent, the attribute of the newly created property is set to its <emu-xref href="#table-object-property-attributes">default value</emu-xref>. | |||
1. Create an own accessor property named _P_ of object _O_ whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in _Desc_ if it has the field, otherwise to the attribute's <emu-xref href="#table-object-property-attributes">default value</emu-xref>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Create an own accessor property named _P_ of object _O_ whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in _Desc_ if it has the field, otherwise to the attribute's <emu-xref href="#table-object-property-attributes">default value</emu-xref>. | |
1. Create an own accessor property named _P_ of object _O_ whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in _Desc_ if it has the field, and to the attribute's <emu-xref href="#table-object-property-attributes">default value</emu-xref> otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I wonder if "or" would be better than "and" though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"and" seems unambiguously incorrect; "or" seems like the right choice here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed "and" to "or" per @ljharb, and squashed the fixup commit.
Change: `_rec_.[[Field]] is absent` to: `_rec_ does not have a [[Field]] field` as a follow-up to PR tc39#2620.
…tor (tc39#2624) In the "Create" and "Replace" steps in ValidateAndApplyPropertyDescriptor, use consistent phrasing for getting a value from _Desc_ or the default. In the "Replace" steps, clarify the "each other attribute" wording by naming the other attributes explicitly. And instead of talking about a record field being "present" or "absent", use the "record has a field" phrasing that PR tc39#2620 settled on.
That is, eliminate the remaining references to a record's fields being "present" or "absent".
i.e., IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor - Prefer "has a field" over "does not have a field". - Prefer simple conditions over conjunctions.
Change: `_rec_.[[Field]] is absent` to: `_rec_ does not have a [[Field]] field` as a follow-up to PR tc39#2620.
…tor (tc39#2624) In the "Create" and "Replace" steps in ValidateAndApplyPropertyDescriptor, use consistent phrasing for getting a value from _Desc_ or the default. In the "Replace" steps, clarify the "each other attribute" wording by naming the other attributes explicitly. And instead of talking about a record field being "present" or "absent", use the "record has a field" phrasing that PR tc39#2620 settled on.
That is, eliminate the remaining references to a record's fields being "present" or "absent".
i.e., IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor - Prefer "has a field" over "does not have a field". - Prefer simple conditions over conjunctions.
(force-pushed to squash the fixup-commit) |
Change: `_rec_.[[Field]] is absent` to: `_rec_ does not have a [[Field]] field` as a follow-up to PR tc39#2620.
…tor (tc39#2624) In the "Create" and "Replace" steps in ValidateAndApplyPropertyDescriptor, use consistent phrasing for getting a value from _Desc_ or the default. In the "Replace" steps, clarify the "each other attribute" wording by naming the other attributes explicitly. And instead of talking about a record field being "present" or "absent", use the "record has a field" phrasing that PR tc39#2620 settled on.
That is, eliminate the remaining references to a record's fields being "present" or "absent".
i.e., IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor - Prefer "has a field" over "does not have a field". - Prefer simple conditions over conjunctions.
When processing the merge of PR #2620, I noticed that although it had taken care of
_rec_.[[Field]] is present
, there were also cases of_rec_.[[Field]] is absent
that should probably be handled similarly. And then I noticed that that still left some references to "present" and "absent" fields. So this PR is to clean all that up. And the last commit is a bonus.There's actually one place left that uses "present" when talking about a field, and that's in Table 9: PrivateElement Fields, where one of the column-headers is "Values of the [[Kind]] field for which it is present" (where "it" is the field that a given row is declaring). I couldn't think of a good way to change that to the "record has a field" wording.