David Piepgrass
1 min readJun 13, 2019

--

In that case, there is no need for IValueEnumerator — it is the same as IEnumerator except that it is IDisposable. Does it really need to be disposable?

The important part is IValueEnumerable. But I would call it simply IEnumerable and define it like this:

public interface IEnumerable<T, TEnumerator>
where TEnumerator : IEnumerator<T>, IDisposable {
TEnumerator GetEnumerator();
}

But you will have a problem in case someone implements a class X that implements both IEnumerable<T> and IEnumerable<T, TEnumerator>. The compiler will say that an extension method like x.Select(e=>e) is ambiguous between System.Linq.Enumerable.Select and NetFabric.Hyperlinq.Enumerable.Select. To avoid this problem, it needs to be derived from IEnumerable<T>:

public interface IEnumerable<T, TEnumerator> : IEnumerable<T>
where TEnumerator : IEnumerator<T>, IDisposable {
TEnumerator GetEnumerator();
}

I think something like Hyperlinq should be part of my Loyc Core Libraries

--

--

David Piepgrass
David Piepgrass

Written by David Piepgrass

Software engineer with over 20 years of experience. Fighting for a better world and against dark epistemology.

Responses (1)