C# interview
Michel Fortin
michel.fortin at michelf.com
Mon Oct 6 18:55:30 PDT 2008
On 2008-10-06 09:11:41 -0400, "Denis Koroskin" <2korden at gmail.com> said:
> char? <-> Nullable@(char)
> char*? <-> Nullable@(char*)
Ok, I think see your point.
We only got different interpretations. Mine was that only pointers (and
object reference) could be made null, therfore, only pointers and
object references could be nullable, but wouldn't be by default.
Your idea is that any type can be made nullable. For pointers and
object references, this would be represented by null pointers; for
other types it'd have to be some kind of struct containing that type
and a boolean null-indicator value. Is this correct?
Although I don't dislike this idea, I think nullable value-types offer
much less value than nullable pointers and references. For one, making
value-types nullable isn't a solution for the problem at hand -- null
pointer errors (access violation, segmentation faults, etc.) -- because
value-types already don't have this problem. For two, it makes the type
memory layout bigger instead of simply allowing it to hold the special
zero value.
That said, I'm not against nullable value-types. My opinion is that
perhaps the language could be kept simpler by only allowing pointer and
object references to be nullable, because that's where it matters the
most.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list