Mimic the C# yield instruction in VC++

November 29th, 2007

Recently mickey0 posted a question on the CodeGuru forum, asking whether VC++ had any syntax similar to the C# yield instruction. Although I knew the answer was ‘no’, I was still intrigued to figure out if it was possible to implement something similar.

I started with a web search and found a couple of existing implementations, all of which were using Win32 Fibers, so I realized that fibers was the way to go. Even though the examples I found was good tutorials on fibers, they did not meet my requirements on a proper yield implementation. So I had to get dirty. Read the rest of this entry »

Safe to remove hardware

November 25th, 2007

This message keeps popping up on my laptop:

Safe To Remove Hardware

As far as I know my laptops network card is a part of the motherboard, and trying to remove it would probably involve a hammer and a chisel. And that’s safe?!

- petter


Static predicates, delegate inference and performance

November 24th, 2007

C# 2.0 introduced a feature called delegate inference. Delegate inference is an simplification of how you initialize delegates.

Where you prior to C# 2.0 would have to write:

MyDelegate d = new MyDelegate(MyFunction);

You can now simply write:

MyDelegate d = MyFunction;

The two lines of code behaves exactly the same. They construct a new instance of MyDelegate passing MyFunction as argument to the constructor, and then assign the instance to the variable d.

As the name ‘delegate inference’ suggests, the compiler fills in the ‘missing parts’ using inference, leaving the developer with less keystrokes and more readable code. Which is a good thing. Read the rest of this entry »

Guestbook

November 15th, 2007

You’ve managed to get this far, so you might as well leave some ‘comments’ in my guestbook…

The bad thing about String.IsNullOrEmpty…

November 8th, 2007

…is that it makes me wonder why they didn’t throw in Array.IsNullOrEmpty as well.

-petter

Powered by WordPress. Entries (RSS) and Comments (RSS).