On the subject of iterators.

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?

3 thoughts on “On the subject of iterators.

  1. Bill McCarthy

    If you think LINQ and iterators, the key is they are compiler generated code. that is they are a design time feature for working with sets. No once you allow methods and properties of set items to be strongly invoked and expressed in a *dynamic* way, at runtime you can extend these concepts to provide truely data driven solutions.

  2. Bill McCarthy

    If you think LINQ and iterators, the key is they are compiler generated code. that is they are a design time feature for working with sets. Now once you allow methods and properties of set items to be strongly invoked and expressed in a *dynamic* way, at runtime you can extend these concepts to provide truely data driven solutions.

  3. Mitch Denny Post author

    Hi Bill,

    Absolutely – in fact I’ve been starting to enjoy more dynamic language features. I’m probably going to be pretty keen on VB vNext, and I also like some of the features from PowerShell.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s