Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

Simen Kjaeraas simen.kjaras at gmail.com
Sun May 19 05:05:46 PDT 2013


On Sun, 19 May 2013 02:32:49 +0200, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On Sunday, May 19, 2013 02:22:43 Simen Kjaeraas wrote:
>> Or... possibly, the current holes in @disable are fixed, and NonNull!T
>> becomes the default, because we tell people to always use them, rather
>> than flail our arms and behave like idiots. ("regular pointers are
>> broken, use NonNull!T" is a pretty good argument if it's true)
>
> I've never understood why so many people feel that nullable pointers are  
> a
> problem. Clearly, many people do, but personally, I've rarely had  
> problems
> with them, and there are plenty of cases where not being to make a  
> pointer
> null would really suck (which is why we're forced to have
> std.typecons.Nullable for non-reference types). I'm not arguing against  
> having
> non-nullable pointers, but I'd probably almost never use them myself, as  
> I
> really don't think that they'd be buying me much. In my experince,  
> problems
> with null pointers are extremely rare and easily caught.

My experience is the complete opposite - I think maybe 20% of bugs at my  
job
are caused by null references. But as you say, they are very easily fixed.

That said, two things to consider:

How many of the functions you write actually need to accept nullable
pointers/references?

If non-nullable was the default, how often would you explicitly ask for a
nullable pointer/reference?

-- 
Simen


More information about the Digitalmars-d mailing list