[phobos] Calling abort() on unhandled exception
Leandro Lucarella
luca at llucax.com.ar
Fri Jul 30 19:32:52 PDT 2010
Andrei Alexandrescu, el 30 de julio a las 17:37 me escribiste:
> Leandro Lucarella wrote:
> >That's not an exception!!!! What's the point of that???? Why don't you
> >just write a library function like like enforce but that uses exit(1)
> >instead of throwing an exception for that?!?!?! You really want to
> >sacrifice the correct behavior for this dumb, dumb "feature"???
> >This really makes me mad! God...
>
> Relax, we're all on the same boat. To answer each question in sequence:
>
> 1. The point of that is to terminate the program if the number of
> arguments passed is not satisfactory.
>
> 2. I don't write a library function like enforce that uses exit(1) because:
>
> 2.1. I'd have to write a ton of them.
No, just one. The same way you don't have to write tons of enforece()
functions, you don't have to write tons of die() functions.
> 2.2. I don't want to exit(1), I want to correctly propagate an
> exception. In this particular case it would exit straight out of
> main so it's the same as exit(1) but many scripts have more than one
> function.
No, you want to cleanly exit the program, the fact that C's exit() might
not be appropriate doesn't mean that all exceptions should be treated as
user errors. See bug 3462[1].
[1] http://d.puremagic.com/issues/show_bug.cgi?id=3462
> 3. I don't want to sacrifice correct behavior for anything in
> particular. It is your view that the behavior you like is correct
> and the one I like is incorrect.
My view, and the view of most programming languages. And about abort()
(this is mostly about stack traces now, but what I really think it's the
most serious issue is not using abort()) you're still ignoring the fact
that you can't get a debugger pointing to the place where the uncaught
exception was originally thrown with your approach. You have multiple
options to easily show errors to users, but not the other way around.
I think that are very important arguments against your view.
> >Plus *ANY* other programming language mark uncaught exceptions as
> >OBVIOUS ERRORS (they print traces or abort()).
>
> Not Perl for example. I don't know whether Java prints the stack by
> default or not.
Is funny that you use Perl as an example, because Perl doesn't have
exceptions. See my other mail with examples of the multiple PL what
actually support exceptions and how they print stack traces.
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
SATANAS EN COMISARIA
-- Crónica TV
More information about the phobos
mailing list