Re: Try Finally...

From: VBDis (vbdis_at_aol.com)
Date: 10/26/04


Date: 26 Oct 2004 21:27:45 GMT

Im Artikel <sparn0pbklldug52ljm3vrhlf6cbssd87i@4ax.com>, L D Blake
<not@any.adr> schreibt:

>Ok... lemme give you a tiny suggestion... Instead of arguing against you know
>not what; try asking questions until you understand. You will find that I
>(and people in general) respond much more favorably to inquiry than errant
>challenges.

Point taken. So please explain what's wrong with this code:

try
  assert(False, 'test exception');
finally
  WriteLn('don't want to handle exceptions');
end;

as opposed to

try
  assert(False, 'test exception');
except
  WriteLn('don't want to abort on exceptions');
end;

Okay, after an test with D4 I understand your complaint that without the
inclusion of SysUtils the first version aborts immediately, without executing
the Finally code. But since the code takes no means to prevent an abort at all,
this seems to be the shortest way to do exactly what the code means: abort on
any exception. Short also in code size, 23KB less due to not including
SysUtils.

But as soon as any unit in the project uses SysUtils, the Finally part
executes, and also the debugger stops the program when the exception is raised.

More annyoing, and really unexpected to any Delphi user, is the behaviour of
Except, when SysUtils is not used anywhere in the project. Then also Except
does not prevent the program from being terminated immedately, when an
exception occurs! Thanks for demonstrating that :-)

So let me rephrase your complaint about Delphi SEH. It should not read:
  Finally causes a program to abort.
Instead it should read:
  Except does not prevent a program from aborting, if SysUtils is not used.

DoDi



Relevant Pages

  • RE: Is there a better way to implement this:
    ... This will also execute function abort() as a thread. ... However, before it returns, throws an exception. ... def abort: ...
    (comp.lang.python)
  • Re: Threadabortexception
    ... Aborting a thread injects an abort exception into the target ... if the thread is executing unmanaged code the abort will ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Threadabortexception
    ... Aborting a thread injects an abort exception into the target ... if the thread is executing unmanaged code the abort will ...
    (microsoft.public.dotnet.general)
  • Re: number prefix survey
    ... just output an error message and continue interpreting. ... SwiftForth's EVALUATE does throw the exception onward, ... There's a global CATCH around the whole process, and low-level CATCHes where they're appropriate. ... IMO an abort wouldn't be unreasonable either; ...
    (comp.lang.forth)
  • Re: Threadabortexception
    ... But u say exception is rethrown from the point of abortion to start ... > The abort causes an exception to be raised, and even if a catch block handle ... Aborting a thread injects an abort exception into the target ... > execution paths, such as finally blocks and static constructors, that you ...
    (microsoft.public.dotnet.languages.csharp)