Null references redux
Yigal Chripun
yigal100 at gmail.com
Sat Sep 26 17:28:36 PDT 2009
On 27/09/2009 00:51, Walter Bright wrote:
> grauzone wrote:
>> Walter Bright wrote:
>>> It is exactly analogous to a null pointer exception. And it's darned
>>> useful.
>>
>> On Linux, it just generates a segfault. And then you have no idea
>> where the program went wrong. dmd outputting incorrect debugging
>> information (so you have troubles using gdb or even addr2line) doesn't
>> really help here.
>
> Then the problem is incorrect dwarf output, not null pointers.
>
>
>> Not so useful.
>
> It's *still* far more useful than generating corrupt output and
> pretending all is ok.
An exception trace is *far* better than a segfault and that does not
require null values.
what's better?
a)
auto a = new Class; // returns null (out of memory)
a.foo = 5; // segfault since a is null
OR
b)
auto a = new Class; // throws an out of memory exception
a.foo = 5; // doesn't even reach here
no one here argues for option c where a holds garbage and the program
generates corrupt output.
More information about the Digitalmars-d
mailing list