Spec#, nullables and more

Pelle Månsson pelle.mansson at gmail.com
Fri Nov 5 06:49:41 PDT 2010


On 11/05/2010 02:48 PM, Gary Whatmore wrote:
> Pelle Månsson Wrote:
>
>> On 11/05/2010 12:43 PM, Gary Whatmore wrote:
>>> bearophile Wrote:
>>>> - A way to list what attributes are modified in a method (similar to my @outer).
>>>
>>> The compiler should do this itself.
>>
>> Doesn't make sense.
>>
>>>> My reference issue:
>>>> http://d.puremagic.com/issues/show_bug.cgi?id=4571
>>>
>>> Walter, please close this as wontfix. We don't need those. These extra runtime checks will slow down my code. I know myself when my pointer is null.
>>>
>>>    - G.W.
>>
>> How, exactly, do you know when your references are null? Without
>> runtime checks, of course.
>
> Good code design makes the null pointer exceptions go away. I carefully ponder what code goes where. Simple as that. That language just introduces a boatload of unnecessary cruft in forms of runtime null checks. I don't need to know the exact temporal location of nulls, it's enough if the code takes care of handling it at run time.

Say you write a library, with a class and a function. Something like this:

class C {
     /* stuff */
}

void foo(C[] cs) {
     foreach (c; cs) {
         // do stuff with c
     }
}

How do you handle null, in this case?


More information about the Digitalmars-d mailing list