Description
I'm transforming this proposal into a Draft PR for the C# Standard, and have several questions:
-
Optional Members in
Index
andRange
: The proposal suggests that some members in these types are optional, such asRange
'sStartAt
,EndAt
, andAll
. Which members are required for these types? Why not require all those provided by MS's implementation? -
Range indexer setter: What if anything should we say about the implicit and explicit setter for a Range indexer? Certainly, one can define a setter for a user-defined type; however, it is not obvious as to what such a setter would do, especially since it must be used on the left-hand side of assignment taking a right-hand side of the same type as the index returns. In the case of type
BitArray
that would mean something likeba1[range1] = ba2
, or perhapsba1[range1] = ba2[range2]
. As far as I can determine, the operations one might like to implement using such a setter are probably best implemented via a named method. In any event, for a compiler-generated Range indexer, attempting to use its setter results in the error message “CS0131 The left-hand side of an assignment must be a variable, property or indexer,” which suggests the generated indexer has no setter. If that is the case, we should say that, perhaps by stressing that the result of a Range indexer is not a variable, so as such, it can't be used on the lhs of an assignment.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: bcdddc9e-3060-4a72-95fa-93f8a4b6b741
- Version Independent ID: a70329e0-1d30-2e54-e8b8-22f9733bd09f
- Content: Ranges and indices - C# 8.0 draft specifications
- Content Source: proposals/csharp-8.0/ranges.md
- Product: dotnet-csharp
- Technology: csharp-spec
- GitHub Login: @dotnet-bot
- Microsoft Alias: wiwagn