Nullable types

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 20 17:40:49 PDT 2008


Bill Baxter wrote:
> On Tue, Oct 21, 2008 at 9:11 AM, Lionello Lunesu <lio at lunesu.remove.com> wrote:
>> Bent Rasmussen wrote:
>>> Not true. It wraps the value type in a struct with a boolean field
>>> expressing whether it is null or not.
>>>
>>> http://msdn.microsoft.com/en-us/library/1t3y8s4s(VS.80).aspx
>> Indeed. Thanks for pointing that out.
>>
>> So C#'s 'foo?' syntax has even less to do with this compile-time nullness
>> checking.
> 
> Now it makes sense.  Yes the C# feature is apparently just a
> convenient way to create a value type with a special
> "none-of-the-above" value.
> I guess this feature is driven by need to connect with databases that
> often have nullable types.
> 
> This chapter of a C# 2.0 book covering Nullable Types seems to agree
> with that assessment :
> http://www.springerlink.com/content/w2mh0571776t3114/

Not a very clever design. If they took a hit of a Boolean field (= a 
word field when padding is accounted for), they might as well have added 
a reference to Exception. That way, you not only know the value is null, 
you may also have info on why.

Andrei



More information about the Digitalmars-d mailing list