meetings/2023/LDM-2023-10-11.md
The specification effort for C# 7.3 has completed, and the formal spec has been submitted to ECMA for ratification. Following this effort, the committee will be moving onto C# 8, but there were a few questions to clarify with the LDM before getting started on that:
safe-to-escape and ref-safe-to-escape in the specification for clarity. Should we update the existing documents with this info, and if so, should
we update the C# 7 speclets as well as the C# 8+ speclets?
https://github.com/dotnet/csharplang/issues/5354
https://github.com/dotnet/roslyn/issues/70318
Finally today, we considered whether collection expressions should prefer ReadOnlySpan over Span for APIs that are overloaded on these two types. This isn't a super common
case, but it can happen. Some examples include extension methods (these may be overloaded because extensions on ReadOnlySpan do not appear on Span receivers), or
ImmutableArray.Create. Our existing rules prefer Span here, because it can be converted to ReadOnlySpan, and is thus the "more specific" type. And, at least conceptually,
it's possible that Span is the better type in some scenarios: perhaps the API that's being called can be more efficient if it can mutate the input buffer. However, looking at
the existing ecosystem, this isn't the case; the cases we see would indeed prefer an allocation-less ReadOnlySpan if at all possible, rather than Span. We also think that we
have more leeway with collection expressions to choose the better type if possible; unlike, say, new[] { 1, 2, 3 }, we're not explicitly allocating new space with [1, 2, 3].
We also considered what exact wording to use here; we ended up at very similar wording to how we specified the Span vs array type betterness, requiring an implicit conversion
between the element types to avoid the same problems we discussed here.
ReadOnlySpan<T1> will be preferred over Span<T2> in overload resolution for a collection expression parameter when T1 is implicitly convertible to T2.