Standard Generic Delegate Types, Part Two

Last time I asked whether there were examples of delegate types which could be declared with the traditional delegate type declaration syntax that could not be declared with the generic syntax, and Alois Kraus came up with a number of examples. This syntax does not support definition of void delegates, delegates with out or ref…

6

Standard Generic Delegate Types

Hey all, I’m back from my vacation. Two weeks of reading, sailing, kayaking and visiting with old friends has left me a lot more relaxed and sunburnt than when I left. I could use another week, but it’s also good to be back. We’re introducing a lot of new features in C# 3.0 which, when…

21

Type inference woes, part three

There were a lot of good comments and questions posted in the last two entries which deserve answers. However, I am once more off to the beaver-shark infested shores of the great Canadian inland sea for my annual summer vacation. I’ll get to them when I’m back, in late June. Before I go I should…

10

Type inference woes, part two

So what’s the big deal anyway? The difference between the spec and the implementation is subtle, only affects a few specific and rather unlikely scenarios, and can always be worked around by inserting casts if you need to. Fixing the implementation would be a breaking change, it seems like a small and simple change to…

2

Type inference woes, part one

The C# compiler has a subtle violation of the specification which raises an interesting question for some of the new LINQ-related features. The specification for the ?: operator states the following: The second and third operands of the ?: operator control the type of the conditional expression. Let X and Y be the types of…

7

Using undefined variables in JScript

I got a question the other day pointing out that in JScript, it is legal to assign a value to an undeclared variable, and the variable kind of gets implicitly declared for you, but it is not legal to read the value of an undeclared variable. The writer wanted to know if y = 1;…

5

Writing Code Isn’t Rocket Science (It’s Worse Than That)

Today, an old joke: Q: What do rocket scientists say when they want to describe a portion of their work as easy?A: “This bit isn’t exactly brain surgery.” I think that pretty much everyone would agree that rocket science and brain surgery are both intellectually demanding pursuits. But it seems to me that there’s a…

21

Odious ambiguous overloads, part two

There were a number of ideas in the comments for what we should do about the unfortunate situation I described yesterday. We considered all of these options and more.  I thought I might talk a bit about the pros and cons of each. I suggested do nothing.  We shipped with this behaviour in C# 2.0,…

9

Odious ambiguous overloads, part one

As you might have gathered, a lot of the decisions we have to make day-to-day here involve potential breaking changes on odd edge cases. Here’s another one. Consider the following terrible but legal code: public interface I1<U> {    void M(U i);    void M(int i);} My intense pain begins when the user writes: public class C1 :…

9