References in D

Simen Kjaeraas simen.kjaras at
Wed Oct 3 11:45:48 PDT 2012

On 2012-10-03, 19:31,  wrote:

> On Wednesday, 3 October 2012 at 16:33:15 UTC, Simen Kjaeraas wrote:
>> On 2012-10-03, 18:12,  wrote:
>> They make sure you never pass null to a function that doesn't expect  
>> null - I'd say that's a nice advantage.
> No, it is meaningless. If you have a class which is supposed to hold a  
> prime number and you pass it to a function are you going to check each  
> time that the value is indeed prime? That would kill the efficiency of  
> your program guaranteed. So you would be happy to know that the  
> reference is non-null but you would take it for granted the value is  
> indeed prime? Does it make any sense?

I don't know the field you're working in, but prime numbers are rarely
a problem in my field. Null pointers, I have to worry about every day.
In our product there is a null pointer bug that has thus far only
occurred on production hardware, where we're not allowed to run
debuggers (gawd dangit), and only once every few weeks. We know where
it happens (third party library) and that non-nullable references would
have ensured it'd never show up.


More information about the Digitalmars-d mailing list