what is setjump() ?

L

lallous

Hello,

So far, setjump() was never used in any of my programs...
Is it portable? where its usage mostly fits?

Was it exception catching mechanism just as exception handling now exist in
decent languages?
 
D

Derk Gwen

# Hello,
#
# So far, setjump() was never used in any of my programs...
# Is it portable? where its usage mostly fits?
#
# Was it exception catching mechanism just as exception handling now exist in
# decent languages?

In Algol 60, procedures can be nested, and a goto from an interior procedure
can have a label in a containing procedure.

procedure A; begin
procedure B; begin
procedure C; begin
goto X;
end;
...
C;
end;
C;
W: ...
X: ...
end;

will continue at X not W. Because C does not have nestable procedures,
a more complicated mechanism was created.
 
D

Dik T. Winter

> # So far, setjump() was never used in any of my programs...
> # Is it portable? where its usage mostly fits?
> #
> # Was it exception catching mechanism just as exception handling now exist in
> # decent languages?
>
> In Algol 60, procedures can be nested, and a goto from an interior procedure
> can have a label in a containing procedure.
>
> procedure A; begin
> procedure B; begin
> procedure C; begin
> goto X;
> end;
> ...
> C;
> end;
> C;
> W: ...
> X: ...
> end;
>
> will continue at X not W. Because C does not have nestable procedures,
> a more complicated mechanism was created.

While the Algol 60 part is correct, the C mechanism is quite a bit more
than just a jump to another, calling procedure. It is intended to trap
all kinds of error conditions, something Algol 60 could not.

Nesting of procedures and jumping out of inner procedures is something
different from trapping on error conditions.
 
D

Derk Gwen

# While the Algol 60 part is correct, the C mechanism is quite a bit more
# than just a jump to another, calling procedure. It is intended to trap
# all kinds of error conditions, something Algol 60 could not.

procedure A; begin
switch AX := X;
procedure B(eexit); switch eexit; begin
C(eexit);
...
end;
procedure C(eexit); switch eexit; begin
switch CX := Y;
D(CX);...; D(eexit);...
...
Y: ... ; goto eexit[1];
end;
procedure D(eexit); switch eexit; begin
switch DX := Z;
...
goto DX[1];
...
Z: ... ; goto eexit[1]
end;
B(AX);...;C(AX);...;D(AX);...
X: ...
end;

# Nesting of procedures and jumping out of inner procedures is something
# different from trapping on error conditions.

CAR Hoare "Here is a language so far ahead of its time, that it was not
only an improvement on its predecessors, but also on nearly all its
successors."
 
D

Dik T. Winter

> # While the Algol 60 part is correct, the C mechanism is quite a bit more
> # than just a jump to another, calling procedure. It is intended to trap
> # all kinds of error conditions, something Algol 60 could not.
>
> procedure A; begin
> switch AX := X;
> procedure B(eexit); switch eexit; begin
> C(eexit);

Nowhere in this example the trapping of error conditions is present.
So I do not understand the purpose. [ Remainder snipped.]
> # Nesting of procedures and jumping out of inner procedures is something
> # different from trapping on error conditions.
>
> CAR Hoare "Here is a language so far ahead of its time, that it was not
> only an improvement on its predecessors, but also on nearly all its
> successors."

Except that you could not trap on error conditions. Moreover, there
were strange constructs like Jensen's device and:
"begin"
"procedure" B(x, b); "Boolean" b;
"begin"
"if" b "then" "goto" b "else" z := z + b;
"end";
"integer" z;
z := 0;
B(5, "false");
B(5, "true");
B(5, "false");
5:
"end"
where a procedure acts more like a macro than like a real procedure.
(And, yes, I know of at least one compiler that did this correct.
Most compilers did not allow it.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top