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


Groups > comp.lang.forth > #5198 > unrolled thread

A Minimal Extended Control Wordset

Started byJennyB <jennybrien@googlemail.com>
First post2011-08-24 07:01 -0700
Last post2011-09-01 10:33 -0700
Articles 20 on this page of 117 — 15 participants

Back to article view | Back to comp.lang.forth


Contents

  A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:01 -0700
    Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:50 -0700
      Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-08-24 08:04 -0700
        Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 08:59 -0700
          Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-08-24 20:00 +0200
            Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 14:03 -0700
              Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-08-26 20:36 +0200
      Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:54 -0700
      Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-12 09:43 -0700
    Re: A Minimal Extended Control Wordset "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-08-24 18:52 -0400
      Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-25 06:52 -0700
        Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-26 12:23 +1000
          Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 21:03 -0700
            Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-26 20:02 +1000
              Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-26 04:36 -0700
                Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 10:42 -0700
                  Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-27 14:45 -0700
                    Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-27 17:13 -0700
              Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 10:16 -0700
    Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 09:46 -0700
      Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 20:54 -0700
        Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-26 10:24 -0700
          Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 11:04 -0700
            Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-31 04:14 -0700
              Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-31 15:25 -0700
                Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-09-01 04:00 -0700
                  Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 12:47 -0700
          Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-27 13:18 +1000
            Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-27 04:41 -0700
              Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-28 13:28 +1000
                Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-27 18:32 -1000
                  Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-29 12:32 +1000
                Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-28 09:22 -0700
                  Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-29 12:30 +1000
                    Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-28 18:17 -1000
                      return address manipulation (was: A Minimal Extended Control Wordset) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-29 09:14 +0000
                        Re: return address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-29 05:53 -0500
                          Re: return address manipulation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-29 11:45 +0000
                      Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-30 14:08 +1000
                        Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-29 18:28 -1000
                          Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-31 13:52 +1000
                            Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-30 21:42 -1000
                              Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-08-31 00:47 -0700
                                Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-30 21:55 -1000
                                  Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-01 00:44 -0700
                                    Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 03:37 -0500
                                      Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-01 02:19 -0700
                                        Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 05:05 -0500
                                          min-max-sum (was: A Minimal Extended Control Wordset) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-01 14:32 +0000
                                            Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 10:43 -0500
                                              Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-01 15:59 +0000
                                                Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-01 13:13 -0700
                                                Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 04:12 -0500
                                                  Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 04:31 -0500
                                                    Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-02 10:41 +0000
                                                      Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 06:31 -0500
                                                        Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-04 13:18 +0000
                                                          Re: min-max-sum mhx@iae.nl (Marcel Hendrix) - 2011-09-04 22:42 +0200
                                                            Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-05 08:16 +0000
                                                          Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-05 02:58 -0500
                                                      Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-02 08:43 -0700
                                                      Re: min-max-sum coos haak <chforth@hccnet.nl> - 2011-09-02 20:35 +0200
                                                      Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-03 11:48 -0700
                                                        Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-04 18:31 -0700
                                                  Re: min-max-sum Alex McDonald <blog@rivadpm.com> - 2011-09-02 05:37 -0700
                                                Re: min-max-sum mhx@iae.nl (Marcel Hendrix) - 2011-09-03 12:06 +0200
                                          Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-04 22:07 -0700
                                            Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-04 22:56 -0700
                                              Re: A Minimal Extended Control Wordset C G Montgomery <cgm@physics.utoledo.edu> - 2011-09-05 17:44 -0400
                                              Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-05 18:10 -0700
                                        Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 11:01 -0700
                                    Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-01 09:17 -1000
                              Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-01 13:39 +1000
                                Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:21 -0700
                                  Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-05 12:24 +1000
                                    Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-04 21:11 -0700
                                      Re: A Minimal Extended Control Wordset Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-09-06 18:13 +0000
                                        Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-06 12:15 -0700
                                          Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-06 09:53 -1000
                                            Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-06 14:18 -0700
                                            Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-06 17:32 -0700
                                            Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-07 19:43 +1000
                                              Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-07 06:02 -0500
                                                Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-07 05:41 -0700
                                              Re: A Minimal Extended Control Wordset anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-07 16:00 +0000
                                                Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-09 08:52 +1000
                                                  Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 16:08 -0700
                                                    Re: A Minimal Extended Control Wordset George Hubert <georgeahubert@yahoo.co.uk> - 2011-09-09 04:12 -0700
                                                      Re: A Minimal Extended Control Wordset Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-09-10 09:09 +0000
                                                    Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-11 18:29 +1000
                                                      Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-11 09:04 -0700
                                                        Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-15 19:25 +1000
                                                          Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-15 03:30 -0700
                                                            Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-18 15:43 +1000
                                                              Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-17 20:42 -1000
                                                                Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-19 05:14 +1000
                                                                  Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-18 19:31 -0700
                                                              Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-18 01:49 -0500
                                                  Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-08 14:56 -1000
                                                    Re: A Minimal Extended Control Wordset anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-09 08:20 +0000
                                                      Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-11 16:22 +1000
                                                        Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-11 03:06 -0700
                                                  Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-08 19:29 -0700
                                            Re: A Minimal Extended Control Wordset Brad <hwfwguy@gmail.com> - 2011-09-08 08:58 -0700
                                              Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 10:00 -0700
                                                Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-09-08 22:00 +0200
                                                  Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 16:02 -0700
                                              Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-09 09:16 +1000
                                                Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-08 15:04 -1000
                                                  Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-09 04:13 -0500
                      Re: A Minimal Extended Control Wordset Brad <hwfwguy@gmail.com> - 2011-08-31 09:20 -0700
                    Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-28 21:31 -0700
                      Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-31 13:53 +1000
                        Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-31 04:11 -0700
                          Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-01 14:47 +1000
                            Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:32 -0700
                            Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:33 -0700

Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6  Next page →


#5488 — Re: min-max-sum

FromBruceMcF <agila61@netscape.net>
Date2011-09-02 08:43 -0700
SubjectRe: min-max-sum
Message-ID<7868461c-8a0a-413e-8067-58eeaee4a17d@hb5g2000vbb.googlegroups.com>
In reply to#5475
On Sep 2, 6:41 am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:
> Yes, ROLL with a dynamically computed index would be such a use, but I
> have never seen that.  However, GET-CONTEXT SET-CONTEXT use the stack
> as array and have been standardized.  N>R NR> also do that, and IIRC
> you are in favour of them.

But GET-CONTEXT SET-CONTEXT doesn't really treat the stack as stack of
arrays ~ the common uses I've seen of it is to get a context to
restore it later, which is treating the stack as a LIFO stack of
variably sized items, to add a wordlist to the top, bumping up the
count, which is manipulating the variably sized item on the stack as a
substack, and discarding the top wordlist, dropping the count, which
is also manipulating the variably sized item on the stack as a
substack, or in other word is treating the stack as a stack of stacks.

