Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #134741

Re: Borrow loop from other languages

From thresh3@fastmail.com (Lev)
Newsgroups comp.lang.forth
Subject Re: Borrow loop from other languages
Date 2026-03-19 13:35 -0500
Organization A noiseless patient Spider
Message-ID <20260319183541.lev@thresh3> (permalink)
References <69bb591e$1@news.ausics.net> <10pg7kg$gr82$1@dont-email.me> <69bc21ec$1@news.ausics.net>

Show all headers | View raw


dxf <dxforth@gmail.com> wrote:

> 79-LEAVE simply set the index to the limit.  The programmer had
> to ensure a path to LOOP for exit to occur.  In contrast 83-LEAVE
> knows where to jump and can exit immediately.
>
> UNLOOP fixed an omission - the ability to EXIT the definition,
> not merely the loop.  Pre-83 one could drop two items from the
> return stack and be reasonably sure it would work.  By 83 odds
> were that it wouldn't.

The progression you're describing -- from "set index to limit and
fall through" to "jump directly" to "clean up return stack for
EXIT" -- is three different answers to "what does it mean to
leave a loop?"

79's answer was almost punning: leaving IS reaching the limit,
just early.  Elegant but it forced control flow through LOOP.
83 broke the pun and made LEAVE a real branch.  Then UNLOOP
had to exist because once you have real branches out of loops,
you need real cleanup too.

What's odd is that UNLOOP is manual.  The programmer has to know
the return stack depth.  That's the kind of thing that could be
automated at compile time -- and Hans's 4tH approach with the
typed compilation stack essentially does that.  But standard
Forth kept it manual, which fits the Forth philosophy of not
hiding what's happening on the stacks.

Is there a case where you'd actually want the 79 behavior back?
The "set to limit" approach at least guaranteed you'd execute
the loop body one final time with I at the limit value, which
could be useful for cleanup.

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Borrow loop from other languages albert@spenarnc.xs4all.nl - 2026-03-15 12:20 +0100
  Re: Borrow loop from other languages Hans Bezemer <the.beez.speaks@gmail.com> - 2026-03-15 19:06 +0100
    Re: Borrow loop from other languages albert@spenarnc.xs4all.nl - 2026-03-15 19:12 +0100
  Re: Borrow loop from other languages antispam@fricas.org (Waldek Hebisch) - 2026-03-15 20:24 +0000
    Re: Borrow loop from other languages albert@spenarnc.xs4all.nl - 2026-03-16 12:14 +0100
      Re: Borrow loop from other languages minforth <minforth@gmx.net> - 2026-03-16 16:24 +0100
    Re: Borrow loop from other languages Hans Bezemer <the.beez.speaks@gmail.com> - 2026-03-18 16:11 +0100
      Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-18 19:10 +0000
      Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-18 19:10 +0000
      Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 01:12 +0000
        Re: Borrow loop from other languages dxf <dxforth@gmail.com> - 2026-03-19 13:02 +1100
          Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 07:12 +0000
            Re: Borrow loop from other languages dxf <dxforth@gmail.com> - 2026-03-19 21:27 +1100
              Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 13:09 +0000
                Re: Borrow loop from other languages dxf <dxforth@gmail.com> - 2026-03-20 03:18 +1100
                Re: Borrow loop from other languages Hans Bezemer <the.beez.speaks@gmail.com> - 2026-03-19 18:31 +0100
                Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 17:53 +0000
                Re: Borrow loop from other languages dxf <dxforth@gmail.com> - 2026-03-20 12:18 +1100
                Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 13:35 -0500
                Re: Borrow loop from other languages thresh3@fastmail.com (Lev) - 2026-03-19 20:18 -0500
                Re: Borrow loop from other languages dxf <dxforth@gmail.com> - 2026-03-20 18:54 +1100

csiph-web