Nick Randolph posted up a snippet of C# to his blog which demonstrates the use of iterators. a piece of syntactic sugar which allows C# developers to build enumerators. Bill McCarthy joined the conversation with his views. I think that Bill’s proposed language enhancement is interesting, but I actually think that it is more complex than iterators in this case. The beauty of the iterators solution is that it makes it easy to express filters as you walk down the object model. Sure – you could come up with a standard enumerator called TreeEnumeratorWithFilters<T> but it just starts getting more complicated – iterators in C# are the generic solution.
I don’t want to throw the baby out with the bath water though – maybe there is a better use for the proposed enhancements – Bill?