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

C# 7.x: in parameter mode #219

Merged
merged 33 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b28c687
Update basic-concepts.md
RexJaeschke Feb 5, 2021
5943feb
Update variables.md
RexJaeschke Feb 5, 2021
756a5d3
Update conversions.md
RexJaeschke Feb 5, 2021
36a73e5
Update structs.md
RexJaeschke Feb 5, 2021
9c5f0f0
Update interfaces.md
RexJaeschke Feb 5, 2021
a5378e7
Update delegates.md
RexJaeschke Feb 5, 2021
9a523c4
Update unsafe-code.md
RexJaeschke Feb 5, 2021
e2903ea
Update documentation-comments.md
RexJaeschke Feb 5, 2021
4edeff4
Update classes.md
RexJaeschke Feb 5, 2021
63d3b26
Update expressions.md
RexJaeschke Feb 5, 2021
d470aab
include support for local functions
RexJaeschke Apr 23, 2021
13ce6fd
fix merge tag
BillWagner Apr 3, 2022
5c16085
fix build warnings
BillWagner Apr 3, 2022
f6fdcd4
build fixes
BillWagner Apr 3, 2022
ec4c2d2
build fixes, round 1
BillWagner Apr 14, 2023
bb62d47
build fixes, part 2
BillWagner Apr 14, 2023
c464280
one last link fix
BillWagner Apr 14, 2023
6831683
light edits based on earlier feedback.
BillWagner Apr 14, 2023
4d02fa7
respond to remaining feedbac,.
BillWagner Apr 14, 2023
9587783
one final edit....
BillWagner Apr 14, 2023
1bbf9a6
clarification on `ref` extension methods
BillWagner Apr 14, 2023
9dfba23
Apply suggestions from code review
BillWagner Apr 19, 2023
68f60e2
respond to feedback
BillWagner Apr 19, 2023
f8b30fc
Update standard/expressions.md
BillWagner Apr 19, 2023
f102da4
Update standard/expressions.md
BillWagner Apr 19, 2023
5531948
Apply suggestions from code review
BillWagner Apr 20, 2023
912d2c4
Update per April meeting notes.
BillWagner Apr 20, 2023
9045bdb
respond to feedback.
BillWagner May 9, 2023
90d0003
Exclude dynamic implicit conversions
BillWagner May 10, 2023
5890715
Clarify restrictions on `in` parameters
BillWagner May 12, 2023
217c791
Apply suggestions from code review
BillWagner May 19, 2023
a48694c
Updates from 5/17 committee meeting.
BillWagner May 19, 2023
948a46a
fix warning
BillWagner May 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions standard/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,8 @@ The following accessibility constraints exist:

Methods, instance constructors, indexers, and operators are characterized by their ***signatures***:

- The signature of a method consists of the name of the method, the number of type parameters, and the type and parameter-passing mode (value, reference, or output) of each of its formal parameters, considered in the order left to right. For these purposes, any type parameter of the method that occurs in the type of a formal parameter is identified not by its name, but by its ordinal position in the type parameter list of the method. The signature of a method specifically does not include the return type, parameter names, type parameter names, type parameter constraints, the `params` or `this` parameter modifiers, nor whether parameters are required or optional.

- The signature of an instance constructor consists of the type and parameter-passing mode (value, reference, or output) of each of its formal parameters, considered in the order left to right. The signature of an instance constructor specifically does not include the `params` modifier that may be specified for the right-most parameter.
- The signature of a method consists of the name of the method, the number of type parameters, and the type and parameter-passing mode of each of its formal parameters, considered in the order left to right. For these purposes, any type parameter of the method that occurs in the type of a formal parameter is identified not by its name, but by its ordinal position in the type parameter list of the method. The signature of a method specifically does not include the return type, parameter names, type parameter names, type parameter constraints, the `params` or `this` parameter modifiers, nor whether parameters are required or optional.
- The signature of an instance constructor consists of the type and parameter-passing mode of each of its formal parameters, considered in the order left to right. The signature of an instance constructor specifically does not include the `params` modifier that may be specified for the right-most parameter.
BillWagner marked this conversation as resolved.
Show resolved Hide resolved
- The signature of an indexer consists of the type of each of its formal parameters, considered in the order left to right. The signature of an indexer specifically does not include the element type, nor does it include the `params` modifier that may be specified for the right-most parameter.
- The signature of an operator consists of the name of the operator and the type of each of its formal parameters, considered in the order left to right. The signature of an operator specifically does not include the result type.
- The signature of a conversion operator consists of the source type and the target type. The implicit or explicit classification of a conversion operator is not part of the signature.
Expand All @@ -537,9 +536,9 @@ Signatures are the enabling mechanism for ***overloading*** of members in classe
- Overloading of indexers permits a class, struct, or interface to declare multiple indexers, provided their signatures are unique within that class, struct, or interface.
- Overloading of operators permits a class or struct to declare multiple operators with the same name, provided their signatures are unique within that class or struct.

Although `out` and `ref` parameter modifiers are considered part of a signature, members declared in a single type cannot differ in signature solely by `ref` and `out`. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), `ref` and `out` are considered part of the signature and do not match each other.
Although `in`, `out`, and `ref` parameter modifiers are considered part of a signature, members declared in a single type cannot differ in signature solely by `in`, `out`, and `ref`. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` or `in` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), `in`, `out`, and `ref` are considered part of the signature and do not match each other.

> *Note*: This restriction is to allow C# programs to be easily translated to run on the Common Language Infrastructure (CLI), which does not provide a way to define methods that differ solely in `ref` and `out`. *end note*
> *Note*: This restriction is to allow C# programs to be easily translated to run on the Common Language Infrastructure (CLI), which does not provide a way to define methods that differ solely in `in`, `out`, and `ref`. *end note*

The types `object` and `dynamic` are not distinguished when comparing signatures. Therefore members declared in a single type whose signatures differ only by replacing `object` with `dynamic` are not allowed.

Expand Down Expand Up @@ -567,9 +566,7 @@ The types `object` and `dynamic` are not distinguished when comparing signatures
> }
> ```
>
> Note that any `ref` and `out` parameter modifiers ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(ref int)`, and `F(out int)` are all unique signatures. However, `F(ref int)` and `F(out int)` cannot be declared within the same interface because their signatures differ solely by `ref` and `out`. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error.
>
> *end example*
> Note that any `in`, `out`, and `ref` parameter modifiers ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(in int)`, `F(out int)` , and `F(ref int)` are all unique signatures. However, `F(in int)`, `F(out int)` , and `F(ref int)` cannot be declared within the same interface because their signatures differ solely by `in`, `out`, and `ref`. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error. *end example*

## 7.7 Scopes

Expand Down
Loading