Open stephentoub opened 2 months ago
Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?)
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?)
No, it's planned for C# 13.
And this proposal is for .NET 10.
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?)
No, it's planned for C# 13.
It sounds to me like it's (at least being set up to be) in preview for C# 13 https://github.com/dotnet/roslyn/issues/73923
And this proposal is for .NET 10.
That's true 😅
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?)
No, it's planned for C# 13.
It sounds to me like it's (at least being set up to be) in preview for C# 13 dotnet/roslyn#73923
That is out of date.
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?)
No, it's planned for C# 13.
It sounds to me like it's (at least being set up to be) in preview for C# 13 dotnet/roslyn#73923
That is out of date.
Welp 😅
If only that had been released just a few hours prior 🫠😂
Even with interfaces on ref structs, we still can't make ref struct implementing IEnumerable<T>
, because the enumerator can't be boxed as IEnumerator<T>
, right?
There was long-standing discussion to make an abstraction of non-boxing enumerator. Now ref structs forces everything to be non-boxing. Is there any interest to revisit this area?
@huoyaoyuan You mean like IEnumerable<T, TEnumerator> where TEnumerator : IEnumerator<T>
?
I think that hasn't happened so far because C#'s generic inference doesn't work on it, forcing the full generics to be typed out, which is less than ideal.
@huoyaoyuan You mean like
IEnumerable<T, TEnumerator> where TEnumerator : IEnumerator<T>
?I think that hasn't happened so far because C#'s generic inference doesn't work on it, forcing the full generics to be typed out, which is less than ideal.
Yes. But of course if we start to do so, we need also to define an approach to seamless adapt IEnumerable<T>
to it, to not create yet another discrepancy.
static int Sum<TEnumerator>(TEnumerator enumerator)
Is there a proposal to implement linq operators with TEnumerator? (I think that would be related to https://github.com/dotnet/runtime/issues/64031 somehow)
static int Sum<TEnumerator>(TEnumerator enumerator)
Is there a proposal to implement linq operators with TEnumerator? (I think that would be related to #64031 somehow)
No, we don't plan to do that.
namespace System
{
public partial static class MemoryExtensions
{
public partial ref struct SpanSplitEnumerator<T> : IEnumerator<Range>
{
}
}
public readonly ref struct ReadOnlySpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
public readonly ref struct Span<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
}
namespace System.Text
{
public partial ref struct SpanLineEnumerator : IEnumerator<ReadOnlySpan<char>>
{
}
public partial ref struct SpanRuneEnumerator : IEnumerator<Rune>
{
}
}
namespace System.Numerics.Tensors
{
public readonly ref struct ReadOnlyTensorSpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
public readonly ref struct TensorSpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
}
namespace System.Text.RegularExpressions
{
public partial ref struct ValueMatchEnumerator : IEnumerator<ValueMatch>
{
}
public partial ref struct ValueSplitEnumerator : IEnumerator<Range>
{
}
}
Background and motivation
We've shipped multiple ref struct enumerators. Previously they couldn't implement
IEnumerator<T>
, but now they can. We should have them do so.API Proposal
Notes:
API Usage
Alternative Designs
No response
Risks
No response