Here in the UK (and possibly elsewhere – I’m too lazy to check Wikipedia) December 26th is called Boxing Day. I want to know why only this one aspect of .NET is given its own public holiday. Expanding the opportunities to language features as well as those of the runtime, I’d like to see: Null coalescing day (“Take 3 nulls into the shower? Not me. I just coalesce and go!”) Type inference day (not popular with HR) Garbage collection day (as a proper holiday, not just when the bins are collected) Just-In-Time day (arguably every day for procrastinators such as … Continue reading Boxing day
Rather excitingly, all the chapters of C# in Depth are now available for early access. The following chapters have recently been added: 10: Extension methods Without extension methods, LINQ just couldn’t work in an elegant form. Extension methods are basically a way of faking instance methods by providing static methods with an implicit “this” parameter. Importantly, they can work on interfaces, which means you can make an interface appear to have many more methods than implementations actually have to provide. Although they’re primarily provided for the sake of LINQ, extension methods can improve code readability in other spheres too – … Continue reading C# in Depth: All chapters available in MEAP!
Reading through chapter 2 (see, I’m being good) a new thought about return type covariance occurred to me. This is odd in itself, because I thought I’d exhausted my own supply of ideas around variance (which isn’t the same as knowing everything about it, of course – it just means I don’t expect to have anything new to say). Just as a reminder, in C# 1 delegates were completely invariant – in order to create a delegate instance from a method group, for instance, the signature had to match exactly. For instance, suppose we had a delegate type declared as: … Continue reading Covariance and void return types
This post is in lieu of writing a proper one, either on the generic maths operators which Marc Gravell has been hard at work on, or on C# 4 which I have a number of opinions about (no surprise there). I will write about both of those topics, but I really ought to do some more work on the manuscript for chapter 2 of the book before I go to bed. Posting a blog entry is a reward for finishing indexing chapters 2 and 13, but both of the serious posts will take longer than I really have time for … Continue reading Refactris
A little while ago, I wrote about my silly project to test Parallel LINQ – a Mandelbrot generator. In the last week, two things have happened to make this more of a reality. Firstly, the December CTP of Parallel FX has been released. Secondly, my old laptop died, “forcing” me to get a new laptop, which just happens to have a dual core processor. So, it should just be a case of running it, right? Well, not quite. First let’s have a look at the query expression again, in its serial form: var query = from row in Enumerable.Range(0, … Continue reading A cautionary parallel tale: ordering isn’t simple