Even public/private systems that reach two deep into the context are
treating it like a stack of stacks rather than like a stack of arrays.

And NR> N>R is treated the stack as a stack of variably sized items.
While it *could* be used to work with the stack as a stack of arrays,
its *rationale* focuses on the GET-CONTEXT SET-CONTEXT, which is using
the stack as a stack of stacks.

[toc] | [prev] | [next] | [standalone]


#5493 — Re: min-max-sum

Fromcoos haak <chforth@hccnet.nl>
Date2011-09-02 20:35 +0200
SubjectRe: min-max-sum
Message-ID<1vhci9xjezoip$.j490qxqa0qd4$.dlg@40tude.net>
In reply to#5475
Op Fri, 02 Sep 2011 10:41:04 GMT schreef Anton Ertl:

> Yes, ROLL with a dynamically computed index would be such a use, but I
> have never seen that.  However, GET-CONTEXT SET-CONTEXT use the stack
> as array and have been standardized.  N>R NR> also do that, and IIRC
> you are in favour of them.

I would expect GET-CONTEXT deal with one variable, CONTEXT of very old 
Forths. I think GET-ORDER and SET-ORDER is meant.
My € 0,02.

-- 
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html 

[toc] | [prev] | [next] | [standalone]


#5516 — Re: min-max-sum

FromBruceMcF <agila61@netscape.net>
Date2011-09-03 11:48 -0700
SubjectRe: min-max-sum
Message-ID<33900ca2-a53a-4d32-86d4-30559f68db4a@en1g2000vbb.googlegroups.com>
In reply to#5475
On Sep 2, 6:41 am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:
> Andrew Haley <andre...@littlepinkcloud.invalid> writes:
> >To expand on this: you're returning a tuple of N items.  Rather than a
> >named struct you're placing these in an array which is not in memory
> >but on the stack.
>
> Returning multiple values on the stack is one of the features of
> Forth.

But min-max-sum is not a coherent operation.

The min-max part is a coherent operation ~ and indeed updating a range
based on an element may well be a useful factor:

\ update-range ( min max n -- min' max' )
\ min' is min(min,n) and max' is max(max,n)

Which might be variously

: update-range ( min max n -- min' max' )
   ROT OVER MIN -ROT MAX ;

or

: update-range ( min max n -- min' max' )
   TUCK MAX >R MIN R> ;

... or for natural numbers ...

: update-urange ( umin umax u -- umin' umax' )
   TUCK UMAX >R UMIN R> ;

[toc] | [prev] | [next] | [standalone]


#5536 — Re: min-max-sum

FromBruceMcF <agila61@netscape.net>
Date2011-09-04 18:31 -0700
SubjectRe: min-max-sum
Message-ID<9fb2a305-0deb-41c1-bab7-30b5c40f85ca@p10g2000yqi.googlegroups.com>
In reply to#5516
On Sep 3, 2:48 pm, BruceMcF <agil...@netscape.net> wrote:
> The min-max part is a coherent operation ~ and indeed updating a range
> based on an element may well be a useful factor:
>
> \ update-range ( min max n -- min' max' )
> \ min' is min(min,n) and max' is max(max,n)
>
> Which might be variously
>
> : update-range ( min max n -- min' max' )
>    ROT OVER MIN -ROT MAX ;
>
> or
>
> : update-range ( min max n -- min' max' )
>    TUCK MAX >R MIN R> ;
>
> ... or for natural numbers ...
>
> : update-urange ( umin umax u -- umin' umax' )
>    TUCK UMAX >R UMIN R> ;

Or

: update-range ( min max n -- min' max' }
   DUP 2OVER WITHIN 0= IF
      TUCK MAX >R MIN R>
   ELSE DROP
   THEN ;

[toc] | [prev] | [next] | [standalone]


#5479 — Re: min-max-sum

