The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

The wisdom of sev^H^H^Heighth graders: What it means to be an adult
Aug 12, 2009
Post comments count 0
Post likes count 0

The wisdom of sev^H^H^Heighth graders: What it means to be an adult

Raymond Chen
Raymond Chen

Since I'm obviously a glutton for punishment, I also helped read eighth grade essays on the same topic: Describe the qualities you consider to be those which make someone an adult. As always, remember that these are just the funny sentences/excerpts. Let me tell you about my parents Entering a no fun zone It's harder than I thought Tautology corner Assorted commentary Misspelling corner. I've included more context; that may make the game a bit easier. And just so you won't think all eighth graders are terrible writers:

Why can't I pass a reference to a derived class to a function that takes a reference to a base class by reference?
Aug 12, 2009
Post comments count 0
Post likes count 0

Why can't I pass a reference to a derived class to a function that takes a reference to a base class by reference?

Raymond Chen
Raymond Chen

"Why can't I pass a reference to a derived class to a function that takes a reference to a base class by reference?" That's a confusing question, but it's phrased that way because the simpler phrasing is wrong! Ths misleading simplified phrasing of the question is "Why can't I pass a reference to a derived class to a function that takes a base class by reference?" And in fact the answer is "You can!" Our call to passes a reference to the derived class to a function that takes a reference to the base class. This is perfectly fine. When people ask this question, they are typically wondering about passing a...

The wisdom of seventh graders: What it means to be an adult
Aug 11, 2009
Post comments count 0
Post likes count 0

The wisdom of seventh graders: What it means to be an adult

Raymond Chen
Raymond Chen

I didn't participate in the reading of the seventh grade essays, but I did get some of the more entertaining sentences from that batch. As you may recall, the topic was to describe the qualities you consider to be those which make someone an adult. Students were given 90 minutes, plus one additional hour upon request, equipped only with paper and pencil. Remember, these are just the funny sentences/excerpts. Do not assume that all students write like this. Better get your butt in gear Let me tell you about my parents How'd they get that way? Assorted commentary Misspelling corner. I've included more con...

Actually, FlagsAttribute can't do more; that's why it's an attribute
Aug 11, 2009
Post comments count 0
Post likes count 0

Actually, FlagsAttribute can't do more; that's why it's an attribute

Raymond Chen
Raymond Chen

A few years ago, Abhinaba wondered why FlagsAttribute didn't also alter the way enumeration values are auto-assigned. Because attributes don't change the language. They are instructions to the runtime environment or (in rarer cases) to the compiler. An attribute can instruct the runtime environment to treat the function or class in a particular way. For example, you can use an attribute to tell the runtime environment that you want the program entry point to run in a single-threaded apartment, to tell the runtime environment how to look up your p/invoke function, or to tell the compiler to suppress a particular...

Why doesn't String.Format throw a FormatException if you pass too many parameters?
Aug 10, 2009
Post comments count 0
Post likes count 0

Why doesn't String.Format throw a FormatException if you pass too many parameters?

Raymond Chen
Raymond Chen

Welcome to CLR Week 2009. As always, we start with a warm-up. The method doesn't throw a if you pass too many parameters, but it does if you pass too few. Why the asymmetry? Well, this is the type of asymmetry you see in the world a lot. You need a ticket for each person that attends a concert. If you have too few tickets, they won't let you in. If you have too many, well, that's a bit wasteful, but you can still get in; the extras are ignored. If you create an array with 10 elements and use only the first five, nobody is going to raise an exception. Similarly, the message doesn't mind if you pass too ma...

The wisdom of seve^H^H^H^Hsixth graders: What it means to be an adult
Aug 10, 2009
Post comments count 0
Post likes count 0

The wisdom of seve^H^H^H^Hsixth graders: What it means to be an adult

Raymond Chen
Raymond Chen

I was out of town for the grading of the seventh grade essays, so I pitched in with the sixth grade essays instead. The students were asked to think of an adult and describe the qualities that make that person an adult. This topic was not very well received by the students, who deemed it uncreative and boring. While I understand their lack of enthusiasm, it's also true that for most of your life, you're going to have to write on topics that are uncreative and boring (and the stakes are going to be higher), so you'd better get good at it. The difference in writing skill between sixth and seventh graders (between...

Not beany enough
Aug 7, 2009
Post comments count 0
Post likes count 0

Not beany enough

Raymond Chen
Raymond Chen

The other night, I was playing a friendly game of Scrabble®, and I managed to play BEANIER* (meaning "with a stronger flavor of beans") onto a triple-word score, crossing the B with an open Y, scoring over 100 points in the process. This sufficiently demoralized the other players that the game turned into "play anything that vaguely resembles a word, with creative spelling encouraged." It turns out that BEANIER* is not listed in the online versions of the SOWPODS or TWL Scrabble word lists, although I made the move in good faith. If the others had thought to challenge, they would've succeeded. My ...

SHCIDS_CANONICALONLY is the moral equivalent in the shell namespace of the Unicode ordinal comparison
Aug 7, 2009
Post comments count 0
Post likes count 0

SHCIDS_CANONICALONLY is the moral equivalent in the shell namespace of the Unicode ordinal comparison

Raymond Chen
Raymond Chen

One of the flags you can pass to the method is . This flag means that the method should determine whether the two pointers refer to the same underlying object, and if they do not, then it should determine which one should come first by whatever mechanism it wants. It doesn't matter which one is declared as coming before the other one, as long as it is consistent. I like to think of this as the moral equivalent of the Unicode ordinal comparison. In both cases, you use the comparison if you have two items that you wish to keep in sorted order, but you don't care what the ordering rules are, as long as they are...

The great thing about regular expression engines is that there are so many to choose from
Aug 6, 2009
Post comments count 0
Post likes count 0

The great thing about regular expression engines is that there are so many to choose from

Raymond Chen
Raymond Chen

Back in the days before perl ruled the earth, regular expressions were one of those weird niche features, one of those things that everybody reimplements when they need it. If you look at the old unix tools, you'll see that even then, there were three different regular expression engines with different syntax. You had , , and . Probably more. The regular expression language supported character classes, the dot wildcard, the asterisk operator, the start and end anchors, and grouping. No plus operator, no question mark, no alternation, no repetition counts. The program added support for plus, question mark, and ...