Showing results for August 2008 - Page 3 of 4 - The Old New Thing

Aug 14, 2008
0
0

The gradual erosion of the car trip experience

Raymond Chen
Raymond Chen

How will kids today learn to get along with their siblings? I just learned that another of the basic childhood conflict resolution scenarios has disappeared, thanks to the dual-screen DVD player and entertainment system for your car, so each kid can remain content without the burden of having to interact with their annoying brother or sister. The ...

Non-Computer
Aug 14, 2008
0
0

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

Raymond Chen
Raymond Chen

I mentioned that there was an exception to the general statement that the conversion of an iterator into traditional C# code is something you could have done yourself. That's true, and it was also a pun, because the exception is exception handling. If you have a try ... finally block in your iterator, the language executes the finally block und...

Code
Aug 13, 2008
0
0

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

Raymond Chen
Raymond Chen

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 real l...

Code
Aug 12, 2008
0
0

The unwritten rule of riding a Seattle Metro bus

Raymond Chen
Raymond Chen

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 familiar w...

Non-Computer
Aug 12, 2008
0
0

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

Raymond Chen
Raymond Chen

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 possible s...

Code
Aug 11, 2008
0
0

Psychic debugging: Why can’t StreamReader read apostrophes from a text file?

Raymond Chen
Raymond Chen

As is customary, the first day of CLR Week is a warm-up. Actually, today's question is a BCL question, not a CLR question, but only the nitpickers will bother to notice. Can somebody explain why StreamReader can’t read apostrophes? I have a text file, and I read from it the way you would expect: StreamReader sr = new StreamReader("myfil...

Code
Aug 8, 2008
0
0

Raymond rewrites newspaper headlines

Raymond Chen
Raymond Chen

Original headline: Monorail out of service this week. Raymond's headline: Monorail out of service this week: 4 people inconvenienced.

Non-Computer
Aug 8, 2008
0
0

If you return FALSE from DLL_PROCESS_ATTACH, will you get a DLL_PROCESS_DETACH?

Raymond Chen
Raymond Chen

If you return from , will you get a ? Yes. No. ... Yes. All three answers are correct, for different formulations of the question. From the kernel's point of view, the answer is a simple Yes. If a DLL's entry point returns to the notification, it will receive a notification. However, most C and C++ programs do not use the ra...

Code
Aug 7, 2008
0
0

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

Raymond Chen
Raymond Chen

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. Prior t...

Non-Computer