Skip to content

Reverse some V7 edits w.r.t Indexers #970

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

Merged

Conversation

RexJaeschke
Copy link
Contributor

During the final integration of the ref-related feature text into draft-v7, 15.9, "Indexers" was broken into 15.9.1, "General" and 15.9.2 "Indexer and Property Differences," and some of the previous content was moved around, deleted, and/or edited.

A. The following para was deleted from 15.9.1:

The modifiers virtual, override, and abstract are mutually exclusive except in one case. The abstract and override modifiers may be used together so that an abstract indexer can override a virtual one.

When I discussed this privately with Bill, he thought this might be true for all member functions, not just indexers. However, I couldn't find any such text under Methods. (And we don't have a general "member-function" section to state such things anyway.) So, I restored this para.

B. The following para was duplicated, and I removed the first occurrence:

The formal_parameter_list specifies the parameters of the indexer. The formal parameter list of an indexer corresponds to that of a method (§15.6.2), except that at least one parameter shall be specified, and that the this, ref, and out parameter modifiers are not permitted.

C. V6 contained the following:

Based on the presence or absence of get and set accessors, an indexer is classified as follows:

  • An indexer that includes both a get accessor and a set accessor is said to be a read-write indexer.
  • An indexer that has only a get accessor is said to be a read-only indexer. It is a compile-time error for a read-only indexer to be the target of an assignment.
  • An indexer that has only a set accessor is said to be a write-only indexer. Except as the target of an assignment, it is a compile-time error to reference a write-only indexer in an expression.

This was removed and summarized in a Note in the (new) 15.9.1, as follows:

Note: This replacing of property/properties with indexer/indexers when reading §15.7.3, §15.7.5 and §15.7.6 applies to defined terms as well. For example read-write property becomes read-write-indexer. end note

This introduced several problems: It made this informative, and it removed three term definitions (which we use throughout), while suggesting that a series of new-parallel terms existed, without normatively enumerating them.

After discussing this with Bill, I propose replacing that Note with the following normative text:

This replacing of property/properties with indexer/indexers when reading §15.7.3, §15.7.5 and §15.7.6 applies to defined terms as well. Specifically, read-write property becomes read-write indexer, read-only property becomes read-only indexer, and write-only property becomes write-only indexer.

FYI, the reason I stumbled on this was while writing the spec for init accessors in V9. This requires the addition of a 3rd flavor of terms: read-init property/indexer and init-only property/indexer.

@RexJaeschke RexJaeschke added the type: bug The Standard does not describe the language as intended or implemented label Oct 25, 2023
@RexJaeschke RexJaeschke added this to the C# 8.0 milestone Oct 25, 2023
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM @RexJaeschke

Copy link
Contributor

@Nigel-Ecma Nigel-Ecma left a comment

Choose a reason for hiding this comment

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

I've suggested the undoing of the first change and the possible adding of text to §15.6.1. This avoids duplication of the material, as already occurs for properties.

If the duplication is felt warranted then it should also occur in properties and if the abstract virtual remark is kept it should be added to §15.6.1

@jskeet jskeet added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Nov 1, 2023
Copy link
Contributor

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

We have agreed to remove the paragraph at 4191 in classes.md; after that, Rex can merge.

@RexJaeschke RexJaeschke merged commit ff43a49 into dotnet:draft-v8 Nov 1, 2023
@RexJaeschke RexJaeschke deleted the Rex-reverse-v7-indexer-edits branch November 1, 2023 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meeting: discuss This issue should be discussed at the next TC49-TG2 meeting type: bug The Standard does not describe the language as intended or implemented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants