Re: Benefits of Dynamic Typing
- From: Marcin 'Qrczak' Kowalczyk <qrczak@xxxxxxxxxx>
- Date: Sat, 01 Oct 2005 12:45:23 +0200
Joachim Durchholz <jo@xxxxxxxxxxxxx> writes:
> Maybe I'm dense, but I fail to see the difference between "unexpected
> situations" (failed contracts on internal data) and "really unexpected
> situations" (failed contracts when using underlying infrastructure).
>
> From the perspective of the end user, I mean.
For the end user they are the same. But they are handled differently.
When the former problem is detected, it logs the error using the
generic mechanism of the compiler for gathering errors, possibly
associated with a source location, and the exception is used only
to transfer the control flow.
The latter problem is detected in parts not specific to the compiler,
and the only information about the reason is carried by the exception
itself (and the stack trace).
The distinctive property of these fatal errors is not that they are
bugs in the compiler, but that compilation cannot continue after they
are found. They only happen to almost coincide currently.
[...]
> Either case, the calling software layer doesn't need to propagate
> the detail information of the exception.
I don't understand. Consider the well known function Map which applies
a function to each element of a sequence and gathers results. If some
application fails, the entire Map call fails with the same exception.
Was it expected by Map? It didn't expected any particular exception,
but it did expect that some application might fail. And the exception
is propagated.
Exceptions are useful when the cause of the problem is separated from
the point when it can be handled by some other code. Without exceptions
I would have to have a separate variant of Map which allows the mapped
function to signal that it wishes to abort processing.
>> This is how it worked in Turbo Pascal. I don't like this. It's too
>> easy to fail to check the status often enough, and then the program
>> will unnecessarily attempt to continue despite its I/O being partially
>> redirected to nowhere, failing to notice that there is a problem.
>
> So what? A few unnecessary calls if an unanticipated error situation
> comes up aren't a big issue. It's the normal case that needs to be
> efficient, not the unanticipated one.
It's not just efficiency but performing other interaction with the
world which shouldn't take place after an error. Besides, it would
be applicable only to reading and writing files; what about other
filesystem operations, like renaming a file or listing directory
contents? In these cases there is no file object to store the error
flag in.
--
__("< Marcin Kowalczyk
\__/ qrczak@xxxxxxxxxx
^^ http://qrnik.knm.org.pl/~qrczak/
.
- Follow-Ups:
- Re: Benefits of Dynamic Typing
- From: Joachim Durchholz
- Re: Benefits of Dynamic Typing
- References:
- Re: Benefits of Dynamic Typing
- From: Marcin 'Qrczak' Kowalczyk
- Re: Benefits of Dynamic Typing
- From: Joachim Durchholz
- Re: Benefits of Dynamic Typing
- From: Marcin 'Qrczak' Kowalczyk
- Re: Benefits of Dynamic Typing
- From: Joachim Durchholz
- Re: Benefits of Dynamic Typing
- Prev by Date: Re: Benefits of Dynamic Typing
- Next by Date: Re: Benefits of Dynamic Typing
- Previous by thread: Re: Benefits of Dynamic Typing
- Next by thread: Re: Benefits of Dynamic Typing
- Index(es):
Relevant Pages
|