(non)nullable types

Jarrett Billingsley jarrett.billingsley at gmail.com
Fri Feb 13 13:30:59 PST 2009


On Fri, Feb 13, 2009 at 3:23 PM, Nick Sabalausky <a at a.a> wrote:
> Another thing to think about is delegates. Even if classes are non-null by
> default, we can still get the same old null reference problem with
> delegates:
>
> class Foo
> {
>    void delegate() dg;
>    void callDg()
>    {
>        dg();  // Oops! Forgot to check for null!!
>    }
> }
>
> void main()
> {
>    auto f = new Foo();
>    f.callDg();
> }
>
> This could probably be solved by whatever mechanism is used for classes.

I was thinking nullability would be applicable to all reference types.
 A null pointer, delegate, array, or whatever is just as bad as a null
reference.



More information about the Digitalmars-d mailing list