delphi apparently functions the same if I've read the docs right. something about returning control to the exception handler BEFORE your program gets control back.

--
Alexander Grotewohl
http://dcclost.com

On Jun 23, 2019 3:08 AM, Dennis <de...@avidsoft.com.hk> wrote:

Using fpc 3.0.4, Lazarus 2.0, the following simple program

program tryfinally;

begin
  try
    Writeln('before finally');
  finally
     Writeln('inside finally. Before Exit');
     exit; //<----why isn't it executed?
  end;
  Writeln('after try finally block');

end.

gives

P:\RAM64>tryfinally.exe
before finally
inside finally. Before Exit
after try finally block

I have tried putting the try finally block inside a procedure, the same
happened.
program tryfinally;

procedure Test;
begin
    try
      Writeln('before finally');
    finally
       Writeln('inside finally. Before Exit');
       exit;
    end;
    Writeln('after try finally block');
end;

begin
  Test;

end.

Dennis
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to