The Old New Thing

The implementation of iterators in C# and its consequences (part 2)

Now that you have the basic idea behind iterators under your belt, you can already answer some questions on iterator usage. Here's a scenario based on actual events: I have an iterator that is rather long and complicated, so I'd like to refactor it. For illustrative purposes, let's say that the enumerator counts from 1 to 100 twice. (In ...

The unwritten rule of riding a Seattle Metro bus

The Metro King County transit site has all the facts about how to ride the bus, but there's another rule that is applied by convention rather than by any formal codification: For some reason, and I see this only in Seattle, it is customary to say Thank you to the bus driver as you get off the bus. Tip for new riders: If you aren't ...

The implementation of iterators in C# and its consequences (part 1)

Like anonymous methods, iterators in C# are very complex syntactic sugar. You could do it all yourself (after all, you did have to do it all yourself in earlier versions of C#), but the compiler transformation makes for much greater convenience. The idea behind iterators is that they take a function with yield return statements (and ...

If the law says you can’t file a petition, you might need to file it anyway, in case somebody later says that you should’ve even though the law says you couldn’t

It sounds like a scene from the movie Brazil, but in fact it's the law. Let's rewind a bit. The introduction is a bit technical, but I'll try to keep it short. There is a legal filing known as a habeas petition and another known as a petition for review. There are rules regarding what each one covers and the deadlines for filing them. ...

For that, you’ll have to call security

Yahoo! is notorious for bad parking, but they're not the only ones. Microsoft has recurring parking problems as well, caused by office space shortages that force employees to be crammed into offices at double or even triple the intended density. Since parking lots are sized based on the expected number of cars, overstuffing a building with ...

The caret serves as the continuation character for batch files

We saw earlier that the caret is the escape character for the batch language. In a comment to that article, KJK::Hyperion mentioned that the caret serves as the line continuation character. A useful tip if you still find yourself messing with batch files. Mark Yocum elaborates on this point a bit more...