The Truth About Value Types

As you know if you’ve read this blog for a while, I’m disturbed by the myth that “value types go on the stack”. Unfortunately, there are plenty of examples in our own documentation and in many books that reinforce this myth, either subtly or overtly. I’m opposed to it because: It is usually stated incorrectly:…

68

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…

23

The Stack Is An Implementation Detail, Part One

I blogged a while back about how “references” are often described as “addresses” when describing the semantics of the C# memory model. Though that’s arguably correct, it’s also arguably an implementation detail rather than an important eternal truth. Another memory-model implementation detail I often see presented as a fact is “value types are allocated on…

36

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

C# In Depth

Good morning, we interrupt our irregular and unscheduled ramblings with this breaking news bulletin: I am pleased to pass on news of the availability of Jon Skeet’s new book “C# in Depth”. I had the privilege of being the technical editor of this book. But I’ve gotta tell you, when I unzipped the files sent…

9

How to not get a question answered

Raymond has had lots of great posts over the years on how to not get a question answered. Some of the ways he points out that help ensure that a question goes unanswered are: Use a difficult or meaningless subject line. Ask a grammatically unclear question. Forget to actually ask a question (this is a personal…

18

C++ and the Pit Of Despair

Raymond has an interesting post today about two subtle aspects of C#: how order of evaluation in an expression is specified as strictly left-to-right, and how the rules regarding local shadowing ensure that an identifier has exactly one meaning in a local scope. He makes an educated guess that the reason for these sorts of rules is to…

15

Talking About The Weather, Part Two

What we’re missing is a phenomenon that probably was described correctly by your high school science teacher, namely, the phenomenon of “latent heat” (which is what I was taught, though “enthalpy” would be the more modern term.)  I said that the temperature of a substance is the average amount of energy in it. I lied;…

2

Talking About The Weather, Part One

No technology today; just talking about the weather. I love talking about the weather. I mentioned the other day that I had just returned from my ancestral homeland on the shores of Lake Huron, the great inland sea of southwestern Ontario. We got some rip-roaring thunderstorms this year. I love thunderstorms on the lake. They…

7

How to make little girls scream like… well, like little girls

[No technology today, so if you’re only here for the witty banter about programming languages, skip this one.] Leah and I spent the week before Halloween volunteering at Nightmare At Beaver Lake, a haunted-house-style attraction that runs along the trails in Beaver Lake Park, just on the other side of Lake Sammamish from Microsoft’s main…

7