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


Groups > comp.lang.forth > #24741

Re: counted loops

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: counted loops
Date 2013-07-23 17:33 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2013Jul23.193330@mips.complang.tuwien.ac.at> (permalink)
References (3 earlier) <51ed8579$0$26873$e4fe514c@dreader37.news.xs4all.nl> <ksk3kk$ji2$1@dont-email.me> <3e-dneCnz7WpPnDMnZ2dnUVZ_tSdnZ2d@supernews.com> <2013Jul23.144213@mips.complang.tuwien.ac.at> <joSdndjkE9eqIXPMnZ2dnUVZ_o-dnZ2d@supernews.com>

Show all headers | View raw


"Elizabeth D. Rather" <erather@forth.com> writes:
>On 7/23/13 2:42 AM, Anton Ertl wrote:
>> Sure, writing a test may be quicker than consulting a book
>> (but that is more a comment on the quality of the books), but the user
>> first has to be aware that -5 +LOOP is behaving unintuitively.
>
>In most cases, +LOOP will do exactly what you expect. The situations in 
>which you might be surprised are fairly specific and don't crop up that 
>often. If you encounter one you can explore quickly.

Even in Forth, debugging a funny condition in a complex program can
take a long time.  And problems don't crop up that often lead to bugs
that hide themselves well and show only up when the program has become
more complex.

>If I'm sitting at my computer I can type in:
>
>: test ( h l -- )   ?DO  I . -5 +LOOP ;
>
>...in about 5 seconds.

You are a fast typist.  But with that code you have only tested that
?DO...+LOOP compiles.  Compiling is not the problematic case.

>To reach for a book, open it, find the right page 
>and read it will take a minute or more. Even if the book's a pdf, I have 
>to find it on my computer, launch Acrobat, find the right section, etc.

Ok, so you made a comment on the lack of performance of Acrobat.  I
just looked for +loop in the Gforth manual (in info format, using
Emacs as info reader), and found the following passage in 25s:

|   * The behaviour of `n +LOOP' is peculiar when n is negative:
|
|          -1 0 ?DO  i .  -1 +LOOP
|
|     prints `0 -1'
|
|          0 0 ?DO  i .  -1 +LOOP
|     prints nothing.
|
|     Therefore we recommend avoiding `n +LOOP' with negative n.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2013: http://www.euroforth.org/ef13/

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


Thread

Happy pi approximation day Luca Saiu <positron@gnu.org> - 2013-07-21 22:45 +0200
  Re: Happy pi approximation day Coos Haak <chforth@hccnet.nl> - 2013-07-22 01:24 +0200
    Re: Happy pi approximation day Coos Haak <chforth@hccnet.nl> - 2013-07-22 01:27 +0200
  Re: Happy pi approximation day Mark Wills <markrobertwills@yahoo.co.uk> - 2013-07-22 01:14 -0700
    Re: Happy pi approximation day Luca Saiu <positron@gnu.org> - 2013-07-22 11:53 +0200
    Re: Happy pi approximation day anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-22 15:46 +0000
      Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-22 19:18 +0000
        Re: Happy pi approximation day Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-07-22 21:17 +0100
          Re: Happy pi approximation day "Elizabeth D. Rather" <erather@forth.com> - 2013-07-22 11:25 -1000
            counted loops (was: Happy pi approximation day) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-23 12:42 +0000
              Re: counted loops "Elizabeth D. Rather" <erather@forth.com> - 2013-07-23 07:24 -1000
                Re: counted loops anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-23 17:33 +0000
                Re: counted loops "Elizabeth D. Rather" <erather@forth.com> - 2013-07-23 08:06 -1000
                Re: counted loops albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-23 19:47 +0000
                Re: counted loops "Elizabeth D. Rather" <erather@forth.com> - 2013-07-23 10:02 -1000
                Re: counted loops Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-23 14:58 -0500
                Re: counted loops "Elizabeth D. Rather" <erather@forth.com> - 2013-07-23 10:14 -1000
                Re: counted loops anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-24 08:13 +0000
                Re: counted loops Elizabeth D Rather <erather@forth.com> - 2013-07-23 22:42 -1000
                Re: counted loops stephenXXX@mpeforth.com (Stephen Pelc) - 2013-07-24 09:55 +0000
                Re: counted loops stephenXXX@mpeforth.com (Stephen Pelc) - 2013-07-24 09:37 +0000
          Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-23 01:30 +0000
            Re: Happy pi approximation day "Elizabeth D. Rather" <erather@forth.com> - 2013-07-22 19:08 -1000
            Re: Happy pi approximation day m.a.m.hendrix@tue.nl - 2013-07-23 00:19 -0700
            Re: Happy pi approximation day anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-23 13:07 +0000
              Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-23 17:37 +0000
          Re: Happy pi approximation day anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-23 12:31 +0000
            Re: Happy pi approximation day Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-07-23 19:39 +0100
              Re: Happy pi approximation day anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-24 08:16 +0000
                Re: Happy pi approximation day Mark Wills <markrobertwills@yahoo.co.uk> - 2013-07-24 04:23 -0700
                Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-24 11:59 +0000
                Re: Happy pi approximation day Bernd Paysan <bernd.paysan@gmx.de> - 2013-07-24 21:32 +0200
                Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-24 20:07 +0000
                Re: Happy pi approximation day Bernd Paysan <bernd.paysan@gmx.de> - 2013-07-24 23:20 +0200
  Re: Happy pi approximation day m.a.m.hendrix@tue.nl - 2013-07-22 01:30 -0700
    Re: Happy pi approximation day Luca Saiu <positron@gnu.org> - 2013-07-22 11:55 +0200
    Re: Happy pi approximation day albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-22 11:24 +0000
      Re: Happy pi approximation day Richard Owlett <rowlett@pcnetinc.com> - 2013-07-22 10:48 -0500
        Re: Happy pi approximation day Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-22 14:44 -0500
  Re: Happy pi approximation day Mark Wills <markrobertwills@yahoo.co.uk> - 2013-07-24 00:43 -0700
    Re: Happy pi approximation day Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-24 03:07 -0500

csiph-web