#853 removes the implicit conversion from List<Entity> to Entity, because it made three params Entity[] overloads impossible to call with a list. The sibling conversion from Entity[] is kept:
public static implicit operator Entity(Entity[] elements) => new FiniteSet(elements);
Keeping it was deliberate and, on its own terms, correct: an array binds to the params overload in its normal form by an identity conversion, which beats the alternatives outright, so it never produced the ambiguity that the List one did.
But it leaves an asymmetry:
Entity a = new Entity[] { 1, 2, 3 }; // a set
Entity b = new List<Entity> { 1, 2, 3 }; // after #853, does not compile
Entity c = new[] { 1, 2, 3 }.ToSet(); // the explicit form, always worked
Two questions worth settling while 2.0 is still in preview, because removing a public conversion afterwards is a 3.0 change:
- Should the
Entity[] conversion go too? An implicit conversion from a collection to a scalar-ish type is the kind of thing that produces surprising overload resolution — this issue exists because its twin did exactly that. .ToSet() and new FiniteSet(...) cover the need explicitly, and MathS.Sets exists.
- If it stays, is the asymmetry acceptable? It is defensible on the mechanics, but "array converts, list does not" is hard to explain to a caller who has not read the overload-resolution rules.
No behaviour is wrong either way — this is a surface-design decision with a deadline, which is the only reason it is worth an issue rather than a comment. Marking Opinions wanted.
#853 removes the implicit conversion from
List<Entity>toEntity, because it made threeparams Entity[]overloads impossible to call with a list. The sibling conversion fromEntity[]is kept:Keeping it was deliberate and, on its own terms, correct: an array binds to the
paramsoverload in its normal form by an identity conversion, which beats the alternatives outright, so it never produced the ambiguity that theListone did.But it leaves an asymmetry:
Two questions worth settling while 2.0 is still in preview, because removing a public conversion afterwards is a 3.0 change:
Entity[]conversion go too? An implicit conversion from a collection to a scalar-ish type is the kind of thing that produces surprising overload resolution — this issue exists because its twin did exactly that..ToSet()andnew FiniteSet(...)cover the need explicitly, andMathS.Setsexists.No behaviour is wrong either way — this is a surface-design decision with a deadline, which is the only reason it is worth an issue rather than a comment. Marking
Opinions wanted.