views:

112

answers:

2

In Eric Lippert's blog entry on umpires and the C# compiler and spec, he makes this statement:

(or deliberately; we implement a small number of extensions to the formal C# language)

And that got me wondering, what extensions is he referring to, exactly?

+3  A: 

In his comments he gives some answers, (and he has given some in past blog entries)

Handling of the constant 0, typed references (http://www.eggheadcafe.com/articles/20030114.asp), type analysis of conditional expressions...

But what he's trying to say is that it shouldn't really matter to the end user, because they're weird corner cases (like the "(m=> (m=> (m=> ..." case) that are needed to help the compiler, and aren't part of the spec.

Follow the spec and you should be fine.

(below added 1:42 pm)

So, I said "Follow the spec and you should be fine." That's really all the advice that I can help you with. Yes, there are some places where the compiler deviates from the spec. But these aren't really documented, partially because they don't know what to do. Do they fix the compiler to adhere to the spec? Or do they change the spec for the weird behavior. That's basically the whole point of the handling of zero article:

http://blogs.msdn.com/ericlippert/archive/2006/03/29/the-root-of-all-evil-part-two.aspx

That's kinda the point of these extensions. They're (for the most part) undocumented, because (for the most part) they're unknown. Who knows, maybe there's some really weird handling of Flags enums that doesn't quite conform to the spec, but we wouldn't really know about it until we do some really weird thing with them. The flags enumerations have been tested, and should mostly follow the spec, so when I say "follow the spec and you should be fine" I mean precisely that. You might not be fine, because there are gotchas. but Eric is doing what he can to fix these problems, and make them known in the interim.

McKay
"Follow the spec and you should be fine". Knowing what the extensions are can be part of knowing what the spec is (if you know they're an extension, you know they're not in the spec). Therefore knowing what the extensions are can be helpful to following the spec.
Michael Burr
I didn't even think of looking at the comments, I saw it through Google Reader.
jasonh
Yep, I'm aware that *most* of the time following the spec will be OK, but I'm still curious about the areas that don't follow the spec. You never know, it may come in handy some day! :)
jasonh
+2  A: 

Not counting bugs, the most common example is varargs; but much of COM interop is extensions; for example interface constructors.

17.5 in the spec basically says "anything in System.Runtime.InteropServices can do what it wants". MSDN documents this here.

Marc Gravell