Skip to content
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

Merged
merged 4 commits into from
Feb 16, 2022
Merged

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Jan 14, 2022

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.

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.
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

@jmdyck jmdyck Jan 14, 2022

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.

Copy link
Member

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.

Copy link
Member

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)

@michaelficarra michaelficarra added the editor call to be discussed in the next editor call label Jan 19, 2022
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>
Copy link
Member

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.

Copy link
Collaborator Author

@jmdyck jmdyck Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I eliminated the "set by Desc or default" phrase, replacing it with a consistent blend of the two phrasings in the status quo, plus @ljharb's "if it has the field" suggestion. See 0cd53f1 for the net effect.

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>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Collaborator Author

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.

jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Jan 20, 2022
Change:
    `_rec_.[[Field]] is absent`
to:
    `_rec_ does not have a [[Field]] field`
as a follow-up to PR tc39#2620.
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Jan 20, 2022
…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.
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Jan 20, 2022
That is, eliminate the remaining references
to a record's fields being "present" or "absent".
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Jan 20, 2022
i.e., IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor

- Prefer "has a field" over "does not have a field".
- Prefer simple conditions over conjunctions.
@ljharb ljharb requested review from syg, bakkot and a team January 20, 2022 19:11
spec.html Outdated Show resolved Hide resolved
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Feb 2, 2022
Change:
    `_rec_.[[Field]] is absent`
to:
    `_rec_ does not have a [[Field]] field`
as a follow-up to PR tc39#2620.
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Feb 2, 2022
…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.
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Feb 2, 2022
That is, eliminate the remaining references
to a record's fields being "present" or "absent".
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Feb 2, 2022
i.e., IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor

- Prefer "has a field" over "does not have a field".
- Prefer simple conditions over conjunctions.
@jmdyck
Copy link
Collaborator Author

jmdyck commented Feb 2, 2022

(force-pushed to squash the fixup-commit)

@michaelficarra michaelficarra added ready to merge Editors believe this PR needs no further reviews, and is ready to land. and removed editor call to be discussed in the next editor call labels Feb 2, 2022
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.
@ljharb ljharb merged commit 1c7ae4b into tc39:main Feb 16, 2022
@jmdyck jmdyck deleted the is_absent branch February 18, 2022 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change establishes editorial conventions ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants