May 26, 2010
I am tired of explaining you the fallacies of your argument.

When you feel like "I am willing to believe I might be completely missing an essential point", please let me know.


Andrei

On 05/26/2010 08:39 PM, Walter Bright wrote:
>
>
> Denis wrote:
>> On Wed, May 26, 2010 at 11:09 PM, Walter Bright<walter at digitalmars.com>  wrote:
>>
>>> Gee, I spent a whole 2 minutes looking at the problem.
>>>
>>
>> "Cure me doctor, I'm ill."
>> "Why bother? It's easier to take 2 pills every day to suppress the symptoms."
>>
>> A problem which is easy to solve is still a problem.
>>
>>
>
> It's true that if the language got rid of null pointers, there wouldn't
> be null pointer exceptions. The problem is this doesn't solve the
> problem, it just shifts it elsewhere. I normally use null pointers for
> data that shouldn't be there, like for example, to mark the end of a
> list. If I didn't have null pointers, I'd have to write a special "end
> of list" object. What should that object do if accessed? Throw an exception.
>
> And so I'm right in exactly the same place I was with the null pointer, except that I had to write a bunch of extra code to get there.
>
> Null pointer exceptions are not bugs. They are bug /detectors/. Defining null pointers out of a language is like putting black electrical tape over the oil pressure light on your car. Voila! No more pesky lights annoying you!
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
May 26, 2010
Walter Bright wrote:
>  If I didn't have null pointers, I'd have to write a special "end of list" object. What should that object do if accessed? Throw an exception.

The idea here isn't to get rid of them, but to catch improper use statically. The language would still have null pointers.

Consider a function like this:

void foo ( Object o )
in {
      assert( o !is null);
}
body {
       o.whatever();
}

The idea with having not-null references is to put that contract in the type signature, so you can catch it at compile time instead of run time. But, null pointers are still allowed if you don't specify the in contract (or if you don't use the hypothetical NotNull type).
1 2
Next ›   Last »