Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It may have been hoped for, but it was an unrealistic hope.

They couldn't have fixed it while retaining backward compatibility.



> They couldn't have fixed it while retaining backward compatibility.

Opt-ins exist. That's what .net ended up doing: by default the language uses "ubiquitous" nullability, but you can enable reference nullability support at the project or file level.

If you do that, references become non-nullable, and have to be explicitly marked as nullable when applicable.


The smart thing that C# has though is automatic conversion to non-nullable references, e.g.:

    void foo1(Bar bar)
    {
    ...
    }

    void foo2(Bar? bar)
    {
        if (bar != null)
            foo1(bar);   
    }
Which wouldn't compile if you didn't have the `if` condition.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: