Nullable Types

Patrick Logan writes about nullable types in C# 2.0, ending with the note that boolean will also be a nullable type that's safely usable in a boolean expression, "assuming one wants Null and False to behave the same". It seems to me that one of the big distinctions between Java/C# and C & Lisp & Scheme is that the former eschew the latters' characteristic of using 0 or #f for false and anything else for true. This seems like C#'s first concession that this may actually be a useful trait. For my part, what ruined this in C was the surprising behavior of assignment in a conditional expression (e.g. if (i = 0) {}), but I think Java and C# may have thrown the baby out with the bathwater in their handling of booleans. However, I agree with Patrick that at first glance, this really seems to junk up the language. It probably does make mapping relational data easier, but at the cost of passing additional burden to the programmer.

— Gordon Weakliem at permanent link

Comments

The debate goes way back in the Lisp world too. Usually generating more heat than light.

I happen to be more of a "purist" when it comes to booleans I guess.

Patrick Logan at

comments are now closed on this post