<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr">Thanks! Is this where unix setjmp/longjmp names come from? (I assume setmp in your message is a typo?)<div dir="ltr"><br></div><div dir="ltr">Algol68 Revised Report has this delightful example in section 5.4.4:<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="page" title="Page 93"><div class="layoutArea"><div class="column"><p><b>proc</b> <b>void</b> <i>m</i> := <b>goto</b> <i>north berwick</i></p></div></div></div></blockquote><div>:-) If <i>m</i> is passed as an argument to another function, calling <i>m</i> can return to within the parent function of <i>m</i> but it may *not* be in the scope of the called function (somewhat like unix setjmp/longjmp) though I don’t recall now if Algol68 allows passing such functions.</div><div><br></div><div>Could setjmp/longjmp have been used to allow some register caching since register held values would be restored upon longjmp? But that can't be quite right since the same values can be modified by code after the label. [No idea about the state of optimizations in those days]</div></div><div dir="ltr"><br><blockquote type="cite">On Mar 19, 2023, at 8:41 AM, Steve <srb@unixsh.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">
  

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  
  
    <pre class="moz-quote-pre" wrap=""><font face="Helvetica, Arial, sans-serif">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
</font>
From: Bakul Shah <a class="moz-txt-link-rfc2396E" href="mailto:bakul@iitbombay.org"><bakul@iitbombay.org></a>
Subject: [TUHS] Re: GOTO etc
To: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:srb@acm.org">srb@acm.org</a>

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.

</pre>
    <blockquote type="cite" style="color: #007cff;">
      <pre class="moz-quote-pre" wrap="">On Mar 12, 2023, at 11:24 AM, Steve <a class="moz-txt-link-rfc2396E" href="mailto:srb@unixsh.com"><srb@unixsh.com></a> 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
</pre>
    </blockquote>
  

</div></blockquote></div></body></html>