Chris,
I see the requirement for "drop-in" functionality from a code management point of view.
Re. the compiler. Are you saying that if you have a "public I<T>Enumerator GetEnumerator()" method and a "IEnumerator IEnumerable.GetEnumerator()" method, the C# compiler will use the former in a foreach statement? And again if you have a "public <T> Current" property and an "object IEnumerator.Current" property, it will use the former?
If so, then there is a definite performance loss in having different property names. Does that not also suggest that enumerating over dictionary elements (DictionaryEntry structs) is sub-optimal in .Net?
Casting I<T>Enumerator instances to IEnumerator is a general polymorphic requirement, ie I have functions that work on generic enumerators. This is for business objects, which are reference types (so therefore no boxing hit). I find enumerators useful when querying subsets of a large collections.
Re. "list inheritance", it's only up-casting (casting to parent classes/interfaces) that I'm interested in. I'll extend the previous example to illustrate the need for this at the list level:
- CricketTeam inherits from Team, and Cricketer inherits from Player
- The Team class has a "IPlayerList Players" collection, and a number of related operations.
- The CricketTeam class has a "ICricketerList Cricketers" collection, and a number of related operations.
Now the CricketTeam.Cricketers association needs to override the Team.Players collection, and to do that the CricketTeam class needs to tell the Team class "this is my player list", and that player list needs to realise IPlayerList. Assuming we do wan't strong typing, this can either be done via a wrapper which up-casts on reading and down-casts on writing, or if the CricketerList implements IPlayerList itself. Thus far I have modified your templates to do the latter.
Interesting discussion thus far!