FromAlex McDonald <blog@rivadpm.com>
Date2011-09-02 05:37 -0700
SubjectRe: min-max-sum
Message-ID<ba44dc21-181b-41be-bb57-bb76723a6f79@br5g2000vbb.googlegroups.com>
In reply to#5472
On Sep 2, 10:12 am, Andrew Haley <andre...@littlepinkcloud.invalid>
wrote:
> Anton Ertl <an...@mips.complang.tuwien.ac.at> wrote:
> > Andrew Haley <andre...@littlepinkcloud.invalid> writes:
>
> >>You could instead shuffle n items to and from the return stack.  Like
> >>so:
>
> >>do ( nsum' nmax' nmin' )
> >> >r >r
> >> i @ + r>
> >> i @ max r>
> >> i @ min
> >>1 cells +loop ;
>
> > Even if it would work (which it wouldn't on many systems because DO
> > communicates with I through the return stack),
>
> Oops.
>
> > I think the rotating solution is clearer.  And it's straightforward
> > to extend to more than three items.  Yes, you have to use ROLL then,
> > but avoiding a clear solution to avoid ROLL is perverse: We normally
> > avoid ROLL because it is a symptom of having too many stack items.
>
> I avoid ROLL because it's a symptom of trying use the stack as an
> array, or in this case as a struct.
>
> Andrew.


I am not a big fan of ROT n ROLL. Although some of Elvis' early stuff
was good.

[toc] | [prev] | [next] | [standalone]


#5512 — Re: min-max-sum

Frommhx@iae.nl (Marcel Hendrix)
Date2011-09-03 12:06 +0200
SubjectRe: min-max-sum
Message-ID<03979100948436@frunobulax.edu>
In reply to#5445
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes Re: min-max-sum

> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
[..]
>>I'm not sure that shuffling things between stacks or shuffling the
>>data stack is necessarily fast.

> Sure, it's not necessarily fast, but it requires much less compiler
> smarts to avoid memory stores in the loop than your solution does.

> I tried it on VFX, and it produced a lot of memory accesses through
> ESP and EBP, so I guess this code exceeded the capacity of its
> register allocator.  Maybe iForth does better.

No, because iForth is very / too careful when writing back data 
to memory is implied.

>>However, obsessing about this kind of thing
>>isn't going to make for the most maintainable Forth code.

> As mentioned, for the most maintainable code I would compute each
> value in a separate loop.

I tried a few variants below. 

FORTH> test
\ 100 times sum-min-max1 [5,000,000] : 12499997500000 0 4999999   4.207 seconds elapsed.
\ 100 times sum-min-max2 [5,000,000] : 12499997500000 0 4999999   2.988 seconds elapsed.
\ 100 times sum-min-max3 [5,000,000] : 12499997500000 0 4999999   2.428 seconds elapsed.
\ 100 times sum-min-max4 [5,000,000] : 12499997500000 0 4999999   3.641 seconds elapsed.
\ 100 times sum-min-max5 [5,000,000] : 12499997500000 0 4999999   4.689 seconds elapsed.
\ 100 times sum-min-max6 [5,000,000] : 12499997500000 0 4999999   1.356 seconds elapsed. ok

The spread in run times is about a factor 3.5 (1.356 versus 4.689 seconds). 

Second fastest and easiest to read solution is sum-min-max3. This word 
separates the address and computational operations by using the FPU 
stack explicitly. Unfortunately, it uses the iForth extension FEXCHANGE 
(swap ftos with n-th value on FPU stack). 

Note that all the FP solutions are quite a bit faster than the integer
ones.

The parallel solution sum-min-max6 performs best. It is not as fast as 
hoped, i.e. it is only about 2.7 times faster than sum-min-max4, not 
three times, and there is quite a bit of cumbersome setup to prevent 
memory congestion. As yet iForth has no extensions to pass parameters
to parallel processes.

-marcel

-- --------------------------------------------
ANEW -mappings

NEEDS -threads 

: make-data ( u -- ) DUP , 0 ?DO i , LOOP ; 

CREATE testdata  #5000000 make-data
	
: sum-min-max1 ( addr ucells -- nsum nmax nmin )
	2>r 0 maxint minint 2r> 
	cells bounds 2dup u> 
	   IF 
		        DO ( nsum' nmax' nmin' )
				rot i @ +
				rot i @ min
				rot i @ max
		cell +LOOP 
	 ELSE	2drop
	ENDIF ;

: sum-min-max2 ( addr ucells -- nsum nmax nmin )
	0 S>F maxint S>F minint S>F
	0 ?DO
		FROT  @+ dup S>F F+    -FROT
		FSWAP    dup S>F FMIN  FSWAP
			     S>F FMAX
	 LOOP	drop 
	FROT F>S  FSWAP F>S  F>S ;

: sum-min-max3 ( addr ucells -- nsum nmax nmin )
	0 S>F maxint S>F minint S>F
	0 ?DO
		@+ S>F
		FDUP 4 FEXCHANGE F+    3 FEXCHANGE
		FDUP 3 FEXCHANGE FMIN  2 FEXCHANGE
		                 FMAX
	 LOOP	drop 
	FROT F>S  FSWAP F>S  F>S ;

: sum-min-max4 ( addr ucells -- nsum nmax nmin )
	2>r     0e  2r@ 0 ?DO  @+ S>F F+    LOOP drop  F>S 
	maxint S>F  2r@ 0 ?DO  @+ S>F FMIN  LOOP drop  F>S 
	minint S>F  2r> 0 ?DO  @+ S>F FMAX  LOOP drop  F>S ;

: sum-min-max5 ( addr ucells -- nsum nmax nmin )
	2>r  0 2r@  0 ?DO  @+ rot +   swap  LOOP drop  
	maxint 2r@  0 ?DO  @+ rot min swap  LOOP drop 
	minint 2r>  0 ?DO  @+ rot max swap  LOOP drop ;

0 value sz1 0 value data1
0 value sz2 0 value data2 
0 value sz3 0 value data3

ALIGN32 0 value =sum6
ALIGN32 0 value =min6
ALIGN32 0 value =max6

: sum6 ( -- ) 0e         data1 sz1 0 ?DO  @+ S>F F+    LOOP drop F>S TO =sum6 ;
: min6 ( -- ) maxint S>F data2 sz2 0 ?DO  @+ S>F FMIN  LOOP drop F>S TO =min6 ;
: max6 ( -- ) minint S>F data3 sz3 0 ?DO  @+ S>F FMAX  LOOP drop F>S TO =max6 ;

: sum-min-max6 ( -- nsum nmax nmin )
	PAR 
	   STARTP  sum6  ENDP
	   STARTP  min6  ENDP
	   STARTP  max6  ENDP
	ENDPAR
	=sum6 =min6 =max6 ;

: test ( -- )
	CR ." \ 100 times sum-min-max1 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop testdata @+ sum-min-max1  LOOP rot . swap . . 2 spaces .ELAPSED
	CR ." \ 100 times sum-min-max2 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop testdata @+ sum-min-max2  LOOP rot . swap . . 2 spaces .ELAPSED 
	CR ." \ 100 times sum-min-max3 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop testdata @+ sum-min-max3  LOOP rot . swap . . 2 spaces .ELAPSED
	CR ." \ 100 times sum-min-max4 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop testdata @+ sum-min-max4  LOOP rot . swap . . 2 spaces .ELAPSED
	CR ." \ 100 times sum-min-max5 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop testdata @+ sum-min-max5  LOOP rot . swap . . 2 spaces .ELAPSED 

	testdata @+ dup TO sz1 dup TO sz2 TO sz3 
	sz1 cells allocate throw TO data1  dup data1 sz1 cells move
	sz2 cells allocate throw TO data2  dup data2 sz2 cells move
	sz3 cells allocate throw TO data3      data3 sz3 cells move
	CR ." \ 100 times sum-min-max6 [5,000,000] : " TIMER-RESET  0 0 0  #100 0 DO  3drop             sum-min-max6  LOOP rot . swap . . 2 spaces .ELAPSED 
	data1 free throw
	data2 free throw  
	data3 free throw ;

\ FORTH> test
\ 100 times sum-min-max1 [5,000,000] : 12499997500000 0 4999999   4.207 seconds elapsed.
\ 100 times sum-min-max2 [5,000,000] : 12499997500000 0 4999999   2.988 seconds elapsed.
\ 100 times sum-min-max3 [5,000,000] : 12499997500000 0 4999999   2.428 seconds elapsed.
\ 100 times sum-min-max4 [5,000,000] : 12499997500000 0 4999999   3.641 seconds elapsed.
\ 100 times sum-min-max5 [5,000,000] : 12499997500000 0 4999999   4.689 seconds elapsed.
\ 100 times sum-min-max6 [5,000,000] : 12499997500000 0 4999999   1.356 seconds elapsed. ok

DOC
(*
FORTH> ' sum-min-max1 idis
$01247D80  : [trashed]
$01247D8A  pop           rbx
$01247D8B  pop           rdi
$01247D8C  lea           rax, [rdi rbx*8] qword
$01247D90  cmp           rdi, rax
$01247D93  push          0 b#
$01247D95  mov           r8, $80000000:00000000 q#
$01247D9F  push          r8
$01247DA1  mov           r8, $7FFFFFFF:FFFFFFFF q#
$01247DAB  push          r8
$01247DAD  push          rax
$01247DAE  mov           rcx, rdi
$01247DB1  mov           rbx, rcx
$01247DB4  jae           $01247E17 offset NEAR
$01247DBA  pop           rcx
$01247DBB  call          (DO) offset NEAR
$01247DC5  mov           rax, rax

$01247DC8  pop           rdi
$01247DC9  pop           rax
$01247DCA  mov           rdx, [rbp 0 +] qword
$01247DCE  add           rax, [rdx] qword
$01247DD1  mov           rdx, [rbp 0 +] qword
$01247DD5  push          rbx
$01247DD6  push          rax
$01247DD7  push          rdi
$01247DD8  push          [rdx] qword
$01247DDA  pop           rbx
$01247DDB  pop           rcx
$01247DDC  cmp           rbx, rcx
$01247DDF  cmovl         rbx, rcx
$01247DE3  pop           rdi
$01247DE4  pop           rax
$01247DE5  mov           rdx, [rbp 0 +] qword
$01247DE9  push          rdi
$01247DEA  push          rbx
$01247DEB  push          rax
$01247DEC  push          [rdx] qword
$01247DEE  pop           rbx
$01247DEF  pop           rcx
$01247DF0  cmp           rbx, rcx
$01247DF3  cmovg         rbx, rcx
$01247DF7  push          rbx
$01247DF8  mov           rbx, 8 d#
$01247DFF  add           [rbp 0 +] qword, rbx
$01247E03  add           [rbp 8 +] qword, rbx
$01247E07  pop           rbx
$01247E08  jno           $01247DC8 offset NEAR

$01247E0E  add           rbp, #24 b#
$01247E12  jmp           $01247E19 offset NEAR
$01247E17  pop           rdi
$01247E18  pop           rbx
$01247E19  push          rbx
$01247E1A  ;



FORTH> ' sum-min-max2 idis
$01311100  : [trashed]
$0131110A  fld           $011B9EF0 tbyte-offset
$01311110  fld           $011B9EE0 tbyte-offset
$01311116  fld           $011B9ED0 tbyte-offset
$0131111C  xor           rbx, rbx
$0131111F  pop           rcx
$01311120  call          (?DO) offset NEAR
$0131112A  nop
$0131112B  lea           rax, [rax 0 +] qword

$01311130  fxch          ST(1)
$01311132  fxch          ST(2)
$01311134  push          [rbx] qword
$01311136  fild          [rsp] qword
$01311139  add           rsp, 8 b#
$0131113D  faddp         ST(1), ST
$0131113F  fxch          ST(2)
$01311141  fxch          ST(1)
$01311143  fxch          ST(1)
$01311145  push          [rbx] qword
$01311147  fild          [rsp] qword
$0131114A  add           rsp, 8 b#
$0131114E  lea           rdi, [rbx 8 +] qword
$01311152  push          rdi
$01311153  push          [rbx] qword
$01311155  fxch          ST(1)
$01311157  fcomi         ST(1)
$01311159  fcmovnb       ST(1)
$0131115B  fstp          ST(1)
$0131115D  fxch          ST(1)
$0131115F  pop           rbx
$01311160  push          rbx
$01311161  fild          [rsp] qword
$01311164  add           rsp, 8 b#
$01311168  fxch          ST(1)
$0131116A  fcomi         ST(1)
$0131116C  fcmovb        ST(1)
$0131116E  fstp          ST(1)
$01311170  pop           rbx
$01311171  add           [rbp 0 +] qword, 1 b#
$01311176  add           [rbp 8 +] qword, 1 b#
$0131117B  jno           $01311130 offset NEAR

$01311181  add           rbp, #24 b#
$01311185  fxch          ST(1)
$01311187  fxch          ST(2)
$01311189  sub           rsp, 8 b#
$0131118D  fisttp        [rsp] qword
$01311190  pop           rbx
$01311191  fxch          ST(1)
$01311193  sub           rsp, 8 b#
$01311197  fisttp        [rsp] qword
$0131119A  pop           rdi
$0131119B  sub           rsp, 8 b#
$0131119F  fisttp        [rsp] qword
$013111A2  pop           rax
$013111A3  push          rbx
$013111A4  push          rdi
$013111A5  push          rax
$013111A6  ;


FORTH> ' sum-min-max3 idis

$01311200  : [trashed]
$0131120A  fld           $011B9F20 tbyte-offset
$01311210  fld           $011B9F10 tbyte-offset
$01311216  fld           $011B9F00 tbyte-offset
$0131121C  xor           rbx, rbx
$0131121F  pop           rcx
$01311220  call          (?DO) offset NEAR
$0131122A  nop
$0131122B  lea           rax, [rax 0 +] qword

$01311230  push          [rbx] qword
$01311232  fild          [rsp] qword
$01311235  add           rsp, 8 b#
$01311239  fld           ST(0)
$0131123B  lea           rbx, [rbx 8 +] qword
$0131123F  push          rbx
$01311240  fxch          ST(4)
$01311242  faddp         ST(1), ST
$01311244  fxch          ST(3)
$01311246  fld           ST(0)
$01311248  fxch          ST(3)
$0131124A  fxch          ST(1)
$0131124C  fcomi         ST(1)
$0131124E  fcmovnb       ST(1)
$01311250  fstp          ST(1)
$01311252  fxch          ST(2)
$01311254  fxch          ST(1)
$01311256  fcomi         ST(1)
$01311258  fcmovb        ST(1)
$0131125A  fstp          ST(1)
$0131125C  pop           rbx
$0131125D  add           [rbp 0 +] qword, 1 b#
$01311262  add           [rbp 8 +] qword, 1 b#
$01311267  jno           $01311230 offset NEAR

$0131126D  add           rbp, #24 b#
$01311271  fxch          ST(1)
$01311273  fxch          ST(2)
$01311275  sub           rsp, 8 b#
$01311279  fisttp        [rsp] qword
$0131127C  pop           rbx
$0131127D  fxch          ST(1)
$0131127F  sub           rsp, 8 b#
$01311283  fisttp        [rsp] qword
$01311286  pop           rdi
$01311287  sub           rsp, 8 b#
$0131128B  fisttp        [rsp] qword
$0131128E  pop           rax
$0131128F  push          rbx
$01311290  push          rdi
$01311291  push          rax
$01311292  ;



FORTH> ' sum-min-max4 idis

$01311300  : [trashed]
$0131130A  pop           rbx
$0131130B  pop           rdi
$0131130C  fld           $011B9F50 tbyte-offset
$01311312  lea           rbp, [rbp -8 +] qword
$01311316  mov           [rbp 0 +] qword, rdi
$0131131A  lea           rbp, [rbp -8 +] qword
$0131131E  mov           [rbp 0 +] qword, rbx
$01311322  push          rdi
$01311323  push          rbx
$01311324  xor           rbx, rbx
$01311327  pop           rcx
$01311328  call          (?DO) offset NEAR
$01311332  nop
$01311333  lea           rax, [rax 0 +] qword

$01311338  push          [rbx] qword
$0131133A  fild          [rsp] qword
$0131133D  add           rsp, 8 b#
$01311341  faddp         ST(1), ST
$01311343  lea           rbx, [rbx 8 +] qword
$01311347  add           [rbp 0 +] qword, 1 b#
$0131134C  add           [rbp 8 +] qword, 1 b#
$01311351  jno           $01311338 offset NEAR

$01311357  add           rbp, #24 b#
$0131135B  sub           rsp, 8 b#
$0131135F  fisttp        [rsp] qword
$01311362  pop           rbx
$01311363  fld           $011B9F40 tbyte-offset
$01311369  mov           rdi, [rbp 8 +] qword
$0131136D  mov           rax, [rbp 0 +] qword
$01311371  push          rbx
$01311372  push          rdi
$01311373  push          rax
$01311374  xor           rbx, rbx
$01311377  pop           rcx
$01311378  call          (?DO) offset NEAR
$01311382  nop
$01311383  lea           rax, [rax 0 +] qword

$01311388  push          [rbx] qword
$0131138A  fild          [rsp] qword
$0131138D  add           rsp, 8 b#
$01311391  lea           rbx, [rbx 8 +] qword
$01311395  push          rbx
$01311396  fxch          ST(1)
$01311398  fcomi         ST(1)
$0131139A  fcmovnb       ST(1)
$0131139C  fstp          ST(1)
$0131139E  pop           rbx
$0131139F  add           [rbp 0 +] qword, 1 b#
$013113A4  add           [rbp 8 +] qword, 1 b#
$013113A9  jno           $01311388 offset NEAR

$013113AF  add           rbp, #24 b#
$013113B3  sub           rsp, 8 b#
$013113B7  fisttp        [rsp] qword
$013113BA  pop           rbx
$013113BB  fld           $011B9F30 tbyte-offset
$013113C1  mov           rdi, [rbp 0 +] qword
$013113C5  lea           rbp, [rbp 8 +] qword
$013113C9  mov           rax, [rbp 0 +] qword
$013113CD  lea           rbp, [rbp 8 +] qword
$013113D1  push          rbx
$013113D2  push          rax
$013113D3  push          rdi
$013113D4  xor           rbx, rbx
$013113D7  pop           rcx
$013113D8  call          (?DO) offset NEAR
$013113E2  nop
$013113E3  lea           rax, [rax 0 +] qword

$013113E8  push          [rbx] qword
$013113EA  fild          [rsp] qword
$013113ED  add           rsp, 8 b#
$013113F1  lea           rbx, [rbx 8 +] qword
$013113F5  push          rbx
$013113F6  fxch          ST(1)
$013113F8  fcomi         ST(1)
$013113FA  fcmovb        ST(1)
$013113FC  fstp          ST(1)
$013113FE  pop           rbx
$013113FF  add           [rbp 0 +] qword, 1 b#
$01311404  add           [rbp 8 +] qword, 1 b#
$01311409  jno           $013113E8 offset NEAR

$0131140F  add           rbp, #24 b#
$01311413  sub           rsp, 8 b#
$01311417  fisttp        [rsp] qword
$0131141A  mov           rbx, [rsp] qword
$0131141E  ;


FORTH> ' sum-min-max5 idis

$01311480  : [trashed]
$0131148A  pop           rbx
$0131148B  pop           rdi
$0131148C  lea           rbp, [rbp -8 +] qword
$01311490  mov           [rbp 0 +] qword, rdi
$01311494  lea           rbp, [rbp -8 +] qword
$01311498  mov           [rbp 0 +] qword, rbx
$0131149C  push          0 b#
$0131149E  push          rdi
$0131149F  push          rbx
$013114A0  xor           rbx, rbx
$013114A3  pop           rcx
$013114A4  call          (?DO) offset NEAR
$013114AE  nop
$013114AF  nop

$013114B0  pop           rdi
$013114B1  add           rdi, [rbx] qword
$013114B4  push          rdi
$013114B5  lea           rbx, [rbx 8 +] qword
$013114B9  add           [rbp 0 +] qword, 1 b#
$013114BE  add           [rbp 8 +] qword, 1 b#
$013114C3  jno           $013114B0 offset NEAR

$013114C9  add           rbp, #24 b#
$013114CD  mov           rbx, [rbp 8 +] qword
$013114D1  mov           rdi, [rbp 0 +] qword
$013114D5  mov           r8, $7FFFFFFF:FFFFFFFF q#
$013114DF  push          r8
$013114E1  push          rbx
$013114E2  push          rdi
$013114E3  xor           rbx, rbx
$013114E6  pop           rcx
$013114E7  call          (?DO) offset NEAR
$013114F1  lea           rax, [rax 0 +] qword

$013114F8  pop           rdi
$013114F9  lea           rax, [rbx 8 +] qword
$013114FD  push          rax
$013114FE  push          [rbx] qword
$01311500  mov           rbx, rdi
$01311503  pop           rcx
$01311504  cmp           rbx, rcx
$01311507  cmovg         rbx, rcx
$0131150B  pop           rdi
$0131150C  mov           rcx, rbx
$0131150F  mov           rbx, rdi
$01311512  push          rcx
$01311513  add           [rbp 0 +] qword, 1 b#
$01311518  add           [rbp 8 +] qword, 1 b#
$0131151D  jno           $013114F8 offset NEAR

$01311523  add           rbp, #24 b#
$01311527  mov           rbx, [rbp 0 +] qword
$0131152B  lea           rbp, [rbp 8 +] qword
$0131152F  mov           rdi, [rbp 0 +] qword
$01311533  lea           rbp, [rbp 8 +] qword
$01311537  mov           r8, $80000000:00000000 q#
$01311541  push          r8
$01311543  push          rdi
$01311544  push          rbx
$01311545  xor           rbx, rbx
$01311548  pop           rcx
$01311549  call          (?DO) offset NEAR
$01311553  lea           rax, [rax 0 +] qword

$01311558  pop           rdi
$01311559  lea           rax, [rbx 8 +] qword
$0131155D  push          rax
$0131155E  push          [rbx] qword
$01311560  mov           rbx, rdi
$01311563  pop           rcx
$01311564  cmp           rbx, rcx
$01311567  cmovl         rbx, rcx
$0131156B  pop           rdi
$0131156C  mov           rcx, rbx
$0131156F  mov           rbx, rdi
$01311572  push          rcx
$01311573  add           [rbp 0 +] qword, 1 b#
$01311578  add           [rbp 8 +] qword, 1 b#
$0131157D  jno           $01311558 offset NEAR

$01311583  add           rbp, #24 b#
$01311587  ;

*)
ENDDOC

[toc] | [prev] | [next] | [standalone]


#5539

FromPaul Rubin <no.email@nospam.invalid>
Date2011-09-04 22:07 -0700
Message-ID<7xipp760ht.fsf@ruckus.brouhaha.com>
In reply to#5433
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> It didn't seem artificial to me, wanting to know the min, max, and
>> average (mean) of some data set. 
> You always want all three?  OK.

Seems natural enough to me.  Visit wunderground.com (weather forecast
site), type in the name of your town, and click the "today's almanac"
tab.  It will tell you among other things the highest, lowest, and
average temperatures reported for your town on [current day of year]
across the aggregate data set.  So there's min-max-sum in an everyday,
real-world setting.

> Certainly not!  Global variables are global, but these were local to
> the caller: the names are just offsets from a base.  

Oh I see, basically the caller allocates a return buffer and passes
it to the subr.  Sure, that's reasonable.

>> One of my attempts tried to factor something like the repeated "i @
>> over" into a separate word,
>
> Well, it could be reorganized at the expense of clarity, but I'm not
> sure why you'd want to do that. 

Just to eliminate redundancy (DRY).

> You could move the offsets into max! and min! :
>
> : >sum ( n a)   f_sum +! ;
> : >max ( n a)   f_max max! ;
> : >min ( n a)   f_min min! ;

This is the nicest looking one.

[toc] | [prev] | [next] | [standalone]


#5540

FromBruceMcF <agila61@netscape.net>
Date2011-09-04 22:56 -0700
Message-ID<2ff3eafa-0400-48ef-8f8e-4125de93ff88@l7g2000vbz.googlegroups.com>
In reply to#5539
On Sep 5, 1:07 am, Paul Rubin <no.em...@nospam.invalid> wrote:
> Seems natural enough to me.  Visit wunderground.com (weather forecast
> site), type in the name of your town, and click the "today's almanac"
> tab.  It will tell you among other things the highest, lowest, and
> average temperatures reported for your town on [current day of year]
> across the aggregate data set.

> So there's min-max-sum in an everyday, real-world setting.

Are you sure that they are performing the min-max and the sum on the
original data on the fly when requested? Or might they have min, max
and sum for the various days already recorded, updating each day's
data once per year as the new data comes in?

[toc] | [prev] | [next] | [standalone]


#5544

FromC G Montgomery <cgm@physics.utoledo.edu>
Date2011-09-05 17:44 -0400
Message-ID<j43fsu$369$1@dont-email.me>
In reply to#5540
BruceMcF agila61@netscape.net wrote:

> On Sep 5, 1:07 am, Paul Rubin <no.em...@nospam.invalid> wrote:
>> Seems natural enough to me.  Visit wunderground.com (weather forecast
>> site), type in the name of your town, and click the "today's almanac"
>> tab.  It will tell you among other things the highest, lowest, and
>> average temperatures reported for your town on [current day of year]
>> across the aggregate data set.
> 
>>So there's min-max-sum in an everyday, real-world setting.
> 
> Are you sure that they are performing the min-max and the sum on the
> original data on the fly when requested? Or might they have min, max
> and sum for the various days already recorded, updating each day's
> data once per year as the new data comes in?

And you have to be careful about weathermen.  (weatherpersons?)  Sometimes 
they define the average temperature for a day as the mean of the high and 
low temperatures.  A quick look at wunderground was inconclusive:  the 
averages quoted were within a degree or so of halfway between the max and 
the min, close enough to be explained if they use the high and low values 
to more precision than a degree and then round the result.  Maybe it's a 
good approximation to estimate the average as halfway between the 
extremes.  More data needed for a definitive result.

cheers   cgm

[toc] | [prev] | [next] | [standalone]


#5548

FromPaul Rubin <no.email@nospam.invalid>
Date2011-09-05 18:10 -0700
Message-ID<7x4o0qa32b.fsf@ruckus.brouhaha.com>
In reply to#5540
BruceMcF <agila61@netscape.net> writes:
>> So there's min-max-sum in an everyday, real-world setting.
>
> Are you sure that they are performing the min-max and the sum on the
> original data on the fly when requested? Or might they have min, max
> and sum for the various days already recorded, updating each day's
> data once per year as the new data comes in?

I have no idea what wunderground.com is doing internally.  The simplest
implementation is probably an SQL query that selects the min, max, and
sum from a table after joining on the date and location, which means
computing on the fly, but it's possible they've optimized it some way
like the way you mention.  In any case, it's a straightforward example
of where you'd want all three numbers.

[toc] | [prev] | [next] | [standalone]


#5448

FromBruceMcF <agila61@netscape.net>
Date2011-09-01 11:01 -0700
Message-ID<a6dcd84a-53f3-4569-b538-025e828f5b27@a31g2000vbt.googlegroups.com>
In reply to#5432
On Sep 1, 5:19 am, Paul Rubin <no.em...@nospam.invalid> wrote:

> It didn't seem artificial to me, wanting to know the min, max, and average (mean) of some data set.

Its the precise statement of the problem that seems a bit artificial ~
data is a vector of cells in memory, and you need that precise triplet
of information, and not the median, quartiles, quintiles, sum of
squares, product sum with another vector, etc.

If it was determining the min-max by updating it at each step of data
entry, more useful would be a factor that directly updated a pair of
cells in memory.

: >min-max ( n addr -- )
   2DUP @ MIN OVER !
   CELL+ TUCK @ MAX SWAP ! ;

... then the address could be a double variable, a pair of cells in a
structure, a pair of cells in a scratch workblock, etc.

[toc] | [prev] | [next] | [standalone]


#5449

From"Elizabeth D. Rather" <erather@forth.com>
Date2011-09-01 09:17 -1000
Message-ID<Q_mdnXOwjOz4R8LTnZ2dnUVZ_uudnZ2d@supernews.com>
In reply to#5429
On 8/31/11 9:44 PM, Paul Rubin wrote:
> "Elizabeth D. Rather"<erather@forth.com>  writes:
>> Chuck rarely used xt's explicitly.  And neither he, nor I, nor most of
>> the Forth programmers I've worked with over the years have missed
>> locals at all. It's just a different style of programming from
>> algebraic-style languages.  One factors logic into definitions, and
>> passes data on the stack (and sometimes that data is the address of an
>> array, string, or other stucture), but rarely xt's.
>
> Did he avoid locals by using variables for stuff that wasn't actually
> shared between functions?  I just don't see any clean way to do the
> min-max-sum problem discussed further up, without locals, variables
> instead of locals, or xt's to make multiple passes through the array
> while factoring out the looping code.
>
> Hmm, I guess another possibility is use CREATE to make boilerplate code
> a la C++ templates, but that doesn't seem to be in the factoring spirit.

Andrew and Anton have addressed this with code examples.  I'll just add 
that good factoring is really only feasible in the presence of an actual 
application context, which makes responding to theoretical problems 
awkward.  For example, within an application context, you know which 
values are likely to be used by other words in the application and 
therefore are appropriately kept in variables, as opposed to being only 
used temporarily and locally.

I really don't see a use for CREATE in this context.  CREATE is for 
making data structures.

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]


#5422

From"Ed" <nospam@invalid.com>
Date2011-09-01 13:39 +1000
Message-ID<j3mun9$rb1$1@news-01.bur.connect.com.au>
In reply to#5393
Elizabeth D. Rather wrote:
> On 8/30/11 5:52 PM, Ed wrote:
> > Elizabeth D. Rather wrote:
> >> On 8/29/11 6:08 PM, Ed wrote:
> >> ...
> >>>> Yeah, but what Chuck thinks is "intrinsic to the Forth language" changes
> >>>> from year to year.  For example, FOR ... NEXT is in and DO ... LOOP is
> >>>> out in recent years.
> >>>
> >>> Wow!  And this from one who cited Chuck as an expert Forth
> >>> programmer.  Can anyone take Forth seriously after this :)
> >>
> >> He is very definitely an expert Forth programmer.  He is far from an
> >> expert standards developer.
> >
> > I intended to say "Forth designer" - meaning he has the capacity
> > to discriminate what Forth needs as a language.
>
> Yes.  But Chuck has never thought of himself as a "language designer".
> His view of Forth has always been how to make it the tool to solve the
> current application challenge, and has little interest in the theory of
> programming languages.  Features he needed in several applications over
> time found their way into the common sources, but he not only made no
> attempt to forecast what might be needed in the future, he had only
> contempt for those who attempted to do so.  Moreover, he was perfectly
> happy to make any change in the "rules" at any time if it seemed
> productive for the current project, regardless of its effect on other
> potential users. In summary, he viewed Forth from a purely personal
> perspective, and (from all indications) still does.

