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

Reserve operator method names #1104

Merged

Conversation

RexJaeschke
Copy link
Contributor

While the mapping of C# operators to compiler-generated method names is not stated in the C# spec, it is in the CLI spec. (Partition I, I.4 and I.5.) Unfortunately, this is insufficient, for the following reasons:

  1. The C# spec normatively references Partition IV only: ISO/IEC 23271:2012, Common Language Infrastructure (CLI), Partition IV: Base Class Library (BCL), Extended Numerics Library, and Extended Array Library. In the C# spec Introduction we say, “Although Microsoft’s implementation of C# relies on CLI for library and run-time support, other implementations of C# need not, provided they support an alternate way of getting at the minimum CLI features required by this C# standard (see Annex C).” And Annex C is all about the library in Partition IV. So, we can’t simply defer to Partition I without making it a Normative Reference (which I’m sure we don’t want to do).
  2. In any event, those tables do not actually show the C# mapping! Instead, their right-most columns imply a mapping to C++ and are marked as informative.
  3. Even if we could defer to the CLI for this information, we’d still have to augment it for the new operator function names resulting from V11’s “Checked user-defined operators” as well as >>>.

This PR replicates the tables from the CLI spec, replacing C++ with C# in the (now normative) right column, and puts them in a new section, 15.3.10.6, “Member names reserved for operators.” And as we already know the extra names that V11 uses, I’ve put those in the current spec, but tagged with “reserved for future use” to warn people to stay away from defining methods with those names.

@RexJaeschke RexJaeschke added the type: bug The Standard does not describe the language as intended or implemented label May 8, 2024
@RexJaeschke RexJaeschke self-assigned this May 8, 2024
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

I'd like Jon or Nigel to weigh in, and then let's ship it.

standard/classes.md Outdated Show resolved Hide resolved
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.

Approved with the change to "Method names"

@RexJaeschke RexJaeschke merged commit a18121f into dotnet:draft-v8 Aug 12, 2024
7 checks passed
@RexJaeschke RexJaeschke deleted the Reserve-Operator-Method-Names branch August 12, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants