Browse by Tags

Tagged Content List
  • Blog Post: Dynamic contagion, part two

    Last time I discussed how "dynamic" tends to spread through a program like a virus : if an expression of dynamic type "touches" another expression then that other expression often also becomes of dynamic type. Today I want to describe one of the least well understood aspects of method type inference...
  • Blog Post: Dynamic contagion, part one

    Suppose you're an epidemiologist modeling the potential spread of a highly infectious disease. The straightforward way to model such a series of unfortunate events is to assume that the population can be divided into three sets: the definitely infected, the definitely healthy, and the possibly infected...
  • Blog Post: A method group of one

    I'm implementing the semantic analysis of dynamic expressions in Roslyn this week, so I'm fielding a lot of questions within the team on the design of the dynamic feature of C# 4. A question I get fairly frequently in this space is as follows: public class Alpha { public int Foo(string x) { ... } } ...
  • Blog Post: An "is" operator puzzle, part two

    As I said last time , that was a pretty easy puzzle: either FooBar, or the type of local variable x, can be a type parameter. That is: void M<FooBar>() { int x = 0; bool b = x is FooBar; // legal, true if FooBar is int. FooBar fb = (FooBar)x; // illegal } or struct FooBar { /* ... */ } void M<X>...
  • Blog Post: Breaking changes and named arguments

    Before I get into the subject of today's post, thanks so much to all of you who have given us great feedback on the Roslyn CTP. Please keep it coming . I'm definitely going to do some articles on Roslyn in the future; the past few weeks I have been too busy actually implementing it to write much about...
  • Blog Post: Optional argument corner cases, part four

    (This is the fourth and final part of a series on the corner cases of optional arguments in C# 4; part three is here .) Last time we discussed how some people think that an optional argument generates a bunch of overloads that call each other. People also sometimes incorrectly think that void M(string...
  • Blog Post: Optional argument corner cases, part three

    (This is part three of a series on the corner cases of optional arguments in C# 4; part two is here . Part four is here .) A lot of people seem to think that this: void M(string x, bool y = false) { ... whatever ... } is actually a syntactic sugar for the way you used to have to write this in C#, which...
  • Blog Post: Optional argument corner cases, part two

    (This is part two of a series on the corner cases of optional arguments in C# 4. Part one is here . Part three is here . This portion of the series was inspired by this StackOverflow question .) Last time we saw that the declared optional arguments of an interface method need not be optional arguments...
  • Blog Post: Optional argument corner cases, part one

    (This is part one of a series on the corner cases of optional arguments in C# 4. Part two is here .) In C# 4.0 we added "optional arguments"; that is, you can state in the declaration of a method's parameter that if certain arguments are omitted, then constants can be substituted for them: void M(int...
  • Blog Post: So many interfaces!

    Today, another question from StackOverflow , and again, presented as a dialogue as is my wont. The MSDN documentation for List<T> says that the class is declared as public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable Does List<T>...
  • Blog Post: Optional arguments on both ends

    Before we get into today's topic, a quick update on my posting from last year about Roslyn jobs. We have gotten a lot of good leads and made some hires but we still have positions open, both on the Roslyn team and on the larger Visual Studio team. For details, see this post on the Visual Studio blog...
  • Blog Post: The Annotated Fourth Edition is available

    A brief digression from C# 5 to talk about C# 4: the annotated C# 4 specification is now available in book form from Addison-Wesley . It is of course handy to have a specification in book form, particularly if you're going to while away the hours with the book sitting by a warm fire. (It's hundreds of...
  • Blog Post: Teach Yourself C# In... how long?

    Earlier this year I was the technical editor of " Teach Yourself Visual C# 2010 in 24 Hours " by Scott Dorman, and I am pleased to announce that it is available in stores now. Scott has pretty much completely rewritten this from the previous edition to ensure that it is totally up-to-date for C# 4. If...
  • Blog Post: Better late than never

    Good heavens, I just realized I completely forgot to post a link to this interview . I'm a year late, but better late than never. A year ago Ken stopped by my office and we had a very freewheeling, entertaining and rather random conversation about many diverse aspects of programming language design...
  • Blog Post: It's Essential!

    My copy of Essential C# 4.0 just arrived, and it looks great. I was one of the technical reviewers of this book. Some books are a pain to edit, but the Essential C# series is one of my favourites. It totally lives up to its name; it really does give you lots of essential information for developing high...
  • Blog Post: Some Last-Minute New C# 4.0 Features

    As I’m sure you know by now, we are done implementing C# 4. We’ve added support for interoperability with dynamic languages and legacy object models, named and optional parameters, the ability to “link” against interfaces from a Primary Interop Assembly, and my favourite feature, covariance and contravariance...
  • Blog Post: How Many Passes?

    Large bodies of code written in the C/C++ languages typically divide up the code into “header” files, which are just declarations of methods and types (and definitions of macros). The actual bodies of those methods and types are in completely different files. People sometimes ask me why doesn’t C#...
  • Blog Post: Exact rules for variance validity

    I thought it might be interesting for you all to get a precise description of how exactly it is that we determine when it is legal to put "in" and "out" on a type parameter declaration in C# 4. I'm doing this here because (1) it's of general interest, and (2) our attempt to make a more human-readable...
  • Blog Post: What's the difference between covariance and assignment compatibility?

    I've written a lot about this already, but I think one particular point bears repeating. As we're getting closer to shipping C# 4.0, I'm seeing a lot of documents, blogs, and so on, attempting to explain what "covariant" means. This is a tricky word to define in a way that is actually meaningful to...
  • Blog Post: The Purpose, Revealed

    Interestingly enough, no one correctly guessed why I needed code in the compiler to transform a method argument list into a form that batched up the side effecting expressions, stuck their values in variables, and then called the method with the side-effect-free variable references. There certainly were...
  • Blog Post: Some new videos

    Somehow it has happened again; people just keep on recording videos of me and putting them on the internet. In these videos you find out what I look like when lit from above and behind. Kinda spooky. We should have made the room entirely dark and held a flashlight underneath my face. That would be...
  • Blog Post: Why No Extension Properties?

    I'm frequently asked "you guys added extension methods to C# 3, so why not add extension properties as well?" Good question. First, let me talk a bit about C# 3. Clearly the big feature in C# 3 was LINQ. In a sense we had only three features in C# 3: everything necessary for LINQ -- implicitly...
  • Blog Post: What's the difference, part one: Generics are not templates

    Because I'm a geek, I enjoy learning about the sometimes-subtle differences between easily-confused things. For example: I'm still not super-clear in my head on the differences between a hub , router and switch and how it relates to the gnomes that live inside of each. Hunks of minerals found...
  • Blog Post: Reserved and Contextual Keywords

    Many programming languages, C# included, treat certain sequences of letters as “special”. Some sequences are so special that they cannot be used as identifiers. Let’s call those the “reserved keywords” and the remaining special sequences we’ll call the “contextual keywords”. They are “contextual” because...
  • Blog Post: Zip Me Up

    Suppose you’ve got a sequence of Foos and you want to project from that a sequences of Bars. That’s straightforward using LINQ: IEnumerable<Bars> bars = from foo in foos select MakeBar(foo); or, without the query sugar: IEnumerable<Bars> bars = foos.Select(foo=>MakeBar(foo));...
Page 1 of 2 (43 items) 12