Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-10

Non-local goto’s and nested exits

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Adriaan van Os

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

Reply by email

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote
I wonder if there is anything special that hinders the implementation of non-local goto’s and nested exits in macpas mode.

Afaik it's mainly a matter of no one caring enough about it to implement it. Florian did recently add support for non-local goto's in ISO mode, but it uses setjmp/longjmp directly and therefore probably doesn't play nice with automated types.

I am asking because emulation through exception-handling does seem to work (which implies that the code to unwind the stack is there).

Indeed.

Jonas

Reply by email

Adriaan van Os
to Jonas Maebe
Jonas Maebe wrote 10 lines
On 04 Oct 2010, at 12:17, Adriaan van Os wrote: > I wonder if there is anything special that hinders the implementation > of non-local goto’s and nested exits in macpas mode. Afaik it's mainly a matter of no one caring enough about it to implement it. Florian did recently add support for non-local goto's in ISO mode, but it uses setjmp/longjmp directly and therefore probably doesn't play nice with automated types.

You mean, for example, the implicit exception handling of Ansistrings ?

Regards,

Adriaan van Os

Reply by email

Florian Klaempfl
to Adriaan van Os
Adriaan van Os wrote 13 lines
Jonas Maebe wrote: > > On 04 Oct 2010, at 12:17, Adriaan van Os wrote: > >> I wonder if there is anything special that hinders the implementation >> of non-local goto’s and nested exits in macpas mode. > > Afaik it's mainly a matter of no one caring enough about it to > implement it. Florian did recently add support for non-local goto's in > ISO mode, but it uses setjmp/longjmp directly and therefore probably > doesn't play nice with automated types. You mean, for example, the implicit exception handling of Ansistrings ?

Yes, I think I didn't handle this properly. Gotos out and into procedures having implicit exeception handling should be forbidden. My patch does not check all involved procedures but this should be easy to implement.

Reply by email

Florian Klaempfl
to Florian Klaempfl
Florian Klaempfl wrote 17 lines
Am 14.10.2010 14:09, schrieb Adriaan van Os: > Jonas Maebe wrote: >> >> On 04 Oct 2010, at 12:17, Adriaan van Os wrote: >> >>> I wonder if there is anything special that hinders the implementation >>> of non-local goto’s and nested exits in macpas mode. >> >> Afaik it's mainly a matter of no one caring enough about it to >> implement it. Florian did recently add support for non-local goto's in >> ISO mode, but it uses setjmp/longjmp directly and therefore probably >> doesn't play nice with automated types. > > You mean, for example, the implicit exception handling of Ansistrings ? Yes, I think I didn't handle this properly. Gotos out and into procedures

Actually into is allowed and possible.

Reply by email