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: Out parameters and LINQ do not mix

    I am back from my annual vacation in beautiful southwestern Ontario; before I get into the subject of today's post, check out this shot I took with my Windows Phone camera from the plane on the trip home. We are at 37000 feet, just outside of Billings, Montana, a few minutes before sunset: The whole...
  • Blog Post: Never Say Never, Part One

    Can you find a lambda expression that can be implicitly converted to Func<T> for any possible T? . . . . . . . . . . . Hint : The same lambda is convertible to Action as well. . . . . . . . . . Func<int> function = () => { throw new Exception(); }; The rule for assigning lambdas to delegates...
  • Blog Post: Closing over the loop variable, part two

    (This is part two of a two-part series on the loop-variable-closure problem. Part one is here .) UPDATE : We are taking the breaking change. In C# 5, the loop variable of a foreach will be logically inside the loop, and therefore closures will close over a fresh copy of the variable each time . The ...
  • Blog Post: Closing over the loop variable considered harmful

    (This is part one of a two-part series on the loop-variable-closure problem. Part two is here .) UPDATE : We are taking the breaking change. In C# 5, the loop variable of a foreach will be logically inside the loop, and therefore closures will close over a fresh copy of the variable each time . The ...
  • Blog Post: Iterator Blocks Part Seven: Why no anonymous iterators?

    This annotation to a comment in part five I think deserves to be promoted to a post of its own. Why do we disallow anonymous iterators? I would love to have anonymous iterator blocks. I want to say something like: IEnumerable<int> twoints = ()=>{ yield return x; yield return x*10; }; foreach...
  • Blog Post: Mmm, Curry

    A recent comment asked why Haskell programmers sometimes write C# lambdas in this style: Func<int, Func<int, int>> add = x=>y=>x+y; which is then invoked as sum = add(2)(3); because of course the first invocation returns a function that adds two, which is then invoked with...
  • Blog Post: The Stack Is An Implementation Detail, Part One

    " style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px; BORDER-RIGHT-WIDTH: 0px" height=240 alt="Stack " src="http://blogs.msdn.com/blogfiles/ericlippert/WindowsLiveWriter/TheStackIsAnImplementationDetail_C978/Stack_thumb_1...
  • Blog Post: Five-Dollar Words For Programmers, Part Three: Homoiconic

    Jeff Atwood was kind enough to once more give me the shout-out in his blog the other day . Thanks Jeff! This inspires me to continue my series on five-dollar words for programmers. Here’s one that I only learned relatively recently, when I helped write the code that translates a lambda expression into...
  • Blog Post: Method Type Inference Changes, Part One

    I want to start this by discussing the purpose of method type inference, and clearing up some potential misunderstandings about type inference errors. First off though, a brief note on nomenclature. Throughout this series when I say "type inference" I mean "method type inference", not any of the other...
  • Blog Post: Reading Code Over the Telephone

    In my youth I once attended a lecture given by Brian Kernighan on the subject of code quality, which was very influential on my attitudes towards writing legible code. One of the things that Kernighan recommended was to endeavour write code that was so clear that it could be easily read over the phone...
  • Blog Post: Translating intentions and mechanisms

    Before I get into today's blogging, a quick note about my recent post on How To Not Get A Question Answered . That was certainly not intended to be fishing for compliments or chiding people for never acknowledging help ten years ago; that said, I appreciate both. Thanks to everyone who made thoughtful...
  • Blog Post: Future Breaking Changes, Part Two

    Last time I mentioned that one of the subtleties of programming language design is weighing the benefit of adding a feature against the pain it will cause you in the future. This is a specific subset of a more general set of problems. Languages run into the same problem that other large, multiply-versioned...
  • Blog Post: FYI: C# and VB Closures are per-scope

    This post assumes that you understand how closures are implemented in C#. They're implemented in essentially the same way in the upcoming version of Visual Basic. As Raymond and Grant point out in their various articles on the subject, the question of whether or not two instances of a delegate share...
  • Blog Post: Lambda Expressions vs. Anonymous Methods, Part Five

    Last time I demonstrated that the compiler could have to do an exponential number of bindings in order to determine whether there was a unique best overload resolution for a function call that takes a lambda. Some of you may have wondered whether we simply were not being clever enough in the compiler...
  • Blog Post: Lambda Expressions vs. Anonymous Methods, Part Four

    Hey all, sorry for the long time between posts; I have been crazy busy recruiting , interviewing, fixing bugs, making performance improvements and implementing last-minute changes to the language and expression tree library. The last few posts about lambda binding yielded many interesting comments which...
  • Blog Post: Lambda Expressions vs. Anonymous Methods, Part Three

    Last time I said that I would describe a sneaky trick whereby you can get variable type inference out of a lambda by using method type inference. First off, I want to again emphasize that the reason we are adding so many type inferencing features to C# 3.0 is not just because it is convenient to reduce...
  • Blog Post: Lambda Expressions vs. Anonymous Methods, Part Two

    We interrupt the discussion of how the difference between lambda expression and anonymous method convertibility leads to potential performance problems in the compiler to answer a user question. Within hours of yesterday's post readers Raymond Chen and Marc Brooks both asked me the same question....
  • Blog Post: Lambda Expressions vs. Anonymous Methods, Part One

    As you know by now if you've been reading this blog for a while, I am incredibly excited about adding lambda expressions to C# 3.0. I thought I'd talk a bit today about an incredibly subtle difference between C# 2.0 anonymous methods and C# 3.0 lambda expressions which has caused me no end of stress...
  • Blog Post: Why does a recursive lambda cause a definite assignment error?

    Hey fabulous readers, sorry for not much blogging lately. Between implementing LINQ and making plans to attend my first Burning Man, there's been no time for anything. We've had lots of new ideas generated here for the type inferencing algorithm which I will discuss in detail when I get back. For...
  • Blog Post: Delegates, Lambdas, Type Inference and Long Playing Records

    Today is my 33 1/3rd birthday! I'm one third of the way through my first century. I feel like I should go buy some LPs to celebrate, not that I have anything that will play them. In other news, someone sent me this code the other day. Suppose you've got a collection of mammals and you want to feed...
  • Blog Post: Why are base class calls from anonymous delegates nonverifiable?

    I'm still learning my way around the C# codebase – heck, I'm still learning my way around the Jscript codebase and I've been working on it for nine years, not nine weeks. Here's something I stumbled across while refactoring the anonymous method binding code last week that I thought might be interesting...
Page 1 of 1 (22 items)