That may be.  What Chuck thought of himself and Forth, how it came to
be etc. is one thing - what he practically achieved is another.  Reading
his document "Programming A Problem-Oriented-Language" who can
doubt he was designing a computer language or had the ability, vision
and discrimination to achieve it.  That he didn't want to be tied to a
Standard or be told by others "what is Forth" is understandable and
his prerogative as a creator.

> And in my experience, he took a fairly dim view of manipulating return
> addresses arbitrarily.

What do you mean by "manipulating return addresses arbitrarily"?
From "Thinking Forth" pp.255

    Moore:  "More and more I've come to favor  R> DROP to alter control
    flow. [ ... ] The alternative is burdening the rest of the application with
    checking whether an error occured.  That's an inconvenience".

    Brodie:  "As we've seen there may be times when a premature exit is
    appropriate [...]  Remember though this use of  EXIT and  R> DROP
    is not consistent with structured programming in the strictest sense
    and requires great care. [ ... ] Fooling with the return stack is like playing
    with fire.  But how convenient is it to have fire."

CATCH THROW manipulates return addresses.  Using CATCH THROW
in the circumstances where  R> DROP ... EXIT could be applied would
amount to using a sledge-hammer to crack a nut.

Using  R> DROP ... EXIT  to effect a premature exit was available, legal
and portable in Forth prior to '94.  By not nominating a replacement when
it became non-portable, ANS removed from Forth a facility that users
(and apparently Chuck) enjoyed from earliest times.


