Comma Quibbling

[UPDATE: Holy goodness. Apparently this was a more popular pasttime than I anticipated. There’s like a hundred solutions in there. Who knew there were that many ways to stick commas in a string? It will take me some time to go through them all, so don’t be surprised if it’s a couple of weeks until…

277

Asynchronous Programming in C# 5.0 part two: Whence await?

I want to start by being absolutely positively clear about two things, because our usability research has shown this to be confusing. Remember our little program from last time? async void ArchiveDocuments(List<Url> urls){  Task archive = null;  for(int i = 0; i < urls.Count; ++i)  {    var document = await FetchAsync(urls[i]);    if (archive != null)     …

161

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 “for” loop…

134

Putting a base in the middle

Here’s a crazy-seeming but honest-to-goodness real customer scenario that got reported to me recently. There are three DLLs involved, Alpha.DLL, Bravo.DLL and Charlie.DLL. The classes in each are: public class Alpha // In Alpha.DLL{  public virtual void M()  {    Console.WriteLine(“Alpha”);  }} public class Bravo: Alpha // In Bravo.DLL{} public class Charlie : Bravo // In…

134

Constraints are not part of the signature

What happens here? class Animal { } class Mammal : Animal { } class Giraffe : Mammal { }class Reptile : Animal { } …static void Foo<T>(T t) where T : Reptile { }static void Foo(Animal animal) { }static void Main() {     Foo(new Giraffe()); } Most people assume that overload resolution will choose the…

122

Attracting Talent

Today I want your insights, opinions and advice. In any large organization over time people are going to move around within that organization, or leave it for various reasons, and therefore sometimes you need to bring in fresh new people to fill the gaps left by the attrition. Over my sixteen years in the Developer…

95

Writing Code On Whiteboards Is Hard

Work has been crazy lately and I haven’t had much time to work on SimpleScript.  It’s a lot of work starting from scratch! Right now I’m writing a templatized hash table for the binders and other lookup tables.  I haven’t written templatized C++ for a loooong time and its slow going.  I hope to have…

87

How Do The Script Garbage Collectors Work?

UPDATE: This article was written in 2003. Since that time the JScript garbage collector has been completely rewritten so as to be more performant in general, to handle the larger working sets entailed by modern web applications that we had absolutely no idea were coming when we designed the JScript GC back in 1995, to be better at…

81

References are not addresses

[NOTE: Based on some insightful comments I have updated this article to describe more clearly the relationships between references, pointers and addresses. Thanks to those who commented.] I review a fair number of C# books; in all of them of course the author attempts to explain the difference between reference types and value types. Unfortunately,…

76

The Future Of C#, Part Five

When we’re designing a new version of the language, something we think about a lot is whether the proposed new features “hang together”. Having a consistent “theme” to a release makes it easier for us to prioritize and organize proposals, it makes it easier for our marketing and user education people to effectively communicate with…

74