Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #24650 > unrolled thread
| Started by | Luca Saiu <positron@gnu.org> |
|---|---|
| First post | 2013-07-21 22:45 +0200 |
| Last post | 2013-07-24 03:07 -0500 |
| Articles | 20 on this page of 41 — 13 participants |
Back to article view | Back to comp.lang.forth
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
Page 1 of 3 [1] 2 3 Next page →
| From | Luca Saiu <positron@gnu.org> |
|---|---|
| Date | 2013-07-21 22:45 +0200 |
| Subject | Happy pi approximation day |
| Message-ID | <kshgui$bf4$3@dont-email.me> |
Happy pi approximation day, Forthers.
s" random.fs" included
10000000 constant sampleno
10000 constant n
: square
dup * ;
n square constant nsquare
: coordinate
n random ;
: below ( x y -- b )
square swap square + nsquare ( y²+x² n² ) < ;
: 1sample ( u -- v )
coordinate coordinate below if 1+ endif ;
: countbelow ( u -- v )
0 swap 0 u+do 1sample loop ;
: go ( -- denominator numerator )
sampleno dup countbelow 4 * ;
go . . cr bye
When explaining this, I've seized the occasion to write a little
tutorial for non-Forthers on my blog, at
http://ageinghacker.net/blog/posts/13 . Of course I welcome comments
from you experts.
Regards,
--
Luca Saiu
Home page: http://ageinghacker.net
GNU epsilon: http://www.gnu.org/software/epsilon
Marionnet: http://marionnet.org
[toc] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2013-07-22 01:24 +0200 |
| Message-ID | <1brmivvrlost0.d4q1mm82twi4$.dlg@40tude.net> |
| In reply to | #24650 |
Op Sun, 21 Jul 2013 22:45:22 +0200 schreef Luca Saiu: > Happy pi approximation day, Forthers. Still 13 3/4 time zones to go ;-) -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2013-07-22 01:27 +0200 |
| Message-ID | <2xdapnhz40zl$.nwcw9uulubrv.dlg@40tude.net> |
| In reply to | #24653 |
Op Mon, 22 Jul 2013 01:24:22 +0200 schreef Coos Haak: > Op Sun, 21 Jul 2013 22:45:22 +0200 schreef Luca Saiu: > >> Happy pi approximation day, Forthers. > Still 13 3/4 time zones to go ;-) Minus two, sorry. -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markrobertwills@yahoo.co.uk> |
|---|---|
| Date | 2013-07-22 01:14 -0700 |
| Message-ID | <8157678c-4b68-4b8a-8bfc-8d192685d88a@googlegroups.com> |
| In reply to | #24650 |
What's u+do ?
[toc] | [prev] | [next] | [standalone]
| From | Luca Saiu <positron@gnu.org> |
|---|---|
| Date | 2013-07-22 11:53 +0200 |
| Message-ID | <ksiv48$2it$1@dont-email.me> |
| In reply to | #24659 |
On 2013-07-22 at 10:14, Mark Wills wrote: > What's u+do ? It's a GForth word; a safer do for unsigned numbers, which doesn't enter the loop if the initial index is greater than the limit. do would have worked just as well here. I also used the nonstandard endif, just to avoid explaining "then" to beginners in my post; and I don't think s" random.fs" included works everywhere either. I see that the for loop isn't standard either, but that would have been the best choice in my case. This is a little frustrating. What do you people do to iterate n times? n 0 do ... loop ? -- Luca Saiu Home page: http://ageinghacker.net GNU epsilon: http://www.gnu.org/software/epsilon Marionnet: http://marionnet.org
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2013-07-22 15:46 +0000 |
| Message-ID | <2013Jul22.174620@mips.complang.tuwien.ac.at> |
| In reply to | #24659 |
Mark Wills <markrobertwills@yahoo.co.uk> writes:
>What's u+do ?
?DO done right, for unsigned parameters.
From
<http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Counted-Loops.html>:
|If start is greater than limit, a ?DO loop is entered (and LOOP
|iterates) until they become equal by wrap-around arithmetic. This
|behaviour is usually not what you want. Therefore, Gforth offers +DO
|and U+DO (as replacements for ?DO), which do not enter the loop if
|start is greater than limit; +DO is for signed loop parameters, U+DO
|for unsigned loop parameters.
- 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/
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2013-07-22 19:18 +0000 |
| Message-ID | <51ed8579$0$26873$e4fe514c@dreader37.news.xs4all.nl> |
| In reply to | #24688 |
In article <2013Jul22.174620@mips.complang.tuwien.ac.at>, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >Mark Wills <markrobertwills@yahoo.co.uk> writes: >>What's u+do ? > >?DO done right, for unsigned parameters. > >From ><http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Counted-Loops.html>: > >|If start is greater than limit, a ?DO loop is entered (and LOOP >|iterates) until they become equal by wrap-around arithmetic. This >|behaviour is usually not what you want. Therefore, Gforth offers +DO >|and U+DO (as replacements for ?DO), which do not enter the loop if >|start is greater than limit; +DO is for signed loop parameters, U+DO >|for unsigned loop parameters. So +DO is a better alternative for FOR NEXT. It has the specification I had in mind for an (uncompatible) ?DO. I hope +DO catches on fast and that nobody will use the name differently. Then the looping for yourforth could become I +DO LOOP > >- anton Groetjes Albert -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2013-07-22 21:17 +0100 |
| Message-ID | <ksk3kk$ji2$1@dont-email.me> |
| In reply to | #24698 |
On 22/07/2013 20:18, Albert van der Horst wrote: > In article <2013Jul22.174620@mips.complang.tuwien.ac.at>, > Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >> Mark Wills <markrobertwills@yahoo.co.uk> writes: >>> What's u+do ? >> >> ?DO done right, for unsigned parameters. >> >> From >> <http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Counted-Loops.html>: >> >> |If start is greater than limit, a ?DO loop is entered (and LOOP >> |iterates) until they become equal by wrap-around arithmetic. This >> |behaviour is usually not what you want. Therefore, Gforth offers +DO >> |and U+DO (as replacements for ?DO), which do not enter the loop if >> |start is greater than limit; +DO is for signed loop parameters, U+DO >> |for unsigned loop parameters. > > So +DO is a better alternative for FOR NEXT. It has the specification > I had in mind for an (uncompatible) ?DO. I hope +DO catches > on fast The name +DO doesn't imply to me that the loop is only entered if start < limit so I don't think it's a very good name at all and I hope it doesn't catch on. and that nobody will use the name differently. > Then the looping for yourforth could become > I +DO LOOP > I fail to see why yourforth shouldn't include the standard DO ... LOOP. Certainly it is complicated but it is commonly used, even by beginners. Do you think it too difficult for them to understand - if so they're unlikely to stick with FORTH. Implementing alternatives such as +DO will lead to confusion or frustration when a newbie realises that not all systems provide it. If you're going to make yourforth compliant with the ANS standard do so, don't have an "(uncompatible) ?DO" or make anything non-compliant or omit anything that is in common use. -- Gerry
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-07-22 11:25 -1000 |
| Message-ID | <3e-dneCnz7WpPnDMnZ2dnUVZ_tSdnZ2d@supernews.com> |
| In reply to | #24703 |
On 7/22/13 10:17 AM, Gerry Jackson wrote: > On 22/07/2013 20:18, Albert van der Horst wrote: >> In article <2013Jul22.174620@mips.complang.tuwien.ac.at>, >> Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >>> Mark Wills <markrobertwills@yahoo.co.uk> writes: >>>> What's u+do ? >>> >>> ?DO done right, for unsigned parameters. >>> >>> From >>> <http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Counted-Loops.html>: >>> >>> >>> |If start is greater than limit, a ?DO loop is entered (and LOOP >>> |iterates) until they become equal by wrap-around arithmetic. This >>> |behaviour is usually not what you want. Therefore, Gforth offers +DO >>> |and U+DO (as replacements for ?DO), which do not enter the loop if >>> |start is greater than limit; +DO is for signed loop parameters, U+DO >>> |for unsigned loop parameters. >> >> So +DO is a better alternative for FOR NEXT. It has the specification >> I had in mind for an (uncompatible) ?DO. I hope +DO catches >> on fast > > The name +DO doesn't imply to me that the loop is only entered if start > < limit so I don't think it's a very good name at all and I hope it > doesn't catch on. > > and that nobody will use the name differently. >> Then the looping for yourforth could become >> I +DO LOOP >> > > I fail to see why yourforth shouldn't include the standard DO ... LOOP. > Certainly it is complicated but it is commonly used, even by beginners. > Do you think it too difficult for them to understand - if so they're > unlikely to stick with FORTH. Implementing alternatives such as +DO will > lead to confusion or frustration when a newbie realises that not all > systems provide it. If you're going to make yourforth compliant with the > ANS standard do so, don't have an "(uncompatible) ?DO" or make anything > non-compliant or omit anything that is in common use. > I think DO ... LOOP is harder for implementers than users (especially +LOOP). I've never seen a beginner have trouble with either one. The both are pretty intuitive. If someone is unclear about, for example, how +LOOP is going to act with negative increments, it's easy enough to type in a test definition and try it. Much quicker than consulting a book! Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2013-07-23 12:42 +0000 |
| Subject | counted loops (was: Happy pi approximation day) |
| Message-ID | <2013Jul23.144213@mips.complang.tuwien.ac.at> |
| In reply to | #24705 |
"Elizabeth D. Rather" <erather@forth.com> writes:
>I think DO ... LOOP is harder for implementers than users (especially
>+LOOP). I've never seen a beginner have trouble with either one. The
>both are pretty intuitive. If someone is unclear about, for example, how
>+LOOP is going to act with negative increments, it's easy enough to type
>in a test definition and try it. Much quicker than consulting a book!
I don't think that the behaviour of
?DO ... -5 +LOOP
for various parameter pairs is intuitive at all, especially if you
know how
?DO ... 5 +LOOP
behaves. 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 any
case, choosing unintuitive features over more intuitive ones is bad
design.
While I am at it:
-DO ... 5 -LOOP
is an improvement over
?DO ... -5 +LOOP
and pretty intuitive because it behaves symmetrical to
+DO ... 5 +LOOP
but is inconvenient in a common use case:
When I do
x y u+do ... 1 cells +loop
and I want to walk through the data structure in revers direction,
with -DO ... -LOOP I have to write it as follows:
y cell+ x cell+ u-do ... 1 cells -loop
Given that this usage is relatively common, I would like a less
cumbersome way to write it down (with the increment only occuring
once). One difficulty here is that with the -DO ... -LOOP syntax,
there is no way to know where the parameter of the -LOOP begins, so
there is no way to decrement it before entering the rest of the first
iteration. One would need a syntax like
y x <DO 1 cells U-DO> ... -LOOP
y x U-DO ... <LOOP 1 cells -LOOP>
y x 1 cells U--DO ... --LOOP
or somesuch (feel free to think of better names).
- 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/
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-07-23 07:24 -1000 |
| Subject | Re: counted loops |
| Message-ID | <joSdndjkE9eqIXPMnZ2dnUVZ_o-dnZ2d@supernews.com> |
| In reply to | #24734 |
On 7/23/13 2:42 AM, Anton Ertl wrote: > "Elizabeth D. Rather" <erather@forth.com> writes: >> I think DO ... LOOP is harder for implementers than users (especially >> +LOOP). I've never seen a beginner have trouble with either one. The >> both are pretty intuitive. If someone is unclear about, for example, how >> +LOOP is going to act with negative increments, it's easy enough to type >> in a test definition and try it. Much quicker than consulting a book! > > I don't think that the behaviour of > > ?DO ... -5 +LOOP > > for various parameter pairs is intuitive at all, especially if you > know how > > ?DO ... 5 +LOOP > > behaves. 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. If I'm sitting at my computer I can type in: : test ( h l -- ) ?DO I . -5 +LOOP ; ...in about 5 seconds. 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. Books are great for full explanations of why things work the way they do, but simply exploring is the best way to answer questions like this. Having found out what is going on, if you're curious as to why, you can research further. Or not. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2013-07-23 17:33 +0000 |
| Subject | Re: counted loops |
| Message-ID | <2013Jul23.193330@mips.complang.tuwien.ac.at> |
| In reply to | #24739 |
"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/
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-07-23 08:06 -1000 |
| Subject | Re: counted loops |
| Message-ID | <asudncawHOK8W3PMnZ2dnUVZ_qidnZ2d@supernews.com> |
| In reply to | #24741 |
On 7/23/13 7:33 AM, Anton Ertl wrote: > "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 you're arguing that the spec is inauspicious, I won't disagree. I voted against it. >> 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. No, the point is that test is now a word to which I can feed parameters and see exactly what's going on. >> 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. My point is that it doesn't take a book to figure this out. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2013-07-23 19:47 +0000 |
| Subject | Re: counted loops |
| Message-ID | <51eedde9$0$595$e4fe514c@dreader34.news.xs4all.nl> |
| In reply to | #24742 |
In article <asudncawHOK8W3PMnZ2dnUVZ_qidnZ2d@supernews.com>, Elizabeth D. Rather <erather@forth.com> wrote: >On 7/23/13 7:33 AM, Anton Ertl wrote: >> "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 you're arguing that the spec is inauspicious, I won't disagree. I >voted against it. > >>> 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. > >No, the point is that test is now a word to which I can feed parameters >and see exactly what's going on. ... see exactly what's going on ... Exactly what is going on, on your computer. Without consulting the documentation you don;t know whether this is unambiguous condition or an implementation defined situation. <SNIP> >My point is that it doesn't take a book to figure this out. To an extent. > >Cheers, >Elizabeth -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-07-23 10:02 -1000 |
| Subject | Re: counted loops |
| Message-ID | <fuWdnR4PepjBfHPMnZ2dnUVZ_j2dnZ2d@supernews.com> |
| In reply to | #24745 |
On 7/23/13 9:47 AM, Albert van der Horst wrote: > In article <asudncawHOK8W3PMnZ2dnUVZ_qidnZ2d@supernews.com>, > Elizabeth D. Rather <erather@forth.com> wrote: ... >>>> 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. >> >> No, the point is that test is now a word to which I can feed parameters >> and see exactly what's going on. > > ... see exactly what's going on ... > Exactly what is going on, on your computer. Without consulting the > documentation you don;t know whether this is unambiguous condition > or an implementation defined situation. Isn't what's going on on my computer the most important thing to know? If you're an implementer, the Hays suite should tell you pretty quickly if that's correct. I suppose that, having spent many, many hours writing books and other docs I shouldn't be taking the side of "type and try" learning, but I think there's a place for both. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2013-07-23 14:58 -0500 |
| Subject | Re: counted loops |
| Message-ID | <dbydnX3tV77QfXPMnZ2dnUVZ_jOdnZ2d@supernews.com> |
| In reply to | #24742 |
Elizabeth D. Rather <erather@forth.com> wrote: > On 7/23/13 7:33 AM, Anton Ertl wrote: >> "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 you're arguing that the spec is inauspicious, I won't disagree. I > voted against it. The spec for DO ... +LOOP. you mean? I'm really interested to hear that; I never knew. It's the thing about ANS Forth that I've always hated. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-07-23 10:14 -1000 |
| Subject | Re: counted loops |
| Message-ID | <a_idnRqnA8qgeXPMnZ2dnUVZ_q-dnZ2d@supernews.com> |
| In reply to | #24746 |
On 7/23/13 9:58 AM, Andrew Haley wrote: > Elizabeth D. Rather <erather@forth.com> wrote: >> On 7/23/13 7:33 AM, Anton Ertl wrote: >>> "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 you're arguing that the spec is inauspicious, I won't disagree. I >> voted against it. > > The spec for DO ... +LOOP. you mean? I'm really interested to hear that; > I never knew. It's the thing about ANS Forth that I've always hated. It was a hotly contested issue. Theoretical purists argued for the spec that passed. The more pragmatic amongst us disagreed. But, really, in applications I haven't encountered a situation in which it mattered. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2013-07-24 08:13 +0000 |
| Subject | Re: counted loops |
| Message-ID | <2013Jul24.101323@mips.complang.tuwien.ac.at> |
| In reply to | #24742 |
"Elizabeth D. Rather" <erather@forth.com> writes:
>On 7/23/13 7:33 AM, Anton Ertl wrote:
>> "Elizabeth D. Rather" <erather@forth.com> writes:
>>> 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.
>
>No, the point is that test is now a word to which I can feed parameters
>and see exactly what's going on.
And that takes additional time. And will the user think of all the
test cases that show problematic behaviour? And all of that in less
than 25s? Probably not.
- 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/
[toc] | [prev] | [next] | [standalone]
| From | Elizabeth D Rather <erather@forth.com> |
|---|---|
| Date | 2013-07-23 22:42 -1000 |
| Subject | Re: counted loops |
| Message-ID | <dr-dnRdQyc3HDnLMnZ2dnUVZ_oydnZ2d@supernews.com> |
| In reply to | #24758 |
On 7/23/2013 10:13 PM, Anton Ertl wrote: > "Elizabeth D. Rather" <erather@forth.com> writes: >> On 7/23/13 7:33 AM, Anton Ertl wrote: >>> "Elizabeth D. Rather" <erather@forth.com> writes: >>>> 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. >> >> No, the point is that test is now a word to which I can feed parameters >> and see exactly what's going on. > > And that takes additional time. And will the user think of all the > test cases that show problematic behaviour? And all of that in less > than 25s? Probably not. It's just a matter of personal testing style. Where I'm coming from is testing a word in an application setting. You are getting an unexpected result. You make a few simple tests using data that is within the range you're interested in to see exactly how +LOOP is working. Cheers, Elizabet -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | stephenXXX@mpeforth.com (Stephen Pelc) |
|---|---|
| Date | 2013-07-24 09:55 +0000 |
| Subject | Re: counted loops |
| Message-ID | <51efa09c.1149320471@news.demon.co.uk> |
| In reply to | #24741 |
On Tue, 23 Jul 2013 17:33:30 GMT, anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: >| * 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. Nice compact description of the problem. The Forth-83 LOOP was IMHO a mistake that should be rectified in the long term. Trying to explain the current LOOP to beginners is unpleasant. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.forth
csiph-web