One of the great things in C# is
yield return. It’s a form of continuation implemented atop the CLR in an ingeniously lightweight way, purely by transforming the body of an ordinary method into a state machine class.
Separation of concerns is a popular idea in software. Divide your design up into separate pieces that “know” as little as possible about each other, so you can think about them independently.
How wonderful is that?
Update: Three years later, not that wonderful because it’s gone, but now we have Cloud 9.
These work annoyingly well. Why annoying? Because they’re Mozilla specific. If only we could use them all the time. The other thing that’s annoying is how they are actually better than the C# equivalent.
There are two major advantages compared with C#’s yield return.
This is perhaps the oddest idea I’ve had for a while.
In functional programming, we write functions that return values, and have no side effects. But often it is useful to consider a series of operations that work as a pipeline and “pass forward” their results to some object. Each operation therefore has no return value in the usual sense. It has to have a side-effect on something, or there would be no point in it executing.
I’m doing some work on performance in WPF. One curious standout is dashed lines. A pen with the DashStyle set to DashStyles.Solid is very much faster than one with DashStyles.Dash. Obviously this will only make a difference if you’re drawing a lot of them, but if you have a hundred or so on a Canvas, you will notice a severe degredation in the smoothness of scrolling the Canvas.