Disallow null references in safe code?

Meta jared771 at gmail.com
Sat Feb 1 14:09:11 PST 2014


On Saturday, 1 February 2014 at 18:58:11 UTC, Andrei Alexandrescu 
wrote:
> On 1/31/14, 5:39 PM, Jonathan M Davis wrote:
>> Regardless, we're not adding anything with regards to 
>> non-nullable references
>> to the language itself [...]
>
> I think the sea is changing here. I've collected hard data that 
> reveals null pointer dereference is a top problem for at least 
> certain important categories of applications. Upon discussing 
> that data with Walter, it became clear that no amount of belief 
> to the contrary, personal anecdote, or rhetoric can stand 
> against the data.
>
> It also became clear that a library solution would improve 
> things but cannot compete with a language solution. The latter 
> can do local flow-sensitive inference and require notations 
> only for function signatures. Consider:
>
> class Widget { ... }
>
> void fun()
> {
>     // assume fetchWidget() may return null
>     Widget w = fetchWidget();
>     if (w)
>     {
>         ... here w is automatically inferred as non-null ...
>     }
> }
>
> Bottom line: a language change for non-null references is on 
> the table. It will be an important focus of 2014.
>
>
> Andrei

That is excellent news.


More information about the Digitalmars-d mailing list