Skip to content

[API Proposal]: New user-defined operator names #114930

@AlekseyTs

Description

@AlekseyTs

Background and motivation

New C# language feature adds ability to declare custom +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, >>>= operators, including checked forms for +=, -=, *=, /=. ECMA-335 already reserves names for non-checked assignment operators, but not for checked assignment operators.
The feature also adds ability to declare custom instance (vs. static) ++, -- operators, including checked forms.

API Proposal

Reserve the following names:

Name Operator
op_DecrementAssignment instance --
op_IncrementAssignment instance ++
op_CheckedDecrementAssignment instance checked --
op_CheckedIncrementAssignment instance checked ++
op_CheckedAdditionAssignment checked '+='
op_CheckedSubtractionAssignment checked '-='
op_CheckedMultiplicationAssignment checked '*='
op_CheckedDivisionAssignment checked '/='

The names follow the pattern previously used for Checked user-defined operators feature.

ECMA-335 already reserves the following names for non-checked operators:

Name Operator
op_AdditionAssignment '+='
op_SubtractionAssignment '-='
op_MultiplicationAssignment '*='
op_DivisionAssignment '/='

API Usage

The names will be used by compilers for methods implementing the operators.

Alternative Designs

N/A

Risks

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-Meta

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions