Browse by Tags

Tagged Content List
  • Blog Post: Do not name a class the same as its namespace, Part Two

    (This is part two of a four part series; part one is here , part three is here .) Part Two: Machine-generated code: You write namespace Foo { public sealed class Foo { public string Blah(int x) { … } } } You take this code and run a third-party “decorator” tool over it that makes your class into a more...
  • 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: 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: The void is invariant

    [UPDATES below] A while back I described a kind of variance that we’ve supported since C# 2.0. When assigning a method group to a delegate type, such that both the selected method and the delegate target agree that their return type is a reference type, then the conversion is allowed to be covariant...
  • Blog Post: What does the optimize switch do?

    I was asked recently exactly what optimizations the C# compiler performs when you specify the optimize switch. Before I answer that, I want to make sure that something is perfectly clear. The compiler’s “usage” string is not lying when it says: /debug[+|-] Emit debugging information /optimize[+|-] Enable...
  • Blog Post: The Stack Is An Implementation Detail, Part Two

    A number of people have asked me, in the wake of my earlier posting about value types being on the stack, why it is that value types go on the stack but reference types do not. The short answer is “because they can”. And since the stack is cheap , we do put them on the stack when possible. The long answer...
  • 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: Representation and Identity

    (Note: not to be confused with Inheritance and Representation .) I get a fair number of questions about the C# cast operator. The most frequent question I get is: short sss = 123; object ooo = sss; // Box the short. int iii = (int) sss; // Perfectly legal. int jjj = (int) (short) ooo; // Perfectly...
  • Blog Post: Subtleties of C# IL codegen

    It must be CLR week over at The Old New Thing because it's been non-stop posts about C# lately. Raymond's last two technical posts have been about null checks and no-op instructions generated by the jitter when translating IL into machine code. I'll comment on both posts here, but I want to get the...
  • 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 (10 items)