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: inconsistent prose for intrinsics #2576

Closed
jmdyck opened this issue Nov 11, 2021 · 8 comments
Closed

Editorial: inconsistent prose for intrinsics #2576

jmdyck opened this issue Nov 11, 2021 · 8 comments

Comments

@jmdyck
Copy link
Collaborator

jmdyck commented Nov 11, 2021

I'm looking at making the prose for intrinsics more consistent. (PR #2575 is a start.)

There are many points of inconsistency. Here are a few to start with.

(1) (a) How should the spec refer to a built-in function within its defining clause?

  • by its full 'path' (e.g. "The Object.assign function")
  • by just its final property name (e.g., "The assign function")
  • in a generic way (e.g. "This function")

[(b) Later: Similarly, how should we refer to a property of an intrinsic?]

(c) Also, sometimes these say "function" and sometimes "method", and I don't think there's a rule that governs which is used. E.g., Object.freeze is "the freeze function", but in the next clause, Object.fromEntries is "the fromEntries method".

(2) Sometimes the preamble re-states the heading's parameter list, sometimes it doesn't.

Personally, I suggest dropping the parameter list in the preamble.

  • It doesn't add anything.
  • It's an opportunity to make a mistake.
  • It can be a bit misleading.

Re the last point, wording such
When the `foo` function is called with arguments _x_ and _y_, the following steps are taken:
suggests that it might be called in some other way, with some other behavior. Whereas
When the `foo` function is called, the following steps are taken:
doesn't have that problem.

@ljharb
Copy link
Member

ljharb commented Nov 11, 2021

To me, either they’re all functions, or the only methods are the ones that look at the receiver.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 11, 2021

To me, either they’re all functions,

That would make it easy.

or the only methods are the ones that look at the receiver.

I.e., the ones that reference *this* value?

@ljharb
Copy link
Member

ljharb commented Nov 11, 2021

Yes.

@bakkot
Copy link
Contributor

bakkot commented Nov 13, 2021

Also, sometimes these say "function" and sometimes "method", and I don't think there's a rule that governs which is used.

I think we're already mostly consistent with the rule @ljharb gives, with a few exceptions. Or, almost but not quite equivalently, we could say that anything on a prototype is "method", and anything else is a "function".

The exceptions fall into a few categories, at a quick glance.

  • there's a few one-offs like Object.fromEntries (which was probably my fault) and Array.isArray
  • whenever we say something is "intentionally not generic" it's described as a "function" rather than a "method" in that prose (which honestly seems backwards), even if not elsewhere
  • all the Math.whatever things are described as methods, which was introduced Editorial: define Math functions using algorithm steps #2122 without anyone really thinking about it
  • {Typed,}Array.from and{Typed,}Array.of are "method"s, which are kind of a special case in that they are not on a prototype but do look at their receiver (on the other hand, so do Promise.resolve and Promise.reject, and those are still described as "function"s).

@ljharb
Copy link
Member

ljharb commented Nov 13, 2021

I think that the Promise statics should be described as methods, along with the from/of's; the Maths should be functions; and "intentionally non-generic" should have no impact on the classification.

jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 13, 2021
…just the final property name

... rather than by "full paths".

That is, change:
- `Number.parseFloat` to *"parseFloat"*
- `Number.parseInt` to *"parseInt"*
- %TypedArray%`.prototype.toString` to *"toString"*
- `Date.prototype.toGMTString` to *"toGMTString"*

This increases consistency among sentences of this particular form.

(But note that they're a small fraction of a large class of sentences
being considered by issue tc39#2576, whose resolution could
'overturn' this choice, or other choices made in this PR.)
@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 14, 2021

"intentionally non-generic" should have no impact on the classification.

I'm pretty sure @bakkot wasn't saying it should, rather that it was the occasion of anomalies in the status quo.

Specifically, the current spec has 26 occurrences of "not generic" and 56 of "intentionally generic", and in all but 3 cases, the subject is referred to as a "function", even though in many (most?) cases the preamble referred to it as a "method".

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 14, 2021

Note that 4.4.37 defines "method" as "function that is the value of a property", which includes just about every intrinsic function. So that definition should probably change.

ljharb pushed a commit to jmdyck/ecma262 that referenced this issue Nov 18, 2021
Use consistent prose when the initial values of two intrinsic-properties are the same object.

In the sentences affected by this PR, refer to properties by just the final property name rather than by "full paths".

That is, change:
- `Number.parseFloat` to *"parseFloat"*
- `Number.parseInt` to *"parseInt"*
- %TypedArray%`.prototype.toString` to *"toString"*
- `Date.prototype.toGMTString` to *"toGMTString"*

This increases consistency among sentences of this particular form.

(But note that they're a small fraction of a large class of sentences
being considered by issue tc39#2576, whose resolution could
'overturn' this choice, or other choices made in this PR)
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 28, 2021
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 28, 2021
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 28, 2021
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 29, 2021
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 29, 2021
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Nov 29, 2021
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jan 10, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jan 10, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jan 10, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 10, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 10, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 10, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 18, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 18, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 18, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 30, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 30, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Mar 30, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Apr 21, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Apr 21, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Apr 21, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 2, 2022
... mainly the Math.* functions.

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 2, 2022
(In most cases, the clause already refers to it as a "method"
in some other sentence.)

See Issue tc39#2576 for some discussion.
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 2, 2022
The clause that defines an intrinsic function
(other than an acccessor function)
gives its parameter list in the clause heading.
Often, the preamble re-states the parameter list.
This commit (and the next) deletes those repeats.

(See Issue tc39#2576 for justification.)

In this commit, we handle all the simple cases
where nothing is lost by deleting the repeat.
@jmdyck
Copy link
Collaborator Author

jmdyck commented Aug 5, 2022

I think the merge of #2592 can close this. The only thing this issue brought up that that PR didn't handle was the definition of "method", which I've captured in issue #2846.

@jmdyck jmdyck closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants