The Old New Thing

Common gotchas when writing your own p/invoke

If you're looking to get into some p/invoke action, you'd be well-served to check out the pinvoke wiki to see if somebody else has done it too. If what you need isn't there, you may end up forced to write your own, and here are some gotchas I've seen people run into: C++ and Win32 are not the same as C# (aka ). In Win32...
Comments are closed.0 0
Code

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

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

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

"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 ...
Comments are closed.0 0
Code

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

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

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

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 ...
Comments are closed.0 0
Code

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

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 ...
Comments are closed.0 0
Code

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

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

Not beany enough

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

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

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 ...
Comments are closed.0 0
Code

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

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...
Comments are closed.0 0
Code