[phobos] Calling abort() on unhandled exception

Jonathan M Davis jmdavisprog at gmail.com
Fri Jul 30 18:20:55 PDT 2010


On Friday, July 30, 2010 18:02:48 Brad Roberts wrote:
> On Fri, 30 Jul 2010, Andrei Alexandrescu wrote:
> > It's not that I want. It's an important use of the language. You could
> > argue that D should not attempt to attempt scripting, but I think it
> > should. That implies an ability to write short programs that do useful
> > things.
> > 
> > 
> > Andrei
> 
> It's worth noting that you're changing the definition of the language away
> from it's a Systems Programming language and using that as an argument to
> change behavior.
> 
> I don't disagree with the desire to make short simple apps easy to both
> write and read.  I'm not sure I agree with the requirement to not emit
> anything but the exception's message on an escaping exception.
> 
> I've never, in any language that I've used that has exceptions --
> admitedly not many, considered exceptions to be part of the user of the
> apps experience.  They're internal mechanisms.
> 
> That said, D has upturned a lot of older thinking and styles, and this
> might well be one of the ones worth changing.  I'm not convinced yet.

I tend to agree that users should never see exceptions. I would expect uncaught 
exceptions (other than unrecoverable ones like out of memory) to be logic errors 
in the code, not a means of error reporting to the user. I guess that I kind of 
get where Andrei is coming from though. But personally, I don't see all that big 
a deal in having the exception printed out in such cases. It's useful for 
debugging purposes, and if it's being used by someone other than the developer, 
it could still be useful for bug reporting purposes. Certainly, for what _I_ do, 
I'd prefer to have the stack trace printed.

Perhaps whether the stack trace is printed should be based on whether the code 
was compiled in release mode, or maybe dmd should print a stack trace and rdmd 
shouldn't (though I don't know how much they share and how feasible it would be 
for them to act differently).

For what it's worth, Java prints a stack trace for uncaught exceptions. It 
certainly seems that at least some there are a number of languages out there 
that decided that it was appropriate to print a stack trace for uncaught 
exceptions.

- Jonathan M Davis


More information about the phobos mailing list