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


Groups > comp.lang.forth > #10548

Re: DO... LOOP question

From Hugh Aguilar <hughaguilar96@yahoo.com>
Newsgroups comp.lang.forth
Subject Re: DO... LOOP question
Date 2012-03-26 20:14 -0700
Organization http://groups.google.com
Message-ID <bcaa1252-7ca3-4a30-9d7d-4bca65da9291@i2g2000vbv.googlegroups.com> (permalink)
References <jk50b8$i6f$1@dont-email.me> <98434df3-19b6-4105-8350-09d73de4f697@d17g2000vba.googlegroups.com> <jkl15f$983$2@dont-email.me>

Show all headers | View raw


On Mar 24, 11:44 am, Arnold Doray <inva...@invalid.com> wrote:
> On Wed, 21 Mar 2012 03:01:25 -0700, Hugh Aguilar wrote:
> > I am not even going to support DO loops in Straight Forth --- they are
>
> No DO loops? What is your alternative?

Use WHILE loops. In the bad old days before Forth had local variables,
WHILE loops were awkward because the index that you were looping on
had to be held on the parameter, where it got in the way of the data
that you were working with. DO loops solved this by holding the index
in I where it didn't clutter up the stack. Now that we have local
variables however, the index can be held in a local variable where it
won't clutter up the stack.

Also, I'm introducing some variations on WHILE that will simplify some
common cases, such as looping through an array (what DO is generally
used for now). In addition to simplifying the user's source-code,
these will also simplify the job of the compiler-writer, as he can
make the compiler generate efficient code without having to first
pattern-match the code sequences in the user's code. These variations
on WHILE are just for convenience though --- it is possible to just
use WHILE.

> > just cruft --- I and J were invented by Chuck Moore at a time prior to
> > the invention of general-purpose local variables, and they are not
> > needed now.
>
> I don't think that's true. Forth was invented in the 1970's. There were
> plenty of programming languages with local variables by then - Algol,
> BASIC to name a couple. Or have I misunderstood you?

I was unclear; what I meant was:
"I and J were invented by Chuck Moore at a time prior to [the
introduction] of general-purpose local variables [into Forth], and
they are not needed now."

Forth was a long-time in getting local variables, mostly because Chuck
Moore was opposed to them. I agree with C.M. that they are a bad idea
when overused, however I do think that they can simplify some code
(such as WHILE loops, for example). C.M. didn't like locals, but then
he invented I and J which essentially *are* locals, but which are not
general-purpose --- they is just cruft now that we have general-
purpose locals available.

The point of Straight Forth is closures, so locals are a big deal for
me. Closures are the one thing that I'm adding. I'm taking quite a lot
away however, such as DO loops --- so Straight Forth will come out a
lot leaner than ANS-Forth overall.

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


Thread

DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-18 15:52 +0000
  Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-18 17:08 +0100
  Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 09:41 -0700
    Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-18 20:51 +0100
      Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 14:37 -0700
    Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 15:56 -0700
      Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-19 01:04 +0100
        Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 17:25 -0700
        Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 17:43 -0700
          Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 18:48 -0700
        Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 21:49 -0700
          Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-19 11:39 -0700
          Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-20 12:16 -0700
    Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-20 16:54 +0000
      Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-20 11:41 -0700
        Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-24 17:29 +0000
          Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-24 13:22 -0500
            Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-25 04:09 +0000
              Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-25 13:49 +0200
                Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-27 17:47 +0000
              Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-25 19:45 +0000
              Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-26 04:26 -0500
                Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-26 07:28 -0700
                Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-26 10:03 -0500
                Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-26 18:47 +0200
                Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-26 09:53 -0700
                Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-27 11:21 +0000
                Re: DO... LOOP question Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 04:34 -0700
                Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-27 17:33 +0200
                Re: DO... LOOP question Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 09:19 -0700
                Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-27 12:20 -0700
                Re: DO... LOOP question "Elizabeth D. Rather" <erather@forth.com> - 2012-03-27 09:34 -1000
                Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-27 13:00 -0700
              Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-26 20:16 -0700
          Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-24 11:37 -0700
            Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-25 06:39 +0000
              Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-25 06:19 -0700
      Re: DO... LOOP question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-21 05:48 -0400
        Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-21 08:36 -0700
      Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-21 11:24 -0700
  Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-21 03:01 -0700
    Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-24 17:44 +0000
      Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-25 11:57 +0000
      Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-26 20:14 -0700
        Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-27 16:46 +0000

csiph-web