[phobos] Calling abort() on unhandled exception
David Simcha
dsimcha at gmail.com
Fri Jul 30 09:33:59 PDT 2010
What's wrong with stack traces in short scripts? I use D all the time for
short (< a few hundred lines) scripts and sometimes I use Python instead
when I need a library that's not easily available in D or need to share my
code with Python hackers. I honestly prefer Python's "always print a stack
trace" to D's "make me fire up a debugger" for anything over ~50 lines (the
point where I start to use functions instead of just writing all my code
inline in main()).
On Fri, Jul 30, 2010 at 11:52 AM, Andrei Alexandrescu <andrei at erdani.com>wrote:
> Steve Schveighoffer wrote:
>
>> Um, no. Exceptions can easily be uncaught (oops, forgot a try catch!). I
>> don't want the end result of an uncaught exception to be a bug that's
>> impossible or difficult to determine because no stack trace was printed.
>> Let's consider that an exception may not be easily repeated and is most
>> likely encountered by a user, not a developer. Giving a mechanism to
>> communicate the problem as completely as possible from the user developer
>> should be the default.
>>
>> We should classify any exception or error that gets thrown outside of main
>> to be an exception that was not planned for by the developer, and therefore
>> a program error. This should trigger as much info as possible, definitely
>> including a stack trace, and possibly a core dump (though, dumping core
>> after catching an exception is next to useless).
>>
>> If you want to avoid printing stack traces, catch the exception inside of
>> main. I don't think it's too much to ask.
>>
>
> That argument goes both ways, i.e. I could tell you it's not much to ask to
> insert a try/catch if you care about the stack trace.
>
> It comes back to doing a sensible thing by default. main() without a
> try/catch is common in short scripts. I am currently _exceedingly_ happy
> that I'm able to write 10-line scripts that do something interesting and
> behave reasonably in all circumstances. Obviously, a stack trace is not
> something anyone would be interested in for a short script. You are saying
> that I should take a size hit in order to protect you from adding 6 lines to
> a 100,000 lines program.
>
> D should be script-friendly, it's a huge boon and a huge appeal, and stack
> traces don't go with script friendliness. Serious programs can afford the
> slight overhead.
>
> See my point?
>
>
> Andrei
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100730/07ba4dca/attachment.html>
More information about the phobos
mailing list