C# 4.0: dynamic<T> ?

I’ve not played with the VS2010 CTP much yet, and I’ve only looked briefly at the documentation and blogs about the new C# 4.0 dynamic type, but a thought occurred to me: why not have the option of making it generic as a way of saying “I will dynamically support this set of operations”? As an example of what I mean, suppose you have an interface IMessageRouter like this: public interface IMessageRouter{    void Send(string message, string destination);} (This is an arbitrary example, by the way. The idea isn’t specifically more suitable for message routing than anything else.) I may have various … Continue reading C# 4.0: dynamic<T> ?

DotNetRocks interview

Last Monday evening I had a chat with the guys from DotNetRocks, and today the show has gone live. I wouldn’t claim to have said anything particularly earth-shattering, and regular readers will probably be familiar with many of the themes anyway, but I thoroughly enjoyed it and hope you will too. Amongst other things, we talked about: Protocol buffers Implicit typing and anonymous types Why it doesn’t bother me that Office hasn’t been ported to .NET C# 4 My wishlist for C# Threading and Parallel Extensions Working for Google How to learn LINQ C# in Depth Feedback welcome. And yes, … Continue reading DotNetRocks interview

C# 4: Immutable type initialization

(I’m giving up with the numbering now, unless anyone particularly wants me to keep it up. What was originally going to be a limited series appears to be growing without end…) As Chris Nahr pointed out in my previous post, my earlier idea about staged initialization was very half-baked. As he’s prompted me to think further about it, I’ve come up with another idea. It’s slightly more baked, although there are lots of different possibilities and open questions. Let’s take a step back, and look at my motivation: I like immutable types. They’re handy when it comes to thread safety, … Continue reading C# 4: Immutable type initialization

C# 4 idea: Iterator blocks and parameter checking

Iterator blocks have an interesting property: they defer execution. When the method (or property) is called, none of your code is executed – it only starts running when MoveNext() is first called. Deferred execution is a great thing in many ways, but it’s a pain when it comes to parameter checking. If you check parameters within an iterator block, you’ve effectively left a timebomb – the error will be potentially reported a long way from the original source of the problem. (Side-note: this is why I prefer using a cast to as when I know what type something really should … Continue reading C# 4 idea: Iterator blocks and parameter checking

Language design, when is a language "done", and why does it matter?

As per previous posts, I’ve been thinking a fair amount about how much it’s reasonable to keep progressing a language. Not only have thoughts about C# 4 provoked this, but also a few other sources: Don Box on Ted Neward on Java (yes, two separate links – but view both) Don again on the “doneness” of XML The Channel9 video of Erik Meijer, Gilad Bracha and Mads Torgersen The video is very well worth watching in its entirety – even though I wouldn’t pretend to understand everything in it. (It’s worth watching rather than just listening to, by the way … Continue reading Language design, when is a language "done", and why does it matter?

C# 4, part 4: My manifesto and wishlist

The final part of this little series is the one where I suggest my own ideas for C# 4, beyond those I’ve already indicated my approval for in earlier posts. Before I talk about individual features, however, I’d like to put forward a manifesto which could perhaps help the decision-making process. I hasten to add that I haven’t run all the previous parts through this manifesto to make sure that I’ve been consistent, but all of these thoughts have been running around in my head for a while so I hope I haven’t been wildly out. Manifesto for C# 4 … Continue reading C# 4, part 4: My manifesto and wishlist

Macros, and languages within languages

Ian Griffiths mailed me about macros, and explained how LISP macros were very different to C/C++ macros, working at a language level instead of at a text level. I won’t pretend to understand all about what would be possible and what wouldn’t, but Ian gave a good example: query expressions in C# 3. Instead of being part of the language itself, they could apparently have been written as macros, if C# supported them. Then if you wanted to have similar support for different forms of expression, you could just write your own macro library. Assuming that’s what people are actually … Continue reading Macros, and languages within languages

C# 4, part 3: Ideas from Microsoft

Microsoft haven’t committed to anything in C# 4 yet. However, there have been hints about what they’ve been considering in Eric Lippert’s blog, and more than hints in Charlie Calvert’s blog. There’s not a lot to go on yet, but: Immutability support Most of Eric’s posts about immutability have so far been about immutable data structures. However, the first post in the series did mention that they’re playing around with immutability from the point of view of potential language support. Joe Duffy also wrote about immutability at roughly the same time. What can we expect in terms of support? Possibilities: … Continue reading C# 4, part 3: Ideas from Microsoft

C# 4, part 2: Ideas from other community members

There has been a fair amount of speculation online about what should be in C# 4. I’ve taken the list below from a few posts, primarily those by Ayende and Jeremy Miller. I’ve deliberately left out the ideas that Microsoft have mentioned that they’re at least considering – they’ll come in the next post. Mixins I suspect everyone has a different idea of what these mean, but I’ll say what I’d like. I want to be able to implement an interface by proxying all calls (other than those I’ve actually implemented) to a particular member variable, as an aid to … Continue reading C# 4, part 2: Ideas from other community members

C# 4, part 1: Looking back at the past

Everyone else is speculating about what’s going to be in C# 4 (and various possibilities are coming out of MS), so I thought it would be wise to start my own series of wishlist posts before I miss the boat completely. In this first post, I’m not going to look at the future at all – I’m going to look at mistakes of the past. When I say “mistake” I of course mean “things I would have done differently had I been a language designer with 20/20 hindsight”. Of course, there’s a lot of room for argument 🙂 Mistakes in … Continue reading C# 4, part 1: Looking back at the past