[fpc-devel] Non-local goto’s and nested exits

Adriaan van Os fpc at microbizz.nl
Mon Oct 4 12:17:09 CEST 2010


I wonder if there is anything special that hinders the implementation of non-local goto’s and 
nested exits in macpas mode. I am asking because emulation through exception-handling does seem to 
work (which implies that the code to unwind the stack is there).

For example:


{$mode macpas}
{$modeswitch exceptions+}

program unwind;

uses sysutils;

procedure A;

   procedure B;
       begin
         writeln
           ( 'B begin');
         raise Exception.Create
           ( 'B exception raised');
         writeln
           ( 'B end')
       end;

     begin
       writeln
         ( 'A begin');
       B;
       writeln
         ( 'A end')
     end;

begin
   writeln
     ( 'Program begin');
   try
     writeln
       ( 'try A');
     A;
   except
     writeln
       ( 'except A');
   end;
   writeln
     ( 'Program end')
end.


compiles and prints


Program begin
try A
A begin
B begin
except A
Program end


Regards,

Adriaan van Os



More information about the fpc-devel mailing list