C# interview
Christopher Wright
dhasenan at gmail.com
Thu Oct 2 19:15:14 PDT 2008
Ary Borenszweig wrote:
> What's that feature in D?
>
> If null references are the most problematic (and I must agree because I
> started a project in D and I got null referneces a few times already,
> but no other "bug"), why is it that in debug mode asserts are not put
> for every reference access, to show "somefile.d(58): Error: Null
> Reference" instead of just "Error: Access Violation"? :-(
>
> No, instead you have to open a debugger to discover the file and line
> number... What's the point of losing that time?
You get a stacktrace if you use jive or the Windows equivalent.
Back to the original topic, almost all of the time, you don't encounter
this bug. So it doesn't make any sense to introduce this to the type
system, at least not with the default being the method requiring
additional logic.
Groovy has a ?. operator:
int i = foo?.bar;
=>
int i;
if (foo is null)
i = default(typeof(foo.bar));
else
i = foo.bar;
That operator costs one additional character and pretty much no thought.
More information about the Digitalmars-d
mailing list