A few questions

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 27 11:30:44 PDT 2012


On Friday, July 27, 2012 20:07:56 Namespace wrote:
> > Walter's stand on this is that the OS gives you
> > null-dereferencing detection -
> > i.e. segfaults and access violations. He's not going to add
> > extra syntax for
> > it.
> > 
> > - Jonathan M Davis
> 
> That is a huge mistake. My OS prints me only a funny "Access
> violation". And so i can search for my little null reference by
> myself. I _must_ debug for a ridiculous null reference. That cost
> time. I have not even a filename or a line number. Only the
> message that something went wrong. And all other i have to find
> by myself. So much time for such little mistakes.
> 
> Why would Walter have a language which doesn't support good error
> handling?

Because a debugger will show you exactly where the problem is. So, why add 
checking that the OS already does for you? That's his logic. There are plenty 
of cases where that really isn't enough (e.g. you get a segfault on a server 
application without core dumps turned on when it's been running for 2 weeks), 
but it is for all the types of programs that Walter works on, so that's the 
way he thinks.

> D hasn't support for unused variables, unused imports and even
> not for null references. Why should everyone use D instead of any
> other language?
> If i have a big project and i use many objects and one of them
> change to null, what now? Should the user really step through
> thousand lines of code because D prints only "Access Violation"
> without any further information? Or should i use the same
> principle as Java, and write every time again pre- and
> postconditions? I don't see any reasons why anybody should
> realize a big project with D and not with a other language, if
> the error handling and not null support remains as it is. Sorry.
> 
> To reject even a such handy shorthand is incomprehensible to me.

Honestly, I think that you're blowing null pointer dereferences way out 
proportion. In my experience, they're rare, and I have to wonder what you're 
doing if you're seeing them all that often.

That being said, what I think we're likely to end up with is a signal handler 
in druntime which prints out a stacktrace when a segfault occurs (and does 
whatever the Windows equivalent would be on Windows). That way, you don't have 
to have null checks everywhere, but you still get the debug information that 
you need. But no one has done that yet.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list