added IEnumerable<T>.Intersect

Declined
#27 · Created  · Last updated

Declined pull request

Hi Rémy and thanks for your effort. However I will decline this PR but explain why: Every method added to IEnumerable<T> has to be considered carefully. The decision for adding or not adding them lies mostly in the implementation but also on what other methods/operators would also make sense. Intersect is affected by both: - adding Intersect alone makes little sense because then you would also want Except and Union as they are of the same category - implementing those methods requires the use of the iterator classes from Spring.Collections.Extensions Now every additional type being used in TEnumerableBase<T> affects every collection type in the entire Spring.Collection namespace. It increases binary size for every type even if you never use the Intersect method as it is part of the interface and the compiler cannot remove the method from the implementing class. This especially affects the more complex types like TDictionary<TKey,TValue> which inherits from TEnumerable<TPair<TKey,TValue>> and thus would cause the compiler to also generate TIntersectIterator<TPair<TKey,TValue>>. Same for all other classes and generic type combinations. Also see my blog post about the subject: http://delphisorcery.blogspot.de/2014/03/why-delphi-generics-are-annoying.html And QP tickets like this one: https://quality.embarcadero.com/browse/RSP-18080 One solution to solve this issue (and others) that I have been fighting for for quite some time now would be generic interface helpers. That way we could keep IEnumerable<T> very small (in fact it would not have much more than GetEnumerator). This has been reported and supported by others also but we still have to wait for that and live with compromises until then - feel free to cast your upvote: https://quality.embarcadero.com/browse/RSP-10336 https://quality.embarcadero.com/browse/RSP-13340

Closed by: ·2017-12-06

Description

 

0 attachments

0 comments

Loading commits...