[toc] | [prev] | [next] | [standalone]


#5443

FromBruceMcF <agila61@netscape.net>
Date2011-09-01 10:21 -0700
Message-ID<a831572e-eb55-4501-8300-668589a0d406@q12g2000yqd.googlegroups.com>
In reply to#5422
On Aug 31, 11:39 pm, "Ed" <nos...@invalid.com> wrote:
> Using  R> DROP ... EXIT  to effect a premature exit was available, legal
> and portable in Forth prior to '94.  By not nominating a replacement when
> it became non-portable, ANS removed from Forth a facility that users
> (and apparently Chuck) enjoyed from earliest times.

Except it already failed on some implementations prior to '94. Above,
its reported to fail on FPC, a Forth83 system for MS-DOS. So it was
not any more portable prior to '94 than it is now: it works when it
works, and fails when it fails.

And where Chuck refers to using R> DROP for an error recovery, using
CATCH THROW instead is using a nutcracker to crack a nut ... its a
tool to use for error recovery, which does not need adjusting if there
is factoring between the error catch and the error recovery.

[toc] | [prev] | [next] | [standalone]


#5537

From"Ed" <nospam@invalid.com>
Date2011-09-05 12:24 +1000
Message-ID<j41bp7$7cs$1@news-01.bur.connect.com.au>
In reply to#5443
BruceMcF wrote:
> On Aug 31, 11:39 pm, "Ed" <nos...@invalid.com> wrote:
> > Using R> DROP ... EXIT to effect a premature exit was available, legal
> > and portable in Forth prior to '94. By not nominating a replacement when
> > it became non-portable, ANS removed from Forth a facility that users
> > (and apparently Chuck) enjoyed from earliest times.
>
> Except it already failed on some implementations prior to '94. Above,
> its reported to fail on FPC, a Forth83 system for MS-DOS. So it was
> not any more portable prior to '94 than it is now: it works when it
> works, and fails when it fails.

