On 03/03/2012 09:00 PM, deadalnix wrote:
Le 03/03/2012 20:06, Walter Bright a écrit :
On 3/3/2012 2:13 AM, bearophile wrote:
Walter:

Adding in software checks for null pointers will dramatically slow
things
down.

Define this use of "dramatically" in a more quantitative and objective
way,
please. Is Java "dramatically" slower than C++/D here?

You can try it for yourself. Take some OOP code of yours, and insert a
null check in front of every dereference of the class handle.

Why would you want to check every time ? You program will get a signal
from the system if it try to deference a null pointer, so thing can be
done in the signal handler, and no cost is involved.

The signal will likely be the same for the following two code snippets:

void main(){
    Object o;
    o.toString();
}

void main(){
    *cast(int*)0xDEADBEEF = 1337;
}


How to detect whether or not the access violation was actually caused by a null pointer?

Reply via email to