The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] GOTO etc
@ 2023-03-12 18:23 Steve
  2023-03-12 20:06 ` [TUHS] " Bakul Shah
  0 siblings, 1 reply; 5+ messages in thread
From: Steve @ 2023-03-12 18:23 UTC (permalink / raw)
  To: tuhs

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

Dennis added setjmp() and longjmp() so the shell could handle errors in a reasonable way.
There are two places where setjmp was used in the original shell (7th edition) code as I recall.  
Both at the top level
in main.c.

The idea came from Algol68 but I do not know where it was originally invented.  longjmp() was used 
in the "exitsh"
function that got called on the exit command, default trap routine and a fault with no trap set.

It was also used when executing a subshell to avoid a fork and exec.  In this case the setjmp() was 
at top level
in the initial sh setup.

Hope this makes sense.  But these were two different uses.  One for error recovery and one to reset 
the execution environment
back to initial state.

Steve

[-- Attachment #2: Type: text/html, Size: 1116 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [TUHS] Re: GOTO etc
  2023-03-12 18:23 [TUHS] GOTO etc Steve
@ 2023-03-12 20:06 ` Bakul Shah
  2023-03-12 21:10   ` Paul Winalski
  0 siblings, 1 reply; 5+ messages in thread
From: Bakul Shah @ 2023-03-12 20:06 UTC (permalink / raw)
  To: srb; +Cc: tuhs

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

Perhaps you’re talking about non-local GOTOs in Algol68, where you can jump from a nested procedure to a label in a lexically enclosing procedure. Pascal has this too. C has no nested procedures but its setjmp/longjmp is much more powerful (& dangerous). Though both can be used to the top level of a REPL or to jump to a known place after an error.

> On Mar 12, 2023, at 11:24 AM, Steve <srb@unixsh.com> wrote:
> 
>  Dennis added setjmp() and longjmp() so the shell could handle errors in a reasonable way.
> There are two places where setjmp was used in the original shell (7th edition) code as I recall.  Both at the top level
> in main.c.
> 
> The idea came from Algol68 but I do not know where it was originally invented.  longjmp() was used in the "exitsh"
> function that got called on the exit command, default trap routine and a fault with no trap set.
> 
> It was also used when executing a subshell to avoid a fork and exec.  In this case the setjmp() was at top level
> in the initial sh setup.
> 
> Hope this makes sense.  But these were two different uses.  One for error recovery and one to reset the execution environment
> back to initial state.
> 
> Steve

[-- Attachment #2: Type: text/html, Size: 1821 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [TUHS] Re: GOTO etc
  2023-03-12 20:06 ` [TUHS] " Bakul Shah
@ 2023-03-12 21:10   ` Paul Winalski
  2023-03-16 20:35     ` Steve Bourne
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Winalski @ 2023-03-12 21:10 UTC (permalink / raw)
  To: Bakul Shah; +Cc: srb, tuhs

On 3/12/23, Bakul Shah <bakul@iitbombay.org> wrote:
> Perhaps you’re talking about non-local GOTOs in Algol68, where you can jump
> from a nested procedure to a label in a lexically enclosing procedure.
> Pascal has this too.

So does PL/I.

-Paul W.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [TUHS] Re: GOTO etc
  2023-03-12 21:10   ` Paul Winalski
@ 2023-03-16 20:35     ` Steve Bourne
  0 siblings, 0 replies; 5+ messages in thread
From: Steve Bourne @ 2023-03-16 20:35 UTC (permalink / raw)
  To: Paul Winalski, Bakul Shah; +Cc: srb, tuhs

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

Hi Bakul, yes non local GOTOs.  In the Algol68C compiler we wrote we used the names setmp and longjmp
for the code generation routines to implement non local goto.  So as you say they were not partof 
the Algol68 language.

Steve

On 3/12/23 5:10 PM, Paul Winalski wrote:
> On 3/12/23, Bakul Shah<bakul@iitbombay.org>  wrote:
>> Perhaps you’re talking about non-local GOTOs in Algol68, where you can jump
>> from a nested procedure to a label in a lexically enclosing procedure.
>> Pascal has this too.
> So does PL/I.
>
> -Paul W.


[-- Attachment #2: Type: text/html, Size: 1255 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [TUHS] GOTO etc.
@ 2023-03-19 15:41 Steve
  0 siblings, 0 replies; 5+ messages in thread
From: Steve @ 2023-03-19 15:41 UTC (permalink / raw)
  To: tuhs

[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]

After some digging - in the Algol68C compiler we used the names setmp and longjmp for the code 
generation routines to implement non local goto.  So as you say they were not part of the Algol68 
language. Steve
From: Bakul Shah<bakul@iitbombay.org>
Subject: [TUHS] Re: GOTO etc
To:srb@acm.org

Perhaps you’re talking about non-local GOTOs in Algol68, where you can jump from a nested procedure to a label in a lexically enclosing procedure. Pascal has this too. C has no nested procedures but its setjmp/longjmp is much more powerful (& dangerous). Though both can be used to the top level of a REPL or to jump to a known place after an error.

> On Mar 12, 2023, at 11:24 AM, Steve<srb@unixsh.com>  wrote:
>
>  Dennis added setjmp() and longjmp() so the shell could handle errors in a reasonable way.
> There are two places where setjmp was used in the original shell (7th edition) code as I recall.  Both at the top level
> in main.c.
>
> The idea came from Algol68 but I do not know where it was originally invented.  longjmp() was used in the "exitsh"
> function that got called on the exit command, default trap routine and a fault with no trap set.
>
> It was also used when executing a subshell to avoid a fork and exec.  In this case the setjmp() was at top level
> in the initial sh setup.
>
> Hope this makes sense.  But these were two different uses.  One for error recovery and one to reset the execution environment
> back to initial state.
>
> Steve

[-- Attachment #2: Type: text/html, Size: 2067 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-19 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12 18:23 [TUHS] GOTO etc Steve
2023-03-12 20:06 ` [TUHS] " Bakul Shah
2023-03-12 21:10   ` Paul Winalski
2023-03-16 20:35     ` Steve Bourne
2023-03-19 15:41 [TUHS] " Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).