It was portable on forths that followed the classic forth model - which
Standards prior to '94 described.  Systems like F-PC challenged that
model with the result former code and assumptions didn't necessarily
work.

> And where Chuck refers to using R> DROP for an error recovery, using
> CATCH THROW instead is using a nutcracker to crack a nut ... its a
> tool to use for error recovery, which does not need adjusting if there
> is factoring between the error catch and the error recovery.

CATCH THROW is a blunt tool that consumes ridiculous amounts of
return stack space.  One would be unthinking to use it to exit a routine
one level down.  It would be cheaper to use a flag.  R> DROP  is
cheaper than a flag - which was Chuck's point.


[toc] | [prev] | [next] | [standalone]


#5538

FromBruceMcF <agila61@netscape.net>
Date2011-09-04 21:11 -0700
Message-ID<05145414-45c8-4872-9d97-3e8c9c941dee@m38g2000vbn.googlegroups.com>
In reply to#5537
On Sep 4, 10:24 pm, "Ed" <nos...@invalid.com> wrote:
> CATCH THROW is a blunt tool that consumes ridiculous amounts of
> return stack space.

The implementation in hForth consumes two cells.

[toc] | [prev] | [next] | [standalone]


#5568

FromAlbert van der Horst <albert@spenarnc.xs4all.nl>
Date2011-09-06 18:13 +0000
Message-ID<lr45al.np0@spenarnc.xs4all.nl>
In reply to#5538
In article <05145414-45c8-4872-9d97-3e8c9c941dee@m38g2000vbn.googlegroups.com>,
BruceMcF  <agila61@netscape.net> wrote:
>On Sep 4, 10:24=A0pm, "Ed" <nos...@invalid.com> wrote:
>> CATCH THROW is a blunt tool that consumes ridiculous amounts of
>> return stack space.
>
>The implementation in hForth consumes two cells.

