Re: Try Finally...

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 10/26/04


Date: Tue, 26 Oct 2004 11:50:04 +0200


"L D Blake" <not@any.adr> wrote in message
news:3a1sn0lud3c6ilu39gihrbsl8n98odk54v@4ax.com...
> On Tue, 26 Oct 2004 08:47:56 +0100, Duncan McNiven <duncan@mcniven.net>
wrote:

>> I for one am left with the impression that you are
>> re-writing the Delphi code to get around problems caused by
>> misunderstanding and misusing that code.
>
> and I for one am becoming deeply insulted.

Don't be, it's not what we're trying to do.

[...]
> My hope was to discuss the way the *language* itself works...

There are two ways to do that. You can discuss the way it's implemented
(and alternative ways of implementing it), or the way it's documented
to behave, apart from any implementation issues. You're doing the former
while everybody else is doing the latter.

> As I've already made plenty clear in other messages any language with
> a reserved word that depends on loaded units has one serious problem.
[...]
> Now I don't know about you... but I'd rather mess with the guts of the
> language than risk that happening.

And at the end of the day, we can choose whether to include
LaurasExceptionHandling or SysUtils in our uses clauses. And SysUtils we
already had at the start of the day.

We all know different things, and we all do-not-know different things.
You're well versed in Windows exception handling, most of us have only
seen it from the outside: what Delphi does, not even how it does it.
That makes talking about it difficult.

Checking back, your initial question in this thread was how a finally
clause should handle a non-fatal exception. I contend that this is the
wrong question to ask of a finally clause, because it does not handle
the exception at all. You also said something about how except clauses
handled fatal and non-fatal exceptions differently in your code; I
freely admit that it made no sense to me at the time.

The right thing to do, I think, would be to add a retry statement to
the language. Failing that (because nobody but Borland can do that; one
can only hook into the existing exception handling mechanism by linking
in alternate procedures), a discussion about how continuable exceptions
could be incorporated into the current language would be great. But you
could have started by explaining what they were, precisely, and _then_
we could have discussed how except and finally might react differently
to non-fatal exceptions than they do now. Pounding on implementation
details that only you understand isn't conducive to an open discussion,
either.

As an opening, I think there should be no retrying from a finally clause
at all. As Rob(?) said, a finally clause should ideally not even know if
an exception occurred or not. If one did, retrying should jump back to
the offending instruction; without one, it should do nothing. Not only
because there is nothing to retry, but it would cause an infinite loop.

I eagerly await any holes you can shoot in this.

Groetjes,
Maarten Wiltink



Relevant Pages

  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... error occurs during execution. ... statementList2 (the finally clause) is executed. ... exception is raised during execution of statementList1, ... THE IF THEN ELSE STATEMENT DOCUMENTATION IS JUST AS FUCKED:)' ...
    (alt.comp.lang.borland-delphi)
  • Re: Finally in IE
    ... If an exception is thrown, each catch clause is inspected in turn ... the clause executes wether or not an exception is thrown ... Firefox considers your <script> block as self-enclosed system. ...
    (comp.lang.javascript)
  • Re: "ensure" hiding actual error
    ... You caused another exception inside your ensure clause, ... problems with handling correctly the original exception. ... IIRC initially this was about a syntax error. ...
    (comp.lang.ruby)
  • [Proposal] using statement enhancements
    ... Mostly always you use the using clause you deal with native ressources, ... exception handlinjg is sooner or later inevitable. ... Rollback(); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Language comparison - Failing destructors?
    ... > language can only cope with one exception at a time. ... write destructors that don't throw exceptions. ... exception that was thrown from a finally clause. ...
    (comp.programming)