Nullable types

Lionello Lunesu lionello at lunesu.remove.com
Mon Oct 20 18:25:56 PDT 2008


"Olli Aalto" <oaalto at gmail.com> wrote in message 
news:gdhud3$1o0o$1 at digitalmars.com...
> In Objective-C you can call methods on null(nil in Obj-C) objects. The 
> call is silently ignored. So no more crashes or NPEs.
>
> The problem with this is that if you call a method on a null object and 
> try to use the return value as an initializer for a local variable, it 
> will be set to 0 for numbers, nil for objects, and so on. This can lead to 
> hard to find bugs.

:-O That sounds disastrous!

Although it sounds like D's NaN initializer: if there's even one NaN 
somewhere in a big calculation, the result of the calculation will likely be 
NaN as well. And here it helps finding bugs.

Now, if only ints and object references had a real NaN equivalent.... :-)

L. 




More information about the Digitalmars-d mailing list