ciforth ditto

chforth 3 cells.

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]


#5570

FromAlex McDonald <blog@rivadpm.com>
Date2011-09-06 12:15 -0700
Message-ID<7b460c7c-8d1a-4d76-9ce2-2c71b3b71052@m18g2000vbe.googlegroups.com>
In reply to#5568
On Sep 6, 7:13 pm, Albert van der Horst <alb...@spenarnc.xs4all.nl>
wrote:
> In article <05145414-45c8-4872-9d97-3e8c9c941...@m38g2000vbn.googlegroups.com>,
>
> BruceMcF  <agil...@netscape.net> wrote:
> >On Sep 4, 10:24=A0pm, "Ed" <nos...@invalid.com> wrote:
> >> CATCH THROW is a blunt tool that consumes ridiculous amounts of
> >> return stack space.
>
> >The implementation in hForth consumes two cells.
>
> ciforth ditto
>
> chforth 3 cells.
>
> Groetjes Albert
>
> --
> --
> Albert van der Horst, UTRECHT,THE NETHERLANDS
> Economic growth -- being exponential -- ultimately falters.
> albert@spe&ar&c.xs4all.nl &=nhttp://home.hccnet.nl/a.w.m.van.der.horst

My W32F; 3 cells.

[toc] | [prev] | [next] | [standalone]


#5571

From"Elizabeth D. Rather" <erather@forth.com>
Date2011-09-06 09:53 -1000
Message-ID<H9CdneGj2oq05_vTnZ2dnUVZ_hCdnZ2d@supernews.com>
In reply to#5570
On 9/6/11 9:15 AM, Alex McDonald wrote:
> On Sep 6, 7:13 pm, Albert van der Horst<alb...@spenarnc.xs4all.nl>
> wrote:
>> In article<05145414-45c8-4872-9d97-3e8c9c941...@m38g2000vbn.googlegroups.com>,
>>
>> BruceMcF<agil...@netscape.net>  wrote:
>>> On Sep 4, 10:24=A0pm, "Ed"<nos...@invalid.com>  wrote:
>>>> CATCH THROW is a blunt tool that consumes ridiculous amounts of
>>>> return stack space.
>>
>>> The implementation in hForth consumes two cells.
>>
>> ciforth ditto
>>
>> chforth 3 cells.
>>
>> Groetjes Albert
>>
>> --
>> --
>> Albert van der Horst, UTRECHT,THE NETHERLANDS
>> Economic growth -- being exponential -- ultimately falters.
>> albert@spe&ar&c.xs4all.nl&=nhttp://home.hccnet.nl/a.w.m.van.der.horst
>
> My W32F; 3 cells.

Where did this "ridiculous amount of return stack space" hypothesis come 
from?

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]


#5574

FromAlex McDonald <blog@rivadpm.com>
Date2011-09-06 14:18 -0700
Message-ID<f4a1109e-6a26-43e1-a274-3989fcba0440@fi7g2000vbb.googlegroups.com>
In reply to#5571
On Sep 6, 8:53 pm, "Elizabeth D. Rather" <erat...@forth.com> wrote:
> On 9/6/11 9:15 AM, Alex McDonald wrote:
>
>
>
>
>
>
>
>
>
> > On Sep 6, 7:13 pm, Albert van der Horst<alb...@spenarnc.xs4all.nl>
> > wrote:
> >> In article<05145414-45c8-4872-9d97-3e8c9c941...@m38g2000vbn.googlegroups.com>,
>
> >> BruceMcF<agil...@netscape.net>  wrote:
> >>> On Sep 4, 10:24=A0pm, "Ed"<nos...@invalid.com>  wrote:
> >>>> CATCH THROW is a blunt tool that consumes ridiculous amounts of
> >>>> return stack space.
>
> >>> The implementation in hForth consumes two cells.
>
> >> ciforth ditto
>
> >> chforth 3 cells.
>
> >> Groetjes Albert
>
> >> --
> >> --
> >> Albert van der Horst, UTRECHT,THE NETHERLANDS
> >> Economic growth -- being exponential -- ultimately falters.
> >> albert@spe&ar&c.xs4all.nl&=nhttp://home.hccnet.nl/a.w.m.van.der.horst
>
> > My W32F; 3 cells.
>
> Where did this "ridiculous amount of return stack space" hypothesis come
> from?
>
> 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 90045http://www.forth.com
>
> "Forth-based products and Services for real-time
> applications since 1973."
> ==================================================

Don't know. I find CATCH/THROW very useful, and even use it for number
conversion routines; a set of words are tried in turn until one
succeeds, ie doesn't THROW. Each only needs to return the right level
of stack on success, a much easier task than when an error in
conversion is found at some other stack depth.

In fact, I seem to remember that Albert vd Horst had a scoring system
for how unburstable a Forth was to error conditions. W32F is almost
impossible to break, due to CATCH/THROW and integration into the OS.

3 cells is nothing for the benefit it brings.

[toc] | [prev] | [next] | [standalone]


Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6  Next page →

Back to top | Article view | comp.lang.forth